如何使用 SHOPP PLUGIN 了解 WordPress 购物车中添加到购物车的商品数量

发布于 2024-09-30 07:16:55 字数 85 浏览 0 评论 0原文

我正在使用 Shopp 插件使用 WordPress 制作购物车。

我如何知道此处添加到购物车的商品数量。任何代码。 任何人都可以帮助我吗?

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

抚笙 2024-10-07 07:16:55

我添加了一个代码来计算购物车中的商品数量并输出它们。

希望有帮助!

<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>

I added a code to count the number of items in cart and output them.

Hope it helps!

<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>
或十年 2024-10-07 07:16:55

我想这就是你想要的吗?

<?php shopp('cart','totalitems'); ?>

以下是相关文档: Cart_Tags#totalitems

更新:这些文档现已向公众开放,已更新。这是相同功能的新链接。请注意可用的“替代形式”:shopp('cart','total-items')

I think this does what you want?

<?php shopp('cart','totalitems'); ?>

Here are the docs on it: Cart_Tags#totalitems

UPDATED: The docs are now open to the public and updated. Here is a new link for the same function. Note the 'alternative forms' available: shopp('cart','total-items')

故人爱我别走 2024-10-07 07:16:55

这部分在Shopp中一直有点令人困惑。

如果您需要购物车中应使用的独特商品数量

shopp('cart','totalitems','options...');

(例如:5 个苹果、3 个梨、2 个胡萝卜,则结果为 3)

如果您需要购物车中应使用的商品数量

shopp('cart','total-quantity','options...');

(例如:2 个苹果、 3 个梨、1 个胡萝卜将导致 6)

要使用变量中的值,请将选项设置为 'return=true'

This part has always been a little confusing in Shopp.

If you need the number of unique items in the cart you should use

shopp('cart','totalitems','options...');

(for example: 5 apples, 3 pears, 2 carrots would result in 3)

If you need the number of items in the cart you should use

shopp('cart','total-quantity','options...');

(for example: 2 apples, 3 pears, 1 carrot would result in 6)

To use the value in a variable, set options to 'return=true'

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文