📅  最后修改于: 2023-12-03 15:21:12.681000             🧑  作者: Mango
The woocommerce_continue_shopping_redirect
hook in PHP is used to redirect users back to the previous page after they click on "continue shopping" in the cart.
To use this hook, first, we need to create a function that returns the URL we want to redirect to. Here's an example:
function my_continue_shopping_redirect() {
return get_permalink(12); // Replace 12 with the ID of the page you want to redirect to.
}
add_filter('woocommerce_continue_shopping_redirect', 'my_continue_shopping_redirect');
This function will redirect users to the page with ID 12 after they click on "continue shopping" in the cart.
The woocommerce_continue_shopping_redirect
hook does not require any parameters.
The woocommerce_continue_shopping_redirect
hook should return a URL string that the user will be redirected to.
function my_continue_shopping_redirect() {
return home_url();
}
add_filter('woocommerce_continue_shopping_redirect', 'my_continue_shopping_redirect');
function my_continue_shopping_redirect() {
return wp_get_referer() ? wp_get_referer() : home_url();
}
add_filter('woocommerce_continue_shopping_redirect', 'my_continue_shopping_redirect');
The woocommerce_continue_shopping_redirect
hook in PHP is very useful for redirecting users back to the previous page after they click on "continue shopping" in the cart. With this hook, we can easily customize where users will be redirected to.