购物车行数 [英] Shopping Cart Row Count

查看:61
本文介绍了购物车行数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Codeigniter进行项目。

I am using Codeigniter for a project.

这是我的购物车外观

不。 1 | Appple |数量-2

No.1|Appple |Qty -2

第2 |橙色|数量-3

No.2|Orange |Qty -3

第3 |橙色|数量-3

No.3|Orange |Qty -3

通常,如果我使用 $ this-> cart-> total_items(); 。我将得到2 + 3 + 3 =8。
但是,我只想要rowcount(请参阅三行)。我想显示 3。是否有类似'$ this-> cart-> rowcount()'的东西?

Normally if I use "$this->cart->total_items();" . I will get 2+3+3 = 8. However , I only want rowcount(see there are three row) . I want to show '3' . Is there any thing like '$this->cart->rowcount()' ?

推荐答案

我只是在这里猜测(因为我不在可以测试的地方),但是您可以尝试:

I'm just guessing here (as I'm not somewhere where I can test this), but you might try:

$rows = count($this->cart->contents());

我假设返回的数组具有每个带有数量值的项目类型的数组。

I'm assuming that the array that's returned has an array of each item type with a quantity value.

这篇关于购物车行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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