Skip to content

Commit

Permalink
Merge pull request #2631 from StyleT/patch-1
Browse files Browse the repository at this point in the history
Fixed AddToCart duplication when other plugins clone cart
  • Loading branch information
rawdreeg authored Oct 4, 2023
2 parents bed54b5 + cd0f039 commit a96533d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions facebook-commerce-events-tracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,12 @@ public function inject_add_to_cart_event( $cart_item_key, $product_id, $quantity
return;
}

$cart = WC()->cart;
// Check if we're dealing with cloned cart
if ( ! isset( $cart->cart_contents[ $cart_item_key ] ) ) {
return;
}

$product = wc_get_product( $variation_id ?: $product_id );

// bail if invalid product or error
Expand Down

0 comments on commit a96533d

Please sign in to comment.