【问题标题】:Woocommerce redirect to checkout pageWoocommerce 重定向到结帐页面
【发布时间】:2017-06-07 15:14:46
【问题描述】:

我在检查购物车中的商品总数后尝试重定向到结帐页面。如果 product 等于 6,它应该尝试重定向到结帐页面。 我尝试了以下代码,但无法运行或需要一些 curl。

function redirectcheck($url){
$tots = WC()->cart->cart_contents_count();

if($tots > 2){
header("Location: http://somepage.php", 
 true, 301);
 exit();
}
}

【问题讨论】:

    标签: php wordpress woocommerce


    【解决方案1】:

    也许这是一个好的开始......

    function check_quantity( $total, $cart ) {
        if( $cart->cart_contents_count = 6 ) {
                $url = get_permalink( get_option( 'woocommerce_checkout_page_id' ) );
        }
        return $url;
    }
    add_filter( 'woocommerce_calculated_total', 'check_quantity', 10, 2 );
    

    【讨论】:

      猜你喜欢
      • 2016-10-10
      • 1970-01-01
      • 2011-12-27
      • 2022-09-29
      • 1970-01-01
      • 2015-01-17
      • 2016-07-29
      • 2016-09-29
      • 1970-01-01
      相关资源
      最近更新 更多