Skip to content

Commit

Permalink
Fix listing and add_to_cart for blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
puntope committed Sep 11, 2023
1 parent 0ee7953 commit 8ef5d19
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions includes/class-wc-google-analytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ public function __construct() {
add_action( 'woocommerce_after_cart', array( $this, 'remove_from_cart' ) );
add_action( 'woocommerce_after_mini_cart', array( $this, 'remove_from_cart' ) );
add_filter( 'woocommerce_cart_item_remove_link', array( $this, 'remove_from_cart_attributes' ), 10, 2 );
add_action( 'woocommerce_after_shop_loop_item', array( $this, 'listing_impression' ) );
add_action( 'woocommerce_after_shop_loop_item', array( $this, 'listing_click' ) );
add_action( 'woocommerce_after_shop_loop_item_title', array( $this, 'listing_click' ) );
add_action( 'woocommerce_after_shop_loop_item_title', array( $this, 'listing_impression' ) );
add_action( 'woocommerce_after_single_product', array( $this, 'product_detail' ) );
add_action( 'woocommerce_after_checkout_form', array( $this, 'checkout_process' ) );

Expand Down
2 changes: 1 addition & 1 deletion includes/class-wc-google-gtag-js.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public static function listing_click( $product, $position ) {

wc_enqueue_js(
"
$( '.products .post-" . esc_js( $product->get_id() ) . " a' ).on('click', function() {
$( '.product.post-" . esc_js( $product->get_id() ) . " a , .product.post-" . esc_js( $product->get_id() ) . " button' ).on('click', function() {
if ( true === $(this).hasClass( 'add_to_cart_button' ) ) {
$add_to_cart_event_code
} else {
Expand Down

0 comments on commit 8ef5d19

Please sign in to comment.