0

I want to apply the following shipping rules in the magento:

1-5kg - £5.95
6-10kg - £7.95
11-100kg + £0.21p per kilo on top of the £7.95 price.

I am facing problem with applying 0.21p per kilo in the last rule. Please advise if this is possible in magento or if any 3rd party extension can do this?

1 Answer 1

3

You can create your own shipping method.
Here is a nice tutorial.

What you need to change is the collectRates method.
That's the one that calculates the prices.

It could 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;
    }
    $weight = $request->getPackageWeight();
    //if weight is above 100 method is not aplicable
    if ($weight > 100) {
         return false;
    }
    /* @var Mage_Shipping_Model_Rate_Result $result */
    $result = Mage::getModel('shipping/rate_result');
    /* @var Mage_Shipping_Model_Rate_Result_Method $method */
    $method = Mage::getModel('shipping/rate_result_method');

    $method->setCarrier($this->_code);
    $method->setCarrierTitle('Carrier title here'); //can come from config

    // record method information
    $method->setMethod($this->_code);
    $method->setMethodTitle('Method title here'); //can come from config
    //calculate price based on weight

    if ($weight < 6) {
        $price = 5.95; //value can come from config
    }
    elseif ($weight < 11) {
        $price = 7.95; //value can come from config
    }
    else {
        $price = 7.95;//base price - value can come from config
        $overweight = ceil($weight - 11); //round up the weight difference
        $price += 0.21 * $overweight;//add 0.21 for each kg over 11. Value ca come from config
    }
    //add the price to the method
    $method->setPrice($price);

    // add this rate to the result
    $result->append($method);

    return $result;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.