PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.7.0
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.7.0
1.7.0 1.6.6 1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 All 50 releases
← All changes | app/Hooks/Handlers/BlockEditors/Buttons/AddToCartButtonBlockEditor.php +7 -3 1.3.21 → 1.7.0 View file →
@@ -8,9 +8,8 @@
8 8 use FluentCart\App\Models\ProductVariation;
9 9 use FluentCart\App\Modules\Templating\AssetLoader;
10 10 use FluentCart\App\Services\Renderer\ProductRenderer;
11 11 use FluentCart\App\Services\Translations\TransStrings;
12 -use FluentCart\App\Vite;
13 12 use FluentCart\Framework\Support\Arr;
14 13
15 14 class AddToCartButtonBlockEditor extends BlockEditor
16 15 {
@@ -69,9 +68,9 @@
69 68 'slug' => $this->slugPrefix,
70 69 'name' => static::getEditorName(),
71 70 'title' => __('Add to Cart', 'fluent-cart'),
72 71 'description' => __('A custom button block with product selection and automatic link assignment.', 'fluent-cart'),
73 - 'placeholder_image' => Vite::getAssetUrl('images/placeholder.svg'),
72 + 'placeholder_image' => Helper::getProductPlaceholderUrl(),
74 73 ],
75 74 'fluent_cart_block_translation' => TransStrings::blockStrings(),
76 75 ];
77 76 }
@@ -111,9 +110,14 @@
111 110 return '';
112 111 }
113 112
114 113 ob_start();
115 - (new ProductRenderer($product))->renderAddToCartButtonBlock($shortCodeAttribute);
114 + // Pass the block's selected variant as the renderer's default variation
115 + // so the button's data-cart-id (and stock/price) reflect that variant.
116 + // Without this the renderer falls back to the product's first/default
117 + // variant, and the button always adds the wrong variant to the cart.
118 + (new ProductRenderer($product, ['default_variation_id' => $variant->id]))
119 + ->renderAddToCartButtonBlock($shortCodeAttribute);
116 120 return ob_get_clean();
117 121 }
118 122
119 123 }