wordpress Woocommerce:从类别添加产品后自动重定向到购物车

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13295766/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 19:05:30  来源:igfitidea点击:

Woocommerce: Auto-redirect to cart after adding product from category

wordpresswoocommerce

提问by user1810236

http://www.passgotutoring.com/shop/product-category/ucla/ucla-14a/

http://www.passgotutoring.com/shop/product-category/ucla/ucla-14a/

I am trying to get a auto redirect towards WP_Cart to happen as soon as a client "adds to cart" one of our classes that are located on the left.

我试图在客户端“添加到购物车”我们位于左侧的类之一时立即自动重定向到 WP_Cart。

Most of my clients buy a product, pay for it right away so I dont need to really have them keep shopping or anything.

我的大多数客户购买产品后立即付款,因此我不需要真正让他们继续购物或其他任何事情。

I have tried inputting this code in to my function.php of my theme with no luck when I wanted them to go to their checkout directly.

当我希望他们直接去结帐时,我尝试将此代码输入到我的主题的 function.php 中,但没有运气。

add_action('init','woocommerce_go_to_checkout_action',30);
function woocommerce_go_to_checkout_action(){
if ( empty( $_REQUEST['add-to-cart'] ) || sizeof($woocommerce->cart->get_cart())==0) )
    return; wp_safe_redirect( $woocommerce->cart->get_checkout_url() );
}

Any ideas on how I could get it to work? 1. I would like it to go to cart instead of checkout. 2. I tried the checkboxmethod on the catalog page and it did not work.

关于如何让它工作的任何想法?1. 我希望它进入购物车而不是结帐。2.我checkbox在目录页上的方法试过了,没用。

回答by Andrew

In WooCommerce 3.xyou'll find this setting under:

在 WooCommerce 中,3.x您会在以下位置找到此设置:

WooCommerce > Settings > Products > General > Add to cart behaviour > [?] Redirect to the cart page after successful addition

WooCommerce > 设置 > 产品 > 常规 > 添加到购物车行为 > [?] 添加成功后重定向到购物车页面



In WooCommerce 2.3you'll find this setting under:

在 WooCommerce 中,2.3您会在以下位置找到此设置:

WooCommerce > Settings > Products > Display > [?] Redirect to the cart page after successful addition

WooCommerce > 设置 > 产品 > 显示 > [?] 添加成功后重定向到购物车页面



In WooCommerce 2.1you'll find this setting under:

在 WooCommerce 中,2.1您会在以下位置找到此设置:

WooCommerce > Settings > Products > [?] Redirect to the cart page after successful addition

WooCommerce > 设置 > 产品 > [?] 添加成功后重定向到购物车页面

回答by Tanin

try to uncheck this..

尝试取消选中这个..

WooCommerce > Settings > General > Scripts > [?] Enable AJAX add to cart buttons on product archives

WooCommerce > 设置 > 常规 > 脚本 > [?] 在产品档案上启用 AJAX 添加到购物车按钮

回答by Box

WooCommerce Settings | Catalog | Catalog options | Add to cart | Please check the "Add to cart Redirect to the cart page after successful addition" option.

WooCommerce 设置 | 目录 | 目录选项 | 加入购物车 | 请勾选“添加到购物车成功添加后重定向到购物车页面”选项。

回答by Oscar Nevarez

In WooCommerce 2.1.8 you′ll find this setting under... WooCommerce Settings | Products | Enable AJAX add to cart buttons on archives

在 WooCommerce 2.1.8 中,您将在以下位置找到此设置... WooCommerce 设置 | 产品 | 在档案上启用 AJAX 添加到购物车按钮

回答by Kashif Rafique

In WooCommerce 2.3.11 you'll find this setting under...

在 WooCommerce 2.3.11 中,您会在以下位置找到此设置...

WooCommerce > Settings > Products > Display > Add to cart behaviour > [?] Redirect to the cart page after successful addition

WooCommerce > 设置 > 产品 > 显示 > 添加到购物车行为 > [?] 添加成功后重定向到购物车页面

Docs

文档

回答by arifktk

Using a filter hook, you can use the following snippet.

使用过滤器钩子,您可以使用以下代码段。

add_filter('woocommerce_add_to_cart_redirect', 'change_woocommerce_add_to_cart_redirect_url');
function change_woocommerce_add_to_cart_redirect_url($url){
    $url = wc_get_cart_url();
    return $url;
}

The code goes into your child theme or active theme's functions.php file. Tested and working.

代码进入您的子主题或活动主题的functions.php 文件。测试和工作。