This topic has 4 replies, 2 voices, and was last updated 6 months, 2 weeks ago ago by Jack Richardson
Hi there. I have Google Tag Manager for WooCommerce PRO installed. I opened a support ticket with them as I have duplicate add_to_cart events firing on both my XStore sites. They tell me it’s due the the ajax_add_to_cart class. What are your thoughts on this?
Their exact message is as follows:
Doubled add_to_cart event on product page is caused by incorrect/unnecessary css class pinned to “add to cart” button. This element shouldn’t have “ajax_add_to_cart” according to WooCommerce theme standards. The Add to cart button on the single page should have “single_add_to_cart_button” css class. In your case, the button has both classes, so the event is doubled (triggered twice by JavaScript).
Dear @Roobinda,
We have implemented the ‘ajax_add_to_cart’ class to facilitate the AJAX-based addition of products to your cart, utilizing WooCommerce’s functionality. Should you prefer the standard method of adding products to your cart, which includes a page refresh, you may opt to disable the ‘Ajax Add To Cart’ feature. This can be done by navigating to Theme Options -> WooCommerce -> Single Product -> Layout. For your convenience, here is a direct link to the settings: https://prnt.sc/kFLekpq9OLwa.
Upon deactivation, the ‘Add to Cart’ button on single product pages will no longer include the ‘ajax_add_to_cart’ class; it will solely contain the ‘single_add_to_cart_button’ class. Additionally, if you have established contact with the plugin developers, it may be beneficial for them to implement conditions to handle scenarios where both classes are applied to a button. This would help prevent any potential issues with double triggering.
Deactivating the ‘Ajax Add To Cart’ as described should resolve your concerns regarding double triggering. Should you require further assistance or have any questions, please do not hesitate to contact us.
Best Regards,
Jack Richardson
The 8Theme Team
Thank you for the comprehensive answer Jack.
I have tested this and switching off AJAX add to cart on the single product pages does the trick.
Is there a way to switch AJAX off on the ‘Add to Cart’ buttons on the shop/archive pages?
Dear @Roobinda,
We hope this message finds you well. To deactivate the AJAX functionality on product archives, please navigate to the global WooCommerce settings and disable the option titled ‘Enable AJAX add to cart buttons on archives’. For your convenience, here is a screenshot of the settings page: https://prnt.sc/-8KWNDB5BFjs.
Should you require any further assistance, please do not hesitate to contact us.
Best Regards,
Jack Richardson
The 8Theme Team
You must be logged in to reply to this topic.Log in/Sign up