woocommerce cart quantity not showing correctly on cart page

时间:2020-12-31 07:22:53

When I add items to cart, it refreshes the quantity correctly in mini-cart widget, but when I go to cart page it always shows 1 item yet the subtotal is calculated correctly.

当我将商品添加到购物车时,它会在迷你购物车小部件中正确刷新数量,但是当我转到购物车页面时,它总是显示1个商品,但小计的计算正确。

Ex: add 2 product x price is 400 so: 2 items x 400 subtotal 800

例:添加2个产品x价格为400所以:2个项目x 400个小计800个

but in the cart page it shows 1 item x 400 subtotal 800. I add product to cart using the standard ajax call of woocommerce.

但在购物车页面中显示1项x 400小计800.我使用woocommerce的标准ajax调用将产品添加到购物车。

Any body can help me??

任何人都可以帮助我?

Thanks in advance...

提前致谢...

2 个解决方案

#1


0  

      function my_theme_wrapper_start()
          {
                  echo the_breadcrumb();
                  echo '<section role="main"><div class="wrap">';
           }

         function my_theme_wrapper_end()
         {
        echo '</div></section>';
          }

        function mytheme_prepare_woocommerce_wrappers()
       {
    remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
    remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);

    add_action( 'woocommerce_before_main_content', 'my_theme_wrapper_start', 10     );
    add_action( 'woocommerce_after_main_content', 'my_theme_wrapper_end', 10 );
          }
  add_action( 'wp_head', 'mytheme_prepare_woocommerce_wrappers' );

   add_theme_support( 'woocommerce' );

tyry this and see the result and please clear your query

tyry这个并看到结果,请清除您的查询

#2


0  

Thanx for your reply, i find the error by my self. I was trying to avoid negatives values on varibale products so i put the followng filter in the theme function.php:

谢谢你的回复,我发现自己的错误。我试图避免在varibale产品上使用负值,所以我将followng过滤器放在主题function.php中:

/*add_filter('woocommerce_quantity_input_args', 'default_quantity_values');
function default_quantity_values( $default ){
    $default = array(
        'input_name'    => 'quantity',
        'input_value'   => '1',
        'max_value'     => '1000',
        'min_value'     => '1',
        'step'          => '1',
    );
    return $default;
}*/

As result, in my cart page, always reset the quantity value to one. Once i remove this filter, every thing work ok!!

因此,在我的购物车页面中,始终将数量值重置为1。一旦我删除这个过滤器,每件事都可以正常工作!!

#1


0  

      function my_theme_wrapper_start()
          {
                  echo the_breadcrumb();
                  echo '<section role="main"><div class="wrap">';
           }

         function my_theme_wrapper_end()
         {
        echo '</div></section>';
          }

        function mytheme_prepare_woocommerce_wrappers()
       {
    remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
    remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);

    add_action( 'woocommerce_before_main_content', 'my_theme_wrapper_start', 10     );
    add_action( 'woocommerce_after_main_content', 'my_theme_wrapper_end', 10 );
          }
  add_action( 'wp_head', 'mytheme_prepare_woocommerce_wrappers' );

   add_theme_support( 'woocommerce' );

tyry this and see the result and please clear your query

tyry这个并看到结果,请清除您的查询

#2


0  

Thanx for your reply, i find the error by my self. I was trying to avoid negatives values on varibale products so i put the followng filter in the theme function.php:

谢谢你的回复,我发现自己的错误。我试图避免在varibale产品上使用负值,所以我将followng过滤器放在主题function.php中:

/*add_filter('woocommerce_quantity_input_args', 'default_quantity_values');
function default_quantity_values( $default ){
    $default = array(
        'input_name'    => 'quantity',
        'input_value'   => '1',
        'max_value'     => '1000',
        'min_value'     => '1',
        'step'          => '1',
    );
    return $default;
}*/

As result, in my cart page, always reset the quantity value to one. Once i remove this filter, every thing work ok!!

因此,在我的购物车页面中,始终将数量值重置为1。一旦我删除这个过滤器,每件事都可以正常工作!!