I want to get the number of "shippable" products in the quote/basket on the template file checkout/onepage/shipping_method/available.phtml. The aim is to tell the customer at that point how many more products they would need to buy to qualify for free shipping.

When building shipping method modules, you can get this with $request->getPackageQty();

For example, if you have 3 books, 2 T-shirts and 1 virtual product in your basket, getPackageQty will return 5, not 6.

On checkout/onepage/shipping_method/available.phtml, I've tried the following:

$quote = $this->getQuote();
$quote = Mage::getSingleton('checkout/session')->getQuote();

$packageQty = $quote->getPackageQty();

Neither is working. I'm working a bit blind here, can anyone help me out?



I looked at http://docs.magentocommerce.com/Mage_Sales/Mage_Sales_Model_Quote.html

Turns out you can do:

$packageQty = $quote->getItemsSummaryQty() - $quote->getItemVirtualQty();

This is the total number of items in the quote, minus the number of unshippable/virtual items, which is a roundabout way of getting what I want.

(will accept answer when I can, in 2 days)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.