1

I have two shipping method enabled Free Shipping and Flat Rate

I would like to show Free Shipping is the only option if total order amount is greater than 100

And show Flat Rate as only option if total order amount is less than 100.

I created Shopping cart price rule in such a way that

If ALL  of these conditions are TRUE :

Shipping Method  is  [freeshipping] Free 
Subtotal  greater than  100 
Shipping Method  is not  [flatrate] Fixed 
Subtotal  greater than  100 

This way it is working fine if order amount is less than 100. It is not showing Free Shipping option. But when order is greater than 100 it shows both the options.

2

Oddly enough I've only gotten something like this to work by setting the free shipping method to no (disabled).

Then create a shopping cart price rule that grants free shipping when the subtotal is greater than 100.

| improve this answer | |
2

If you do not want to show both the options.

For the free shipping method you will need to set field Minimum Order Amount to 100 in admin.

Admin -> System -> Configuration -> Shipping Methods -> Free Shipping ->  Minimum Order Amount

For the flat rate you will need to rewrite the class

app/code/core/Mage/Shipping/Model/Carrier/Flatrate.php

And function collectRates and you need to change in function as below.

public function collectRates(Mage_Shipping_Model_Rate_Request $request)
    {
        if (!$this->getConfigFlag('active')) {
            return false;
        }

        $freeBoxes = 0;
        if ($request->getAllItems()) {
            foreach ($request->getAllItems() as $item) {

                if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
                    continue;
                }

                if ($item->getHasChildren() && $item->isShipSeparately()) {
                    foreach ($item->getChildren() as $child) {
                        if ($child->getFreeShipping() && !$child->getProduct()->isVirtual()) {
                            $freeBoxes += $item->getQty() * $child->getQty();
                        }
                    }
                } elseif ($item->getFreeShipping()) {
                    $freeBoxes += $item->getQty();
                }
            }
        }
        $this->setFreeBoxes($freeBoxes);

        $result = Mage::getModel('shipping/rate_result');
        if ($this->getConfigData('type') == 'O') { // per order
            $shippingPrice = $this->getConfigData('price');
        } elseif ($this->getConfigData('type') == 'I') { // per item
            $shippingPrice = ($request->getPackageQty() * $this->getConfigData('price')) - ($this->getFreeBoxes() * $this->getConfigData('price'));
        } else {
            $shippingPrice = false;
        }

        $shippingPrice = $this->getFinalPriceWithHandlingFee($shippingPrice);

       if($shippingPrice > 100) {
         return false;
       }

        if ($shippingPrice !== false) {
            $method = Mage::getModel('shipping/rate_result_method');

            $method->setCarrier('flatrate');
            $method->setCarrierTitle($this->getConfigData('title'));

            $method->setMethod('flatrate');
            $method->setMethodTitle($this->getConfigData('name'));

            if ($request->getFreeShipping() === true || $request->getPackageQty() == $this->getFreeBoxes()) {
                $shippingPrice = '0.00';
            }


            $method->setPrice($shippingPrice);
            $method->setCost($shippingPrice);

            $result->append($method);
        }

        return $result;
    }
| improve this answer | |
  • Thanks for your response. Other method is simpler :-) +1 – Butterfly Dec 31 '15 at 7:52
1

You may do it easily by using Table Rate shipping method. There, you just have to create a rule for Price Less than 100 & More than 100. If you wish to give a unique label like "Free Shipping" or "Flat Rate", you may use WebShopApps MatrixRate which is a Free Module.

Here is the sample CSV :

Country,Region/State,Zip/Postal Code,Order Subtotal,Shipping Price
*,*,*,0,10
*,*,*,100,0
| improve this answer | |
0

Enable flat rate shipping and free shipping modify the collectRates function in flatrate.php

file path: app/code/core/Mage/Shipping/Model/Carrier/Flatrate.php

public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
    if (!$this->getConfigFlag('active')) {
        return false;
    }

    $freeBoxes = 0;
    if ($request->getAllItems()) {
        foreach ($request->getAllItems() as $item) {

            if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
                continue;
            }

            if ($item->getHasChildren() && $item->isShipSeparately()) {
                foreach ($item->getChildren() as $child) {
                    if ($child->getFreeShipping() && !$child->getProduct()->isVirtual()) {
                        $freeBoxes += $item->getQty() * $child->getQty();
                    }
                }
            } elseif ($item->getFreeShipping()) {
                $freeBoxes += $item->getQty();
            }
        }
    }
    $this->setFreeBoxes($freeBoxes);

    $result = Mage::getModel('shipping/rate_result');
    if ($this->getConfigData('type') == 'O') { // per order
        $shippingPrice = $this->getConfigData('price');
    } elseif ($this->getConfigData('type') == 'I') { // per item
        $shippingPrice = ($request->getPackageQty() * $this->getConfigData('price')) - ($this->getFreeBoxes() * $this->getConfigData('price'));
    } else {
        $shippingPrice = false;
    }

   $shippingPrice = $this->getFinalPriceWithHandlingFee($shippingPrice);
   $session= Mage::getSingleton('checkout/session');
   $getotal = Mage::helper('checkout')->getQuote()->getGrandTotal();
   $totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals(); //Total object
   $subtotal = $totals["subtotal"]->getValue();
   if($subtotal >100) {
     return false;
   }

    if ($shippingPrice !== false) {
        $method = Mage::getModel('shipping/rate_result_method');

        $method->setCarrier('flatrate');
        $method->setCarrierTitle($this->getConfigData('title'));

        $method->setMethod('flatrate');
        $method->setMethodTitle($this->getConfigData('name'));

        if ($request->getFreeShipping() === true || $request->getPackageQty() == $this->getFreeBoxes()) {
            $shippingPrice = '0.00';
        }


        $method->setPrice($shippingPrice);
        $method->setCost($shippingPrice);

        $result->append($method);
    }

    return $result;
}
| improve this answer | |

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.