Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add to cart works even when requried input fields are not fill. #274

Open
subhanahmet opened this issue Jul 5, 2023 · 1 comment
Open
Assignees

Comments

@subhanahmet
Copy link

I have some products are required input fields. When input not filled and click add to basket button, GTM4WP plugin firing add_to_cart event. But it isn’t true. It must be fire only real add to cart actions.

Screenshot

How can I resolve this issue?

@duracelltomi
Copy link
Owner

Hi,

That is a tricky issue, I already faced it but there is no easy solution.

One solution could be to rewrite the code in GTM4WP to catch the added_to_cart event of WooCommerce in the browser. The problem with this is that it is not triggered when AJAX based cart is not enabled. So when page reloads after pressing the add to cart button, no add to cart tracking would work.

The other solution which might be the only solution is to replace JavaScript based tracking with some PHP code and hook into this WooCommerce action:
https://woocommerce.github.io/code-reference/files/woocommerce-includes-class-wc-cart.html#source-view.1276

I will look at this direction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants