Fix error when adding to cart from the Product Collection block if Google Analytics plugin is enabled (II) (#43177)
* Revert "Trigger event `experimental__woocommerce_blocks-cart-add-item` in the SSR Product Button vis Interactivity API (#42946)"
This reverts commit 4fec136da1
.
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
---------
Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
parent
4efd2123a3
commit
c58b0cf936
|
@ -7,7 +7,6 @@ import { CART_STORE_KEY as storeKey } from '@woocommerce/block-data';
|
|||
import { Cart } from '@woocommerce/type-defs/cart';
|
||||
import { createRoot } from '@wordpress/element';
|
||||
import NoticeBanner from '@woocommerce/base-components/notice-banner';
|
||||
import { doAction } from '@wordpress/hooks';
|
||||
|
||||
interface Context {
|
||||
isLoading: boolean;
|
||||
|
@ -136,7 +135,6 @@ const { state } = store< Store >( 'woocommerce/product-button', {
|
|||
*addToCart() {
|
||||
const context = getContext();
|
||||
const { productId, quantityToAdd } = context;
|
||||
const product = getProductById( state.cart, productId );
|
||||
|
||||
context.isLoading = true;
|
||||
|
||||
|
@ -146,15 +144,6 @@ const { state } = store< Store >( 'woocommerce/product-button', {
|
|||
quantityToAdd
|
||||
);
|
||||
|
||||
// Adding a manual trigger of the event for backward compatibility
|
||||
// and symmetry ("remove" event is triggered properly from Cart and Mini Cart).
|
||||
// The events will be revisited and unified in scope of:
|
||||
// https://github.com/woocommerce/woocommerce/pull/42946
|
||||
yield doAction(
|
||||
`experimental__woocommerce_blocks-cart-add-item`,
|
||||
product
|
||||
);
|
||||
|
||||
// After the cart is updated, sync the temporary number of items again.
|
||||
context.temporaryNumberOfItems = state.numberOfItemsInTheCart;
|
||||
} catch ( error ) {
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
Comment: Product Button: remove the `experimental__woocommerce_blocks-cart-add-item` event to avoid conflicts with extensions.
|
||||
|
Loading…
Reference in New Issue