← All changes
|
app/Hooks/Handlers/BlockEditors/ProductCardBlockEditor.php
+7
-14
1.3.21
→
1.7.0
View file →
| @@ -5,9 +5,8 @@ | ||
| 5 | 5 | use FluentCart\App\Helpers\CurrenciesHelper; |
| 6 | 6 | use FluentCart\App\Hooks\Handlers\ShortCodes\ProductCardShortCode; |
| 7 | 7 | use FluentCart\App\Models\Product; |
| 8 | 8 | use FluentCart\App\Services\Translations\TransStrings; |
| 9 | -use FluentCart\App\Vite; | |
| 10 | 9 | use FluentCart\Framework\Support\Arr; |
| 11 | 10 | use FluentCart\App\Helpers\Helper; |
| 12 | 11 | |
| 13 | 12 | class ProductCardBlockEditor extends BlockEditor |
| @@ -40,9 +39,9 @@ | ||
| 40 | 39 | 'slug' => $this->slugPrefix, |
| 41 | 40 | 'name' => static::getEditorName(), |
| 42 | 41 | 'title' => __('Product Card', 'fluent-cart'), |
| 43 | 42 | 'description' => __('This block will display the product card.', 'fluent-cart'), |
| 44 | - 'placeholder_image' => Vite::getAssetUrl('images/placeholder.svg'), | |
| 43 | + 'placeholder_image' => Helper::getProductPlaceholderUrl(), | |
| 45 | 44 | 'currency_sign' => $currencySign, |
| 46 | 45 | 'currency_position' => $currencyPosition |
| 47 | 46 | ], |
| 48 | 47 | 'fluent_cart_block_translation' => TransStrings::blockStrings(), |
| @@ -70,20 +69,14 @@ | ||
| 70 | 69 | if (!$product) { |
| 71 | 70 | return ''; |
| 72 | 71 | } |
| 73 | 72 | |
| 74 | - $selectedProductId = 'product_id=' . $product->ID; | |
| 75 | - | |
| 76 | - $selectedVariantId = ''; | |
| 77 | - if ($variationId = Arr::get($shortCodeAttribute, 'variant_id', false)) { | |
| 78 | - $selectedVariantId = 'variant_id=' . $variationId; | |
| 79 | - } | |
| 80 | - | |
| 81 | - $priceFormat = Arr::get($shortCodeAttribute, 'price_format', 'starts_from'); | |
| 82 | - $cardWidth = Arr::get($shortCodeAttribute, 'card_width', 216); | |
| 83 | - | |
| 84 | - $shortcodeName = ProductCardShortCode::getShortCodeName(); | |
| 85 | - return "[$shortcodeName $selectedVariantId $selectedProductId price_format=$priceFormat card_width=$cardWidth]"; | |
| 73 | + return ProductCardShortCode::make([ | |
| 74 | + 'product_id' => $product->ID, | |
| 75 | + 'variant_id' => Arr::get($shortCodeAttribute, 'variant_id', ''), | |
| 76 | + 'price_format' => Arr::get($shortCodeAttribute, 'price_format', 'starts_from'), | |
| 77 | + 'card_width' => Arr::get($shortCodeAttribute, 'card_width', 216), | |
| 78 | + ])->renderShortcode($block); | |
| 86 | 79 | } |
| 87 | 80 | |
| 88 | 81 | |
| 89 | 82 | |