1

It's always a good approach to show any result (negative or positive) to the user.

In my case, when I click on the 'Get quotes' button on My Cart page and rates are available — it's OK.

But when there is NO rates available for that address, I need to show to customer something like 'Hey, no rates dude'.

As far as I understand, I need to dig in the estimatePostAction method and check the rates manually and set some flash-message.

But I'm just wondering about is there another Magento-way to have this approach?

Thanks for any suggestion or vision.

2 Answers 2

2

Well, finally I resolved this problem.

But I used not the CartController due to this issue, but the observer sales_quote_collect_totals_after.

1

I just use something similar to:

<?php $_shippingRateGroups = $this->getShippingRates(); ?>
<?php if (!$_shippingRateGroups): ?>
    <p><?php echo $this->__('Sorry, no shipping quotes are available to this address. Please contact us at ' . Mage::getStoreConfig('general/store_information/phone') . ' for a shipping quote') ?></p>
<?php else: ?>
    ...success message...

and our getshippingrates function looks something like this:

 public function getShippingRates()
{
    if (empty($this->_rates)) {
        $this->getAddress()->collectShippingRates()->save();
        $groups = $this->getAddress()->getGroupedAllShippingRates();
        /**
        * If no shipping rate is found an error report will be logged containing product and customer information.
        */
        if (empty($groups)) {
            $this->noShipRateError();
        }
        return $this->_rates = $groups;
    }
    return $this->_rates;
}
3
  • Thanks, but is that applicable to My Cart page? Commented Jan 12, 2015 at 17:27
  • 1
    Ah, my mistake. I thought you were talking about shipping quotes from the checkout page. Either way you could create a simple boolean that will check the saved quote after the request is made and then echo a <div> onto the page based upon results. Commented Jan 12, 2015 at 18:04
  • hmm, good point. Let me try this case. I'll let you know. Commented Jan 12, 2015 at 18:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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