• Resolved wolfage

    (@wolfage)


    I’m notice that when i add to cart product from shop page and ajax add to cart is enabled it is impossible to use woocommerce_add_to_cart hook. I’m using this hook in my plugin to send some data to external server when add to cart event happens. But looks that using this hook causes problems for add to cart via ajax. When i click on add to cart button it is showing permanent loader on this button. I know that problem is directly in using this hook, because when i don’t use it add to cart via ajax works ok. Please notice that i do this on clean wordpress installation using default Storefront theme and set of default test products. So i’m confused how i could avoid such troubles. Is is any alternative hooks which triggers after add to cart even. Does add to cart via ajax has another hook?

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support RK a11n

    (@riaanknoetze)

    Hi there,

    While I’m not sure what your code looks like on the exact hook you’re using, you could make use of a plugin like https://www.ads-software.com/plugins/wp-inspect/ to get a visual reference guide of all the hooks/filters that are available/executed on a given page – This comes in quite handy in development ??

    Thread Starter wolfage

    (@wolfage)

    @riaanknoetze Hi! Thank you for your answer!
    I think i understand where is devil. Inside woocommmerce_add_to_cart hook i tried to use printf and echo functions and this causes problems. When i have removed code which should print any data on page or in console it works.

    Plugin Support EastOfWest a11n

    (@eastofwest)

    It seems like you’ve found a solution to this issue, so I’ll go head and mark this thread as resolved. If you have any further questions, you can always start a new thread.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Ajax add to cart problem with woocommerce_add_to_cart hook’ is closed to new replies.