0

I am setting Shipping Method to quote, For one particular method, shipping price is not added to quote but for other shipping methods it is working fine. Can anyone suggest on this, I have used below code,

// Collect Rates and Set Shipping & Payment Method
                $quote->getShippingAddress()->setCollectShippingRates(true)->collectShippingRates();
                $quote->getShippingAddress()->setShippingMethod($postParams['shipping_method']);


                $quote->getShippingAddress()->setPaymentMethod($postParams['payment_method']);


                //Set Sales Order Payment
                $quote->getPayment()->importData(array('method' => $postParams['payment_method']));


                // Collect Totals & Save Quote
               $quote->collectTotals()->save();
0

Finally, I got it fixed by using below code,

 $quote->getShippingAddress()->setCollectShippingRates(true)->collectShippingRates();

// Updated Line
                    $quote->getShippingAddress()->setShippingMethod($postParams['shipping_method'])->setCollectShippingRates(true);
// Updated Line

                    $quote->getShippingAddress()->setPaymentMethod($postParams['payment_method']);


                    //Set Sales Order Payment
                    $quote->getPayment()->importData(array('method' => $postParams['payment_method']));


                    // Collect Totals & Save Quote
                    $quote->collectTotals()->save();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy