woocommerce / woocommerce-google-analytics-integration

WordPress plugin: Provides the integration between WooCommerce and Google Analytics.
http://wordpress.org/plugins/woocommerce-google-analytics-integration/
172 stars 69 forks source link

Fix incorrect quantity when product is already in cart #421

Closed martynmjones closed 5 months ago

martynmjones commented 5 months ago

Changes proposed in this Pull Request:

Closes #391

Adjusts the utility to retrieve a product by its ID to prioritise the product data object over the cart object. This is to prevent the existing cart quantity from being sent with an add_to_cart event.

Additionally, the function to format product data is updated to pass along the quantity on the added_to_cart event.

Detailed test instructions:

  1. Checkout fix/391-incorrect-product-quantity and build the extension
  2. Go to the shop archive
  3. Add a simple product to the cart multiple times
  4. Refresh the page
  5. Add the same product to the cart and confirm that the event sent has the correct quantity of 1
  6. Go to the single product page
  7. Set the quantity 4 and add it to cart
  8. Confirm the quantity sent in the event is 4

Changelog entry

Fix - Incorrect quantity value when adding product to the cart that exists in the cart