0

I am using Magento 1.9.3.2.

I need customization like, Shipping cost should not show in the Cart page, but shown in the Checkout page.

Is possible to make like Shipping cost should be calculated only in checkout page, not in the Cart page even user logged in.

2 Answers 2

0

You can use the following code somewhere when cart loads:

$quote->setTotalsCollectedFlag(false);
$quote->getShippingAddress()->unsetData('cached_items_all');
$quote->getShippingAddress()->unsetData('cached_items_nominal');
$quote->getShippingAddress()->unsetData('cached_items_nonnominal');
$quote->collectTotals();

Hope this helps!

5
  • Thanks for your reply @sukumar. I have added thid code in template/checkout/cart.phtml. But It is not working. May 22, 2018 at 9:20
  • Try to reload the page again. You need to call that code before page renders. May 22, 2018 at 9:22
  • Shall i call in the checkout/cart action? May 22, 2018 at 9:25
  • I used this solution, magento.stackexchange.com/questions/203474/…. It worked in checkout_cart_save_before event. May 22, 2018 at 9:32
  • Great!. You can use both code for unset shipping method. May 22, 2018 at 9:35
0

I Created a event with observer. Here is the Code:

<frontend>
    <events>
        <checkout_cart_save_before>
            <observers>
            <your_module_shipping_observer>
                <type>singleton</type>
                <class>Your_Module/observer</class>
                <method>setFreeShipping</method>
            </your_module_shipping_observer>
            </observers>
        </checkout_cart_save_before>
    </events>
</frontend>

Observer function setFreeShipping Code:

public function setFreeShipping($observer) {
    $event = $observer->getEvent();
    $cart = $event->getCart();
    $shippingaddress = $cart->getQuote()->getShippingAddress();
    $shippingaddress->setShippingMethod('')->save();
    return;
}

Reference and credits: link

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.