Reputation: 4980
I have only simple products that I want to show total weight of cart in the header section after the "My Cart" link.
Could anybody help me to resolve this issue?
Upvotes: 0
Views: 10662
Reputation: 25996
This should work:
$items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
$weight = 0;
foreach($items as $item) {
$weight += ($item->getWeight() * $item->getQty()) ;
}
echo $weight;
A better way:
$weight = Mage::getSingleton('checkout/session')
->getQuote()
->getShippingAddress()
->getWeight();
Upvotes: 11
Reputation: 31
I added this to the minicart.phtml just under Total price,
<span class="label"><?php echo $this->__('Weight')?>: </span>
<?php echo $_quote = Mage::getSingleton('checkout/session')->getQuote(); echo $_weight = $_quote->getShippingAddress()->getWeight();?>
Thanks for the post here!
Upvotes: 0
Reputation: 17656
Try
$quote = Mage::getSingleton('checkout/session')->getQuote();
$weight = $quote->getShippingAddress()->getWeight();
Upvotes: 8