WooCommerce-将总商品计入购物车-而不是数量 [英] WooCommerce - Getting total products count in the cart - not their quantity

查看:37
本文介绍了WooCommerce-将总商品计入购物车-而不是数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有购物车总数,但是我需要购物车中可用产品的数量。我不想显示总数量,但想显示购物车中的总产品/订单。

I have total cart quantity but I need count of products available in the cart. I donot want to show total quantity but want to show total products/orders in the cart.

请帮助!

推荐答案

我在客户端项目@ jivith.com

但是我解决了...

用在微型购物车/购物车功能中替换购物车中的总产品数量-而不是数量项目

Use in minicart / cart function replace total products count in the cart - not their quantity items

$_cartQty = count( WC()->cart->get_cart() );
**or** use sizeof (WC()->cart->get_cart());

我得到购物车中唯一商品的总数,而不是数量的商品...

i getting the total unique total products count in the cart instead of item of their quantity...

我的演示代码:

<span class="cart-items"><?php echo ($minicart_type == 'minicart-inline')
                        ? '<span class="mobile-hide">' . sprintf( _n( '%d item', '%d items', $_cartQty, 'porto' ), $_cartQty ) . '</span><span class="mobile-show">' . $_cartQty . '</span>'
                        : (($_cartQty > 0) ? $_cartQty : '0'); ?></span>

这篇关于WooCommerce-将总商品计入购物车-而不是数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆