0
A
回答
11
這應該工作:
$items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
$weight = 0;
foreach($items as $item) {
$weight += ($item->getWeight() * $item->getQty()) ;
}
echo $weight;
一個更好的辦法:
$weight = Mage::getSingleton('checkout/session')
->getQuote()
->getShippingAddress()
->getWeight();
8
嘗試
$quote = Mage::getSingleton('checkout/session')->getQuote();
$weight = $quote->getShippingAddress()->getWeight();
+2
這應該是被接受的答案。 – Eric
+0
即使沒有shipping_address也可以使用 –
0
我已將此添加到minicart.phtml不到總價格,
<span class="label"><?php echo $this->__('Weight')?>: </span>
<?php echo $_quote = Mage::getSingleton('checkout/session')->getQuote(); echo $_weight = $_quote->getShippingAddress()->getWeight();?>
感謝這裏的帖子!
相關問題
- 1. Woocommerce購物車顯示重複購物車總計
- 2. 如何在magento上顯示購物車側邊欄或購物車擡頭上的總重量
- 3. 購物車中顯示總金額
- 4. 保存訂單之前更新Mgento購物車總額
- 5. 如何在「購物車」標籤上顯示添加到購物車的數量
- 6. Kentico中的購物車總價問題
- 7. Magento購物主題多「購物車」的車頭標題
- 8. AJAX - 購物車Magento總計和購物車中的物品
- 9. PHP購物車顯示問題
- 10. 如何在OpenCart 2.0結帳購物車中顯示總重量和體積?
- 11. SimpleCart JS購物車顯示
- 12. Magento:添加到購物車顯示空的購物車
- 13. codeigniter購物車:多個商店的顯示購物車
- 14. 在virtmartmart joomla 2.5上顯示購物車中的物品數量?
- 15. 顯示WooCommerce迷你購物車中物品的數量
- 16. 使用minicart.js顯示購物車中的物品數量
- 17. 購物車問題,表中錯誤顯示的物品
- 18. Magento購物車不顯示產品,但確實顯示總價
- 19. Virtuemart 2.0.20顯示購物車並未重定向到購物車頁
- 20. Shopify購物車 - 顯示項基於標題
- 21. 在表中顯示購物車
- 22. 在Rails中顯示購物車總額,Rails方式
- 23. 在模板中顯示購物車總計
- 24. 如何在Prestashop中顯示購物車總數1.6
- 25. 購物車問題
- 26. 購物車問題
- 27. 添加到購物車顯示「您的購物車中沒有產品」?
- 28. 如何從購物車的Prestashop獲得總重量
- 29. 如何將總購物車重量添加到opencart的發票?
- 30. Woocommerce購物車提示多次顯示
謝謝@chapagain,我會試着讓你知道結果。 –
如果您將多個相同的產品放入購物車,則上面給我的代碼不起作用。它始終顯示一種產品重量,而不是乘以產品數量。我該如何解決這個問題? –
編輯答案。現在它應該適用於單個產品的多個數量。如果這確實起作用,請回復。 –