本文介绍了禁用添加到购物车重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
现在,点击存档页面上的添加到图表按钮会将产品添加到购物车,但也会将定制器重定向到某些产品的页面,因此我试图在点击添加到购物车后禁用任何重定向按钮。我希望customer停留在他按下按钮之前所在的页面,或者只是添加到购物车后才刷新页面。
Now, hitting the "add to chart" button on the archive page will add product to cart, but will also redirect custommer to the page of certain product, and I am trying to disable any redirection after hitting "add to cart" button. I want custommer to stays at the same page where he has been before hitting the button, or just to "refresh" page after adding to cart.
有什么建议吗?
/**
* Redirect subscription add to cart to checkout page
*
* @param none
*/
function add_to_cart_checkout_redirect() {
wp_safe_redirect( get_permalink( get_option(
'woocommerce_checkout_page_id' ) ) );
die();
}
add_action( 'woocommerce_add_to_cart', 'add_to_cart_checkout_redirect', 11
);
推荐答案
这就是答案。如果您想要自定义重定向,则可以使用以下过滤器:
Here is the answer. If you want custom redirection, there is a filter for that:
add_filter( 'woocommerce_add_to_cart_redirect', 'custom_redirect_function' );
function custom_redirect_function() {
return get_permalink( wc_get_page_id( 'shop' ) );
}
这篇关于禁用添加到购物车重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!