0
votes

We would like to give free-shipping on cart total $90 and over: If the total cart value goes below $90 after discount is applied, the free-shipping is not applicable and the flat-rate shipping of $7.95 should apply.

I am implementing custom API's for magento, this is reflecting once page got refreshed in magento user account. But the API(mycart.php) was showing the old results(showing 'flatrate' instead of 'free_shipping' above $90 )

I am applying shipping in cart level.

my sample code:

$quote = $this->_getQuote($cart_id, $store);

        try {
            if($sub_total >= 90){               
                $shipping_code = "freeshipping_freeshipping";               
                //$quote->getShippingAddress()->setFreeShipping(1);
                //$quote->save();
            }
            else {
                $shipping_code = "flatrate_flatrate";               
            }   

            if ($quote->getShippingAddress()->getCountryId() == '') {               
                $quote->getShippingAddress()->setCountryId($this->_country);
            }                   

            $address = $quote->getShippingAddress();

            $address->setShippingMethod($shipping_code)->setCollectShippingRates(true);
            $address->save();
2

2 Answers

0
votes
Disable To set up flat rate shipping navigate to 
System -> Configuration and click on Shipping Methods 
in the left column. 

enter image description here

0
votes

I have fixed the problem using the following snippets:

$quote->collectTotals();    
$quote->save();