• Hi there,

    So, all the stores’ products in my website are listed in the archive page, whether it is simple product or variable product. I would like when the customer clicks the “add to cart” button which available on every product, it shows a notification that the product has been added to cart. I’ve managed to have the “add to cart” button on every product and also have able to show notification for the simple product.

    Now I was wondering if variable product can do this as well. I tried to add some filter using the hook on WooCommerce but I supposed it only hooked to the first product in the page. Example, if I have 2 variable products on the same archive page, the hook will only works on the first product. While the second product hook will take place on the first product hook.

    For better example, my website link: https://taleofnightingales.com/collection/
    The first product and fourth product on the list are variable product. If I add the first product, it works fine but when I try to add the other one, the notification “add to basket” shows up on the first product div.

    I really appreciate any idea to solve this issue.
    Thank you,
    Cheers

    https://www.ads-software.com/plugins/woocommerce/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Just letting you know: I went to your site and it was so slow that I didn’t check anything out. All other sites load normally, yet yours was painfully slow for me.

    Thread Starter c28g

    (@c28g)

    Hmm, that’s weird. I tried to open it elsewhere but it works. Probably it’s regarding my hosting. ??

    This is a screenshot of what the notification is like. The “add to basket” notification always shows up on the first hook. I assume something in the message hook woocommerce_show_messages.

    Firstly I remove the hook from the top most page by adding:

    //Remove Added To Cart top message in archive product page
    remove_filter('woocommerce_before_shop_loop', 'woocommerce_show_messages', 10, 2);

    Then I add it back using:

    //Hook Added To Cart message in archive product page
    add_filter('woocommerce_after_shop_loop_item', 'woocommerce_show_messages', 10, 2);

    Anyone could enlighten me about this?
    Thank you,
    Cheers

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hook WooCommerce message on archive/category page’ is closed to new replies.