1

Is there any way to remove shipping method from quote, programmatically.

I have try this code

Mage::getSingleton('checkout/session')->getQuote()->unsShippingAddress();

but not working.

And this code is remove only from the session. How can i remove from the quote table.

3

Try this code:

$shippingAddress->setShippingMethod('');

// Set the payment method
$shippingAddress->setPaymentMethod($paymentMethod);

// Set the payment method
$quote->getPayment()->importData(array('method' => $paymentMethod));

// Collect the prices
$quote->collectTotals()->save();
0

you can do this

<?php $shippingaddress = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress(); ?>
<?php $shippingaddress->setShippingMethod(''); ?>
<?php $shippingaddress->save(); ?>

but magento will throw an error saying select shipping method.you need to set something

  • not working. :( – MeenakshiSundaram R May 30 '14 at 11:40
  • for me its working.i had tested my code now. – Pradeep Sanku May 30 '14 at 11:49
  • its clear form the session. But still in quote table. How can i remove that, without remove the product from cart. – MeenakshiSundaram R May 30 '14 at 12:08
0

If all you want is to remove current contents of shipping address. You can try this (which worked for me)

     $shippingaddress = Mage::getSingleton('checkout/session')->getQuote()
->getShippingAddress()->unsetData();
0
$shippingaddresss = $quote->getShippingAddress();
$shippingaddresss->setShippingMethod(null);
//$shippingaddresss->setShippingMethod('');
$shippingaddresss->save();

Set ShippingMethod null or empty string, both does same thing. but i recommend you to use null. Hope it will works. if not please share your code. Thanks

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.