I am learning Magento and trying to create a shipping method that appears only when the subtotal of the cart is over than $100.

I tried to getSubTotal() in function collectRates(), then return false if the return value smaller than 100. However, it always returns 0. I guess it had not been calculated at that step, is that true?

And is there any other way I can do what I wanted?

Please help... Thank you a lot!

1 Answer 1


your collectRates method should look like this

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

    if ($request->getPackageValue() < 100) {
        return false;
    /** @var Mage_Shipping_Model_Rate_Result $result */
    $result = Mage::getModel('shipping/rate_result');
    $method = Mage::getModel('shipping/rate_result_method');
    $method->setCarrier($this->_code); //add here the payment method code
    $method->setCarrierTitle($this->getConfigData('title')); //or you can add any title if it's not configurable
    $method->setPrice(your shiping cost here);
    return $result;
  • Thank you, @Marius!! getPackageValue() is exactly what I need!! I saw it but I thought it was about weight or something else lol. Oct 14, 2015 at 2:32

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.