【问题标题】:woocommerce cart quantity not showing correctly on cart pagewoocommerce 购物车数量未在购物车页面上正确显示
【发布时间】:2016-03-30 14:51:59
【问题描述】:

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

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

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

任何机构都可以帮助我吗??

提前谢谢...

【问题讨论】:

  • 显示购物车页面有一件商品,这件商品单价是400,但是你选择了两个数量,小计是800。

标签: php ajax wordpress woocommerce


【解决方案1】:
      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' );

试试这个,看看结果,请清除您的查询

【讨论】:

    【解决方案2】:

    感谢您的回复,我自己发现了错误。我试图避免变量产品的负值,所以我将 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;
    }*/
    

    因此,在我的购物车页面中,始终将数量值重置为 1。删除此过滤器后,一切正常!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-05
      • 1970-01-01
      • 2012-10-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多