Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress 仅当用户选择多个产品时才查看购物车页面_Wordpress_Woocommerce - Fatal编程技术网

Wordpress 仅当用户选择多个产品时才查看购物车页面

Wordpress 仅当用户选择多个产品时才查看购物车页面,wordpress,woocommerce,Wordpress,Woocommerce,我只想在用户选择多个产品时查看购物车页面,否则我想直接将其重定向到结帐页面。 <?php // Add this code in header file. if(is_cart()){ global $woocommerce; $total = $woocommerce->cart->cart_contents_count; if($total<=1){ ?> <script&g

我只想在用户选择多个产品时查看购物车页面,否则我想直接将其重定向到结帐页面。


<?php

// Add this code in header file.

if(is_cart()){        
    global $woocommerce;
    $total = $woocommerce->cart->cart_contents_count;
    if($total<=1){         
      ?>
    <script>window.location="<?php echo esc_url(home_url('checkout'));?>";</script>
    <?php
    }
}
// Note: if You are selected 1 product 3 times the above code is not working.
?>
window.location=“”;