• Resolved sinistred

    (@sinistred)


    Hello,

    Due to Covid-19 I have set all my products to “out of stock” so in the front end the add to cart button product is not “clicable” (gray button). But for some unknowns reasons the event gtm4wp.addProductToCartEEC is fired when you click on the addtocart button. You have to choose a “colonie” and click on addtocart.

    Best

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Thomas Geiger

    (@duracelltomi)

    Hi,

    Thanks for letting me know about this bug.
    The root of the issue is that the button itself is technically not disabled, if it would be, the add to cart event wouldn’t fire. This is not your fault and also not your themes issue.

    WooCommerce simply adds a “post-it” to the button and writes the label “disabled” on it which also renders in the browser with a different design.

    Can you help me testing a simple solution? Either you or your programmer needs to edit a file in your WordPress instance.

    Find the following file:
    wp-content/plugins/duracelltomi-google-tag-manager/js/gtm4wp-woocommerce-enhanced.js

    search for this line:
    jQuery( document ).on( 'click', '.single_add_to_cart_button', function() {

    change it to this:
    jQuery( document ).on( 'click', '.single_add_to_cart_button:not(.disabled)', function() {

    This should prevent the button to fire the add to cart event if in disabled state.
    If this works on your site, I will add this to GTM4WP.

    Thread Starter sinistred

    (@sinistred)

    Hello,

    I have tried your solution and I have edit the file but the problem remain.

    Best,

    Plugin Author Thomas Geiger

    (@duracelltomi)

    Hi,

    There is a typo in your added code:

    jQuery( document ).on( 'click', '.single_add_to_cart_button:not(.disable)', function() {

    It should be disableD.

    So:
    jQuery( document ).on( 'click', '.single_add_to_cart_button:not(.disabled)', function() {

    Thread Starter sinistred

    (@sinistred)

    Thanks I will try.

    Best

    Thread Starter sinistred

    (@sinistred)

    Hello,

    I thinks it works ??

    Best

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘gtm4wp.addProductToCartEEC firing on out of stock product’ is closed to new replies.