Magento custom shipping rate

The question:

Guys i need an advice on how can i achieve this shipping rule

1) Shipping cost should be at a minimum of US$25.00 or 10% of the total purchase.

Example 1:

Total Purchase = $25
Shipping cost = $25
Total = $50

Example 2:

Total Purchase = $500
Shipping cost = $50
Total purchase = $550.00


The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

You can create a new shipping module following this tutorial or this one.
Then the collectRates() method (the one responsible for calculating the shipping price) can look something like this:

public function collectRates(Mage_Shipping_Model_Rate_Request $request){
    // skip if not enabled
    if (!Mage::getStoreConfig('carriers/'.$this->_code.'/active')) {
        return false;
    //create a result object
    $result = Mage::getModel('shipping/rate_result');
    $percentage = 10;
    $minimum = 25;
    $packageValue = $request->getPackageValue();//the cost of the products
    $price = ($pachageValue * $percentage) / 100; //calculate 10% of the product cost
    if ($price < $minimum){//if 10% is less than 25
        $price = $minimum;
    //create new shipping method instance
    $method = Mage::getModel('shipping/rate_result_method');
    //set the price for the method instance
    //add the price to results
    return $result;

For best practice, add the minimum amount (25) and the percentage value (10) to your module configuration so you will be able to change it whenever you want.

Method 2

For set shipping cost you need to create .CSV file. let try this will help you.

Method 3

Tables Rate Method can be used by uploading CSV for different rates and area is a good solution.

Admin: System->Configuration->Sales->Shipping Method

Check the Link for using Tables Rate Method

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment