I have read quite a lot of possible ways to do it but after going through each of them I'm still not able to understand what should be the correct way of doing it and how the correct way works.
When the woo-commerce add to cart hook
Problem in implementation:
The hooks such as
echo <script>//some js code</script>. Whereas the woocommerce hooks such as
woocommerce_add_to_cart update is happening via ajax.
What I've tried till now:
One possible solution I found was when the
woocommerce_add_to_cart hook is triggered change the data attribute of the Add to cart button and then read them in the jQuery script via
What I want:
P.S- I'm new to the WordPress/Php ecosystem and would really appreciate it if someone can explain a possible solution to my question in detail.