Enabling ‘Add to Cart’ on search redirects to frontpage
-
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
- The topic ‘Enabling ‘Add to Cart’ on search redirects to frontpage’ is closed to new replies.