I'm doing a shopping cart with wordpress using Shopp Plugin.
How can i know the number of items added to cart here.Any code for this. Can any one please help me.
I'm doing a shopping cart with wordpress using Shopp Plugin.
How can i know the number of items added to cart here.Any code for this. Can any one please help me.
我想这是你想要的吗?
<?php shopp('cart','totalitems'); ?>
这是上面的文档:Cart_Tags#totalitems
更新:文档现在向公众开放并更新。这是相同功能的新链接。注意可用的“替代形式”:shopp('cart','total-items')
我添加了一个代码来计算购物车中的商品数量并输出它们。
希望能帮助到你!
<p class="cartinfo">
<?php if (shopp('cart','hasitems')): ?>
<?php $total_items = 0; ?>
<?php while(shopp('cart','items')): ?>
<?php $total_items = $total_items + 1; ?>
<?php endwhile; ?>
<?php echo $total_items;?> <?php if ($total_items = 1) {echo'Item';} else {echo'Items';} ?> (<?php shopp('cart','subtotal'); ?>)
<?php else: ?>
0 Items in Cart :(
<?php endif; ?>
</p>
这部分在 Shopp 中一直有些混乱。
如果您需要购物车中唯一商品的数量,您应该使用
shopp('cart','totalitems','options...');
(例如:5 个苹果、3 个梨、2 个胡萝卜将产生 3 个)
如果您需要购物车中的商品数量,您应该使用
shopp('cart','total-quantity','options...');
(例如:2 个苹果、3 个梨、1 个胡萝卜将产生 6 个)
要在变量中使用值,请将选项设置为'return=true'