6

I am trying to get the shipping price from the quote on the cart page for the entire order.

I have tried multiple things including:

Mage::getModel("checkout/session")->getQuote()->getShippingMethod()->getPrice();


$rates = Mage::getModel("checkout/session")->getQuote()->getShippingAddress()->getAllShippingRates();
foreach($rates as $rate){
    $rate->getPrice();
}

What can I do to get the shipping price in the Magento cart?

14

This will do the trick. From your question, I assume that the customer has already selected their desired shipping method.

<?php

$quote = Mage::getModel("checkout/session")->getQuote();
$amount = $quote->getShippingAddress()->getShippingAmount();

In fact, there are a number of methods available to you. Such as:

<?php 

$address = $quote->getShippingAddress();
$address->getBaseShippingAmount();
$address->getBaseShippingDiscountAmount();
$address->getBaseShippingHiddenTaxAmount();
$address->getBaseShippingInclTax();
$address->getBaseShippingTaxAmount();

$address->getShippingAmount();
$address->getShippingDiscountAmount();
$address->getShippingHiddenTaxAmount();
$address->getShippingInclTax();
$address->getShippingTaxAmount();

If you simply want to get all available shipping rates into an array:

<?php

$address = $quote->getShippingAddress();

$shippingPrices = array();
foreach($address->getAllShippingRates() as $rate){
    $shippingPrices[$rate->getCode()] = $rate->getPrice();
}
var_dump($shippingPrices);
  • 1
    My pleasure and good luck to you in your endeavors! – Shawn Abramson Aug 18 '16 at 17:48

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.