How to make “return to shop” button return to previous page and not the cart?
-
So I’ve been fiddling with this for hours and can’t seem to figure this out.
I just want the “return to shop” button (visible when cart is empty) to return to the previous page.
I have found ways to make “return to shop” return to the previous page, but the code I’ve found all lead to an infinite loop problem in which the cart thinks the “previous page” is also the cart page when it is emptied because that was the “previous page” before it was emptied. Hence, clicking “return to shop” will link right back to the cart.
For example, the code below should have worked if not for the infinite loop problem:
function wc_empty_cart_redirect_url() { return $_SERVER['HTTP_REFERER']; } add_filter( 'woocommerce_return_to_shop_redirect', 'wc_empty_cart_redirect_url' );
Is there a way to accomplish this?
Thank you!
- This topic was modified 6 years, 5 months ago by .
- This topic was modified 6 years, 5 months ago by .
- This topic was modified 6 years, 5 months ago by .
- This topic was modified 6 years, 5 months ago by .
- This topic was modified 6 years, 5 months ago by .
- This topic was modified 6 years, 5 months ago by .
- The topic ‘How to make “return to shop” button return to previous page and not the cart?’ is closed to new replies.