I'm trying to place an order programmatically with tablerates. Here is my code


        /** @var \Magento\Quote\Model\Quote\Address $shippingAddress */
        $shippingAddress= $quote->getShippingAddress();
            ->setShippingMethod('tablerate_bestway') //shipping method
            ->setShippingDescription('Table Rate - Best Way');


        $orderId = $this->cartManagement->placeOrder($quote->getId());
        $order = $this->orderResource->load($this->order, $orderId);

I'm constantly getting Please specify a shipping method. Regardless what I try. In QuoteValidator it tries to get the rate $rate = $quote->getShippingAddress()->getShippingRateByCode($method); which always returns false. tablerates is setup

how can I place this order with tablerates?

3 Answers 3


Follow-up on @xhallix's answer: If you use weight-based Table Rate shipping, the shipping rate collection requires the shipping address have a defined free_method_weight. This value is calculated during quote total collection, but not saved persistently. (There's no such column on quote_address.)

In other words:

If you're hitting Please specify a shipping method when you know you TableRates should work, it's probably because you need to calculate totals first.

Make sure you run $quote->collectTotals() before $shippingAddress->collectShippingRates().


For those who have the same problem. If tablerates are configured as weight -> destination a free_method_weight needs to be set to the shipping address, in order to collect the correct rates


Please see my solution here: https://magento.stackexchange.com/a/320495/15474

You need to use this model \Magento\Quote\Model\Quote\Address\Rate

Your Answer

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

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