Skip to content

Commit

Permalink
Fix select_item on variation products in product lists.
Browse files Browse the repository at this point in the history
  • Loading branch information
TorbenLundsgaard committed Nov 28, 2023
1 parent 21c431d commit 7aee345
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion assets/integration/woocommerce.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ Find out about what's new in our [our release post](https://gtmkit.com/gtm-kit-1
#### Bugfixes:
* Add missing _sbp cookie in the cookie keeper.
* The constant GTMKIT_EDD_DEBUG_TRACK_PURCHASE and GTMKIT_WC_DEBUG_TRACK_PURCHASE was not overriding correct.
* Because of recent changes in WooCommerce clicks on grouped products in a product list would be treated as add_to_cart and not select_item.

#### Other:
* Refactoring code for simplicity and maintainability
Expand Down
6 changes: 3 additions & 3 deletions src/js/woocommerce.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function gtmkitLoad() {

if (
eventTargetElement.closest(
'.add_to_cart_button:not(.single_add_to_cart_button)'
'.add_to_cart_button.ajax_add_to_cart:not(.single_add_to_cart_button)'
)
) {
event = 'add_to_cart';
Expand Down Expand Up @@ -291,8 +291,8 @@ function gtmkitLoad() {

// select_item event on clicks in product lists
const productListItemSelector =
'.products li:not(.product-category) a:not(.add_to_cart_button,.add_to_wishlist,.tinvwl_add_to_wishlist_button),' +
'.wc-block-grid__products li:not(.product-category) a:not(.add_to_cart_button,.add_to_wishlist,.tinvwl_add_to_wishlist_button),' +
'.products li:not(.product-category) a:not(.add_to_cart_button.ajax_add_to_cart,.add_to_wishlist,.tinvwl_add_to_wishlist_button),' +
'.wc-block-grid__products li:not(.product-category) a:not(.add_to_cart_button.ajax_add_to_cart,.add_to_wishlist,.tinvwl_add_to_wishlist_button),' +
'.woocommerce-grouped-product-list-item__label a:not(.add_to_wishlist,.tinvwl_add_to_wishlist_button)';
document.addEventListener('click', function (e) {
const eventTargetElement = e.target;
Expand Down

0 comments on commit 7aee345

Please sign in to comment.