I'm trying to place an order programmatically with tablerates. Here is my code
$quote->getShippingAddress()->addData($postData['shipping_address']);
$quote->getBillingAddress()->addData($postData['billing_address']);
/** @var \Magento\Quote\Model\Quote\Address $shippingAddress */
$shippingAddress= $quote->getShippingAddress();
$shippingAddress
->removeAllShippingRates()
->setCollectShippingRates(true)
->collectShippingRates()
->setShippingMethod('tablerate_bestway') //shipping method
->setShippingDescription('Table Rate - Best Way');
$this->handlePayment('banktransfer');
$quote->setPayment($this->payment);
$quote->setCheckoutMethod(QuoteManagement::METHOD_GUEST);
$quote->save();
$quote->collectTotals();
$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?