Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I save tablerate_bestway shipping method in Magento order saving?

Tags:

magento

While saving order programmatically, I am passing table (tablerate_bestway), but it is giving error

'Please specify a shipping method.'

My code to save shipping method

$shippingAddress->setCollectShippingRates(true)
                    ->setShouldIgnoreValidation(true)
                    ->setShippingMethod("tablerate_bestway")
                    ->collectShippingRates();

However, if I pass flatrate_flatrate, it works. How to save tablerate_bestway?

Both, flat_rate and tablerate_bestway enable in Admin.

like image 404
Elisa Avatar asked Jan 22 '26 06:01

Elisa


1 Answers

Solution sample is:

$shippingAddress->removeAllShippingRates()
            ->setCollectShippingRates(true)
            ->setShippingMethod('tablerate_bestway')
            ->setShippingDescription('Table Rate - Best Way');

Add Shipping Description and do not collect shipping charge.

like image 164
Elisa Avatar answered Jan 25 '26 06:01

Elisa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!