【发布时间】:2015-05-27 13:23:08
【问题描述】:
我有一个自定义 html,我想将此 html 实现到结帐购物车页面中。我已经实现了它,但我无法获得购物车项目的总价,例如。我在购物车中有 5 件商品。我只更新了购物车中的一件特定商品,然后我没有得到这些特定商品的总价。
默认项目 $50 *1 =$50
更新后数量
项目价格:50 美元 * 2 = ??(我想得到这个特定项目的总价)。
谢谢
【问题讨论】:
我有一个自定义 html,我想将此 html 实现到结帐购物车页面中。我已经实现了它,但我无法获得购物车项目的总价,例如。我在购物车中有 5 件商品。我只更新了购物车中的一件特定商品,然后我没有得到这些特定商品的总价。
默认项目 $50 *1 =$50
更新后数量
项目价格:50 美元 * 2 = ??(我想得到这个特定项目的总价)。
谢谢
【问题讨论】:
你可以这样计算价格:
<?php
$items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
foreach($items as $item) {
$qty = $item->getQty();
$price = $item->getPrice();
$totalPrice = $qty * $price;
}
?>
【讨论】:
要获取购物车项目的具体详细信息,您可以使用:
$quote = Mage::getSingleton('checkout/session')->getQuote();
foreach ($quote->getAllItems() as $item){
$qty = $item->getQty() ;
$price = $item->getPrice();
$totalPrice = $qty * $price;
}
【讨论】:
我正在使用默认的 magento 功能在 magento 结账购物车页面中获取特定商品的价格
<?php if ($canApplyMsrp): ?>
<span class="cart-msrp-subtotal">--</span>
<?php else: ?>
<?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?>
<?php echo $this->helper('checkout')->formatPrice($_item->getRowTotal() + $_item->getWeeeTaxAppliedRowAmount() + $_item->getWeeeTaxRowDisposition()); ?>
<?php else: ?>
<?php echo $this->helper('checkout')->formatPrice($_item->getRowTotal()) ?>
<?php endif; ?>
<?php endif; ?>
【讨论】: