简体   繁体   中英

woocommerce cart quantity not showing correctly on cart page

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.

Ex: add 2 product x price is 400 so: 2 items x 400 subtotal 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.

Any body can help me??

Thanks in advance...

      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

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:

/*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!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM