• Resolved marrix

    (@marrix)


    Hello,

    I’m encountering an issue with the (Divi) search module in WooCommerce. When I click the “add to cart” button, it currently redirects to the front page. However, on the shop pages, the same button works correctly: It adds the selected product to the cart, reloads the page, and provides a notification indicating that the product has been added to the cart.

    I’ve added the following code to my child theme’s functions.php to add the cart button:

    add_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_add_to_cart’, 20 );

    How can I modify the link behavior of the “add to cart” button in the search module to match the functionality on the shop pages?

    BTW: I have not activated ‘Enable Ajax add to cart button’ in WooCommerce settings (WC > Options > Products > General). If I enable it, the number of items in the cart won’t be updated after clicking ‘Add to Cart’.

    In shorter words: I want the search result ‘add to cart’ button to match the product page’s behavior.

    Thank you

Viewing 1 replies (of 1 total)
  • Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @marrix

    The issue you’re facing seems to be related to the Divi search module and not necessarily WooCommerce itself. However, I can still provide you with a possible solution.

    You can try using the woocommerce_is_ajax filter to force WooCommerce to think that an AJAX request is being made, which should make the “add to cart” button behave as it does on the shop pages.

    Please note that this is a workaround and might not work in all cases. Also, since this is a third-party theme which we don’t provide support for (please see our Support Policy), it would be best to reach out to the theme’s developers for a more permanent solution here.

    I am sure they will have no problem supporting you there.

    I hope this helps! If you have any other questions, feel free to ask.

Viewing 1 replies (of 1 total)
  • The topic ‘Enabling ‘Add to Cart’ on search redirects to frontpage’ is closed to new replies.