I'm trying to caltulate the total wight of products in cart and here is my code:
//If we have no weight, try to calculate this
$weight = 0;
if ($quote->getShippingAddress()->getWeight() == null ||
$quote->getShippingAddress()->getWeight() == 0 ||
$quote->getShippingAddress()->getWeight() == ''){
foreach ($quote->getAllItems() as $item){
$itemWeight = $item->getWeight();
if ($itemWeight != null){
$weight += $itemWeight;
}
Now the problem is I have free/bonus products in the cart and this free product has weight. The above code just add the weight of the free product as well. I want to know is there a way I can exclude the weight of the free product in my cart. Or how can I filter the free/bonus products on magento using the Singleton.