diff --git a/includes/class-wc-google-gtag-js.php b/includes/class-wc-google-gtag-js.php index 1820cf5d..cfceb20e 100644 --- a/includes/class-wc-google-gtag-js.php +++ b/includes/class-wc-google-gtag-js.php @@ -394,8 +394,12 @@ public function remove_from_cart() { }]}' ); + // To track all the consecutive removals, + // we listen for clicks on `.woocommerce` container(s), + // as `.woocommerce-cart-form` and its items are re-rendered on each removal. wc_enqueue_js( - "$( '.remove' ).off('click', '.remove').on( 'click', function() { + "const selector = '.woocommerce-cart-form__cart-item .remove'; + $( '.woocommerce' ).off('click', selector).on( 'click', selector, function() { $event_code });" );