PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.5
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.5
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 1.3.19 trunk All 48 releases
← All changes | app/Hooks/Handlers/BlockEditors/Buttons/AddToCartButtonBlockEditor.php +6 -1 1.3.21 → 1.6.5 View file →
@@ -111,9 +111,14 @@
111 111 return '';
112 112 }
113 113
114 114 ob_start();
115 - (new ProductRenderer($product))->renderAddToCartButtonBlock($shortCodeAttribute);
115 + // Pass the block's selected variant as the renderer's default variation
116 + // so the button's data-cart-id (and stock/price) reflect that variant.
117 + // Without this the renderer falls back to the product's first/default
118 + // variant, and the button always adds the wrong variant to the cart.
119 + (new ProductRenderer($product, ['default_variation_id' => $variant->id]))
120 + ->renderAddToCartButtonBlock($shortCodeAttribute);
116 121 return ob_get_clean();
117 122 }
118 123
119 124 }