WPIntell

Source evidence

Add to cart event on custom button class

Tag Pilot FREE – Google Tag Manager Integration for WooCommerce · support · 2024-02-01T16:44:00+00:00

mixedsentiment
mediumseverity
0.85relevance
7replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

5 / 34 rows with source links

14.7% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

29 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
saracomin resolved
Hi, I saw that the click event is only caught via certain classes (.cart .single_add_to_cart_button, ajax_add_to_cart), is it possible to add the event to another class? Hey @saracomin , good catch. Currently, it is not supported to easily customise those classes. Can you share with me what exactly you try to achieve? Is it about custom theme implementation or about some extra add to cart buttons that go beyond typical Woo setup? Eager to learn more, HI, thanks so much for the quick response! I use a plugin that allows me to view the products in the table ( https://wordpress.org/plugins/woo-product-table/ ), because the woocommerce class view for the project I developed wasn’t right for me an example for their website https://demo.wooproducttable.com/product/samsung-galaxy/ button add to cart has to trigger the event Hello @saracomin again, sorry for not getting back before the weekend. Unfortunately, the FREE version of our plugin available here won’t support that out-of-the-box. I mean even if you modify the code and listen to custom add_to_cart button classes, you would encounter issues with getting the details of actual product (variation name, price which can be different for each variation). Our paid plugin would make that slightly easier, because we detect if product type is variable, then we make all variants details available for JS. Alternatively, maybe there is an option to make this table plugin reload page on add_to_cart, then the event can be generated server-side. Either way we would need to extend even the PRO version to support this plugin. I don’t want to only steer you towards our paid offering, so you may want to look how the default add_to_cart event is implemented in this plugin and try to duplicate that code and extending it to cover your use case: https://github.com/tagconcierge/tc-woocommerce-plugin-free/blob/develop/src/EventStrategy/AddToCartStrategy.php If you decide going that path I can help figuring out how to connect that with existing plugin. Let me know if that was of any help. Hey @saracomin , I will allow myself to close this thread for now. If you would like to get back to this topic feel free to continue it, open another thread or send us an email at contact@tagconcierge.com All the best, Hi, In the end I solved it by using the same js code but adapting it to the data present in the product table on the page 🙂 Hey @saracoming, nice, great to hear that you solved it. Do you read the product variant details from HTML directly? Hi, Yes, exactly, even if it’s not the nicest thing to do, it allowed me to get all the items I needed

Comments

7 shown
Tag Concierge 2024-02-01T16:48:00+00:00

Hey @saracomin , good catch. Currently, it is not supported to easily customise those classes. Can you share with me what exactly you try to achieve? Is it about custom theme implementation or about some extra add to cart buttons that go beyond typical Woo setup? Eager to learn more,

saracomin 2024-02-01T16:54:00+00:00

HI, thanks so much for the quick response! I use a plugin that allows me to view the products in the table ( https://wordpress.org/plugins/woo-product-table/ ), because the woocommerce class view for the project I developed wasn’t right for me an example for their website https://demo.wooproducttable.com/product/samsung-galaxy/ button add to cart has to trigger the event

Tag Concierge 2024-02-05T15:12:00+00:00

Hello @saracomin again, sorry for not getting back before the weekend. Unfortunately, the FREE version of our plugin available here won’t support that out-of-the-box. I mean even if you modify the code and listen to custom add_to_cart button classes, you would encounter issues with getting the details of actual product (variation name, price which can be different for each variation). Our paid plugin would make that slightly easier, because we detect if product type is variable, then we make all variants details available for JS. Alternatively, maybe there is an option to make this table plugin reload page on add_to_cart, then the event can be generated server-side. Either way we would need to extend even the PRO version to support this plugin. I don’t want to only steer you towards our paid offering, so you may want to look how the default add_to_cart event is implemented in this plugin and try to duplicate that code and extending it to cover your use case: https://github.com/tagconcierge/tc-woocommerce-plugin-free/blob/develop/src/EventStrategy/AddToCartStrategy.php If you decide going that path I can help figuring out how to connect that with existing plugin. Let me know if that was of any help.

Tag Concierge 2024-02-07T09:12:00+00:00

Hey @saracomin , I will allow myself to close this thread for now. If you would like to get back to this topic feel free to continue it, open another thread or send us an email at contact@tagconcierge.com All the best,

saracomin 2024-02-07T09:26:00+00:00

Hi, In the end I solved it by using the same js code but adapting it to the data present in the product table on the page 🙂

Tag Concierge 2024-02-07T10:41:00+00:00

Hey @saracoming, nice, great to hear that you solved it. Do you read the product variant details from HTML directly?

saracomin 2024-02-07T10:45:00+00:00

Hi, Yes, exactly, even if it’s not the nicest thing to do, it allowed me to get all the items I needed