Don't miss the chance! Use Coupon: black30 on checkout page to get 30% discount on any plugins.Buy Now!
Public Ticket #3396

add_to_cart event not working with variable products

Damian

Hello,

My client is using your plugin in the store.
On the product page with variants (e.g. https://greenlo.pl/produkt/szczotka-laboratoryjna-wycior-do-mycia-pipet-rozne-rozmiary/ ) GTM does not see the event view_item and add_to_cart. In the simple product (e.g. https://greenlo.pl/produkt/maseczki-medyczne-tw-plast-3-warstwowe-typ-iir-50-szt/ ) everything is fine.

What should be done to fix this? Is it a plugin or theme issue?

wpx

wpx

Hi Damian,

I hope you are doing well today.

Yes, I have seen the wp.org support thread.

Then tried to download the GTM plugin and checked it carefully. They have a file woocommerce.js (gtm-kit > src > js > woocommerce.js ), they are targeting the <form> and [name=variation_id] inside <form>.

You can see the line number 167 - 192 of woocommerce.js. They are pushing their data using the above mentioned tag and tag attribute. In our Product Variation Table plugin, we have disabled the <form> to display a button Available Options. So, GTM plugin doesn't recognize the values for variable product.

It is not a plugin or theme issue. They have created their plugin only for the basic WooCommerce default dropdown. If they kept a trigger to push the parameter for third party plugin, we could pass the needed values to work with the event add_to_cart. Unfortunately, they didn't keep anything like that. So, this compatibility can't done from one side.

You can ask them to add a trigger so that we can push the needed value for:

window[datalayerName].push({
event,
ecommerce: {
currency: window.gtmkit_data.wc.currency,
value: price * quantity,
items: [selectedProductVariationData],
},
});

Line number 184 - 191 (woocommerce.js).

Note: There is a massive student protest ongoing within the country, and the government has shut down the internet for the past five days. You can check the situation on YouTube if you want more information. Now, the internet is available with a very limited speed.

I hope this will clear up your confusion that why it is not working as expected.

Best Regards

 

Damian

Damian

Hello.

I don't understand.

Is this a problem with the new version of woocommerce or what?

I am using GTM (Google Tag Manager) and implementing it with GTM4WP plugin.
Previously, all events worked.
The theme has been changed.
Used your plugin Product Variation Table for WooCommerce - PVT I think for products with variants.

I don't understand.

Is this a problem with the new version of woocommerce?
I am using GTM (Google Tag Manager) and implementing it with GTM4WP plugin.
Previously, all events worked.
The theme has been changed.
Used your plugin Product Variation Table for WooCommerce - PVT I think for products with variants.

Now add_to_cart and view_item for products with variants does not work.

wpx

wpx

Hi Damian,

I am sorry if my last message was unclear to you.

Is it working previously with PVT - Product Variation Table?

If so, we didn't change a single line for the "Add-to-cart" events and you should mention it earlier.

Still, you can download the 1.4.22 from here- https://downloads.wordpress.org/plugin/product-variant-table-for-woocommerce.1.4.22.zip

Then check whether it works or not.

Again, if it previously worked with PVT. You can change the theme to the old one, because, we are using the same mechanism for cart as WooCommerce does.

Best Regards

Damian

Damian

No.

Previously, everything worked on standard woo functions.
The way you created in Woo a product with variants - that's how it worked.
Previously, your plugin was not used.

Now the theme (I think custom) + ACF + your plugin has changed.

wpx

wpx

Hi Damian,

In that case, I will refer you to read my previous reply - https://wpxtension.com/ticket/3396/#cid-3697

As I said, the plugin (GTM Kit) you used to get add_to_cart event was developed for WooCommerce default dropdown not for PVT- Product Variation Table. So, it will work for WooCommerce default dropdown not with the tabular view of variation (by PVT -  Product Variation Table plugin).

If you want PVT -  Product Variation Table and GTM Kit work together, you have to contact with the GTM Kit plugin author. Then ask them to keep a trigger/event here gtm-kit > src > js > woocommerce.js between these lines 184 - 191

As our plugin has no feature with Google Tag Manager. We are unable to add it to our plugin, unless the GTM Kit plugin keep an event (or any mechanism) for the third party plugin like PVT - Product Variation Table plugin.

Best Regards

Damian

Damian

Sorry, but you don't understand me at all.

I DON'T USE THE GTM KIT PLUGIN.

I use the GTM4WP plugin to integrate with Google Tag Manager.

At the very beginning it was enough and all events worked.

Then there was a change of theme.
I think the Theme is custom, ACF was used for it, and your plugin was used for the variant products.

I emphasize that I am using GTM4WP and not GTM Kit plugin.

That's the only thing that has changed: the theme, ACF and your plugin have arrived.
As of this moment, add_to_cart and view_item events do not work.

Have I written clearly now?

wpx

wpx

Hi,

Sorry for mentioning the wrong plugin name. Again our plugin has no feature for Google Tag Manager.

GTM4WP plugin added the event for Default WooCommerce variation dropdown form. They didn't make it compatible with PVT - Product Variation Table plugin. Please contact the author of GTM4WP and ask them if they have any mechanism that can be applied with PVT - Product Variation Table plugin or not.

I hope it will be a clear message to you from our end.

Best Regards