Last active
February 14, 2022 19:50
-
-
Save wpflames/0f0b6acb8aac1b90b32d57ce7653a998 to your computer and use it in GitHub Desktop.
Change Continue Shopping link to the Previously Visited Page in WooCommerce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // ========================================================================= | |
| // Changes the redirect URL for the Return To Shop button in the cart. | |
| // ========================================================================= | |
| function wc_empty_cart_redirect_url() { | |
| if( WC()->cart->is_empty() ) { | |
| return wc_get_page_permalink( 'shop' ); | |
| } else{ | |
| return $_SERVER['HTTP_REFERER']; | |
| } | |
| } | |
| add_filter( 'woocommerce_return_to_shop_redirect', 'wc_empty_cart_redirect_url' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment