1

I need to set a custom free-shipping threshold (in config this is carriers/freeshipping/free_shipping_subtotal and can be set in the back-end) for each quote subtotal. So quotes above this subtotal amount will have free shipping applied. The subtotal-amount will change dynamically (by user) and should revert to default value set in back end when user is logged off.

How do I go about doing this?

3
  • can not understand by free-shipping subtotal threshold for each quote(cart.plz explain
    – Amit Bera
    Commented Sep 28, 2015 at 15:51
  • Hi Amit. I've made an edit.
    – Alan
    Commented Sep 28, 2015 at 16:03
  • what mean by The subtotal-amount will change dynamically(by user) and should revert to default value set in back end when user is logged off .please explain brefly
    – Amit Bera
    Commented Sep 28, 2015 at 16:41

1 Answer 1

1

You can accomplish a free shipping/per customer/per minimum subtotal by :

  1. Adding a new customer entity attribute, which will be the place to edit the minimum per order for each customer. Adding custom attribute to Customer
  2. After this you will need to rewrite the class Mage_Shipping_Model_Carrier_Freeshipping in app/code/core/Mage/Shipping/Model/Carrier/Freeshipping.php , specifically in the collectRates() method. instead of checking for $this->getConfigData('free_shipping_subtotal') we will check the customer subtotal from the attribute we created in point one.
if(Mage::getSingleton('customer/session')->isLoggedIn()) {
    $minimumOrderAmount = Mage::getSingleton('customer/session')->getCustomer()->getNewAttrubuteYouCreated();
} else {
    $minimumOrderAmount = $this->getConfigData('free_shipping_subtotal');
}

if (($request->getFreeShipping())
    || ($request->getBaseSubtotalInclTax() >= $minimumOrderAmount)
) {
    $method = Mage::getModel('shipping/rate_result_method');

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

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

    $method->setPrice('0.00');
    $method->setCost('0.00');

    $result->append($method);
}

Some links to help: http://inchoo.net/magento/overriding-magento-blocks-models-helpers-and-controllers/

2
  • Thanks Rabee. Although it didn't work for some reason(despite the condition was met the shipping rate wasn't free) it pointed me in the right direction. I've overwritten Mage_SalesRule_Model_Quote_Freeshipping as advised here magento.stackexchange.com/questions/3670/….
    – Alan
    Commented Sep 29, 2015 at 12:08
  • @Alan glad you found the answer, you didnt need to add a customer attribute at the end ? how did you make it customer specific ? I am going to double check my answer also.
    – Rabea
    Commented Sep 29, 2015 at 12:12

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.