I'm creating an order programmatically with code I wrote a while ago which functions correctly, when using the free shipping method (i.e freeshipping_freeshipping)

However, I'm now trying to place the order using a shipping method (which is from a module by WebShopApps).


Where $delivery is the shipping method code. When I place the order, I get given an error

a:5:{i:0;s:33:"Please specify a shipping method.";i:1;s:1554:"#0 /chroot/home/site/site/html/app/code/core/Mage/Sales/Model/Service/Quote.php(303): Mage::throwException('Please specify ...')

When navigating to this file (Quote.php) on line 303:

protected function _validate()
    if (!$this->getQuote()->isVirtual()) {
        $address = $this->getQuote()->getShippingAddress();
        $addressValidation = $address->validate();
        if ($addressValidation !== true) {
                Mage::helper('sales')->__('Please check shipping address information. %s', implode(' ', $addressValidation))
        $method= $address->getShippingMethod();
        $rate  = $address->getShippingRateByCode($method);
        if (!$this->getQuote()->isVirtual() && (!$method || !$rate)) {
            Mage::throwException(Mage::helper('sales')->__('Please specify a shipping method.')); //this is line 303

To try and solve this, I went the route of creating an order via Adminhtml, and modifying Quote.php for testing purposes, to:

echo ($method . " and " . $rate);die();

I'm then given a blank page with the method Magento is expecting as well as the rate (which is blank), yet the order still gets created fine. The method Magento prints out is also the exact same value that my $delivery variable had set.

What am I doing wrong?

  • 1
    Please check free shipping is enable in admin – Amit Bera Feb 10 '14 at 11:32
  • Free shipping is enabled – Moose Feb 10 '14 at 11:33
  • Did you try setting the shipping method before calling collectShippingRates()? – David Manners Mar 29 '14 at 10:02

You should add $quote->getShippingAddress()->collectTotals(); before your above code. It will work :

/* Important*/
 $quote->getShippingAddress()->collectTotals();// if not will show Please specify shipping methods.
 /* Important*/

| improve this answer | |
  • 2
    tried too. the rate not calculated so rate always return false/empty. Magento 1.9.x – Osify Jul 27 '16 at 10:49
$shipping_method = "flatrate_flatrate";


Above worked for me.

| improve this answer | |
  • adding your solution into sales_quote_collect_totals_before gives me Fatal error: Maximum function nesting level of '500' reached, aborting! – rbncha Mar 27 '15 at 17:23
  • 2
    tried, not work... setCollectShippingRates the rate not calculated so rate always return false/empty. Magento 1.9.x – Osify Jul 27 '16 at 10:49

This seems completely unrelated to the WebShopApps carrier itself, it seems that there are no shipping rates returned from for your request.

Can you investigate whether your shippingAddress and quote object are correctly populated when you are programatically creating them? I suggest testing with another Magento in built carrier such as Tablerates, as the free_shipping carrier does not use any fields on the request to return shipping rates.

| improve this answer | |

for each quote item:


then you can set freeshipping method to your quote

| improve this answer | |

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.