Author - Robert Popovic

Founder and Technical Director of LERO9, a web agency specializing in Magento and WordPress design and development.

I launched Magebase in April, 2010 and am its editor and contributor. My main topics of interest are Magento development, customization and how to get the most out of Magento with the least amount of headache.

More Info » Follow me on Twitter »

Reader Comments (67)

  1. Isy Macadar
    July 21, 2010 at 8:59 am /

    Robert,

    We need to fix problem with Magento related to Authorize (first) and then Capture (some days afterwards) using Authorize.net

    Can you help me locate how to do that in agento?

    Thanks in advance and I look forward your comments.

    Isy.

    Reply
  2. Wayne Erickson
    July 22, 2010 at 10:41 am /

    Not understanding how to call this free shipping… do I need to config a promotion?

    Thanks

    Reply
  3. Wayne Erickson
    July 23, 2010 at 1:31 pm /

    Robert,

    The following link is the promo I have set up and the tablerate.php code… I used the view source link and pasted in into the tablerate.php file

    If I set the weights to “0″, the cart gives me a shipping charge… let me know what I doing wrong ….thanks

    http://we-designstudio.com/magento/promo-rule.png

             // Package weight and qty free shipping
            $oldWeight = $request->getPackageWeight();
            $oldQty = $request->getPackageQty();
    
            $request->setPackageWeight($request->getFreeMethodWeight());
            $request->setPackageQty($oldQty - $freeQty);
    
            $result = Mage::getModel('shipping/rate_result');
            $rate = $this->getRate($request);
    
            $request->setPackageWeight($oldWeight);
            $request->setPackageQty($oldQty);
    
      if (!empty($rate) && $rate['price'] >= 0) {
          $method = Mage::getModel('shipping/rate_result_method');
    
          $method->setCarrier('tablerate');
          $method->setCarrierTitle($this->getConfigData('title'));
    
          $method->setMethod('bestway');
    
          // If the free shipping promo condition is met
          if($request->getFreeShipping() === true) {
          	$shippingPrice = '0.00'; // we set the shipping price to zero
              // then we change the method title to indicate shipping is free
           $method->setMethodTitle(Mage::helper('shipping')->__('Free Shipping'));
    } else { // else we continue as normal
          	$shippingPrice = $this->getFinalPriceWithHandlingFee($rate['price']);
           $method->setMethodTitle($this->getConfigData('name'));
          }
    
          $method->setPrice($shippingPrice);
          $method->setCost($rate['cost']);
    
          $result->append($method);
      }
    
    Reply
  4. Wayne Erickson
    July 23, 2010 at 3:46 pm /

    Robert,

    Are you saying that will show the the free shipping call to the user?

    Thanks

    Reply
  5. Brittany
    Brittany
    October 6, 2010 at 10:05 am /

    Hi Robert,

    I’m curious as to how you set up your promotion. Did you use a coupon code to enable free shipping on checkout, and did you have to name the promotion “Free Shipping” to enable this code change? I can’t quite get it to work on my Magento install. Is it compatible with 1.4?

    Thanks
    -Brittany

    Reply
  6. Guido Jansen
    November 2, 2010 at 11:00 pm /

    We encountered this problem today, but a Google search lead us right to the solution here. Got to love open source and big online communities ;) . Thanks for the fix Robert!

    Reply
  7. Matthew Ellis
    November 25, 2010 at 5:07 am /

    Hi,

    This looks like exactly what I’m after – but I can’t get it working.

    I’ve updated the Tablerate.php file, created a Shopping Cart Price Rule with the following settings:

    Rule Name * – UK Shipping Discount
    Status * – Active
    Customer Groups * – All
    Coupon * – Yes
    Coupon Code * – noukshipping
    Uses per Coupon – Blank
    Uses per Customer – Blank
    From Date – Today
    To Date – Blank
    Priority – 0
    Public In RSS Feed – No
    ——-
    Conditions – Blank
    ——-
    Apply – Fixed Amount Discount
    Discount Amount * – 0
    Maximum Qty Discount is Applied To – 0
    Discount Qty Step (Buy X) – 0
    Apply to Shipping Amount – 0
    Free Shipping – For shipment with matching items
    Stop Further Rules Processing – No

    When I apply the coupon in the cart I get the ‘Coupon code “noukshipping” was applied’ message, but the grand total does not update – and the checkout give no indication of the Free Shipping either.

    Any ideas?

    Thanks!

    Reply
  8. Dickdv
    December 1, 2010 at 1:08 pm /

    Robert,

    great fix, thanks. I suppose we can’t complain about Magento not having fixed things like this earlier themselves. After all this is a free product. But it would make sense for them to organise the community better. A fix like this should be easily available on officila Magento support site ..

    Reply
  9. Sjoerd
    December 5, 2010 at 9:30 pm /

    Hey Robert,
    Simpel and good fix.
    Thanks

    Reply
  10. tarun
    tarun
    December 7, 2010 at 12:29 am /

    hey this is cool but i want to apply on item rate shipping calcuation how i perform

    Reply
  11. Irfan Ahmed
    Irfan Ahmed
    December 10, 2010 at 6:39 am /

    Hi,

    I am having trouble implementing the “Shopping Cart Rule” on USPS and FedEx shipping method. I have set all things up properly in “Shopping Cart Rule” i.e.

    Rule Name: Free Shipping 50
    Description: This is free shipping
    Status: Active
    Customers Group: All
    Coupon: FREE50
    User per Coupon: 1000000000
    User per Customer: 100000000
    From Date: today
    End Date: 12/21/2010
    Priority:
    RSS: No

    Conditions:

    Subtotal >= 50
    Shipping country: US
    True if Any:
    {
    Shipping Method: is fedex ground
    Shipping Method: is fedex Home delivery
    Shipping Method: is usps Priority Mail
    Shipping Method: is usps First-Class Mail flat
    }
    True if All:
    {
    Shipping Method: is not flat rate
    Shipping Method: is not Fixed

    }

    Total weight >= 0

    Action:
    Apply: Percent of product price discount
    Disount Amount: 0
    Max Qty : 0
    Discount Qty Step: 0
    Apply to Shipping Amount: Yes
    Free Shipping: For Shippment with matching items
    Stop further: No

    When I go to checkout and apply the Coupon “Free50″. It only apply the discount on Flat rate or free Shipping method types and It doesn’t have any impact on USPS and Fedex rates.

    I am using Magento 1.4.1.1.

    Can you please guide me what need to be done to apply this on these two Shipping methods.

    Best regards,

    Reply
  12. Chris
    December 21, 2010 at 10:23 am /

    How did you get the override of collectRates to work. I’m trying to override that function and doesn’t seem to want to allow it. I have checked and rechecked my code.

    Reply
  13. Chris
    Chris
    January 3, 2011 at 12:48 pm /

    @Robert

    Yes, thanks.. after monkeying around a bit, that’s what I ended up doing.

    Reply
  14. Peter
    Peter
    February 23, 2011 at 1:10 am /

    Slightly offtopic but I hope you would help me.

    it seems that there’s a bug in the Tablerate. Since 1.4.2 the tablerate returns always a shippingprice of 0 euro for all my products and accordings weights.
    Do you know where the weight prices is collected and how to set a correct weight?

    Any help appreciated !!!

    Reply
  15. Andreas von Studnitz
    March 9, 2011 at 11:05 pm /

    Hi Robert,
    thank you very much, you helped me a lot with this.
    By the way, the issue seems to be fixed in Magento 1.5.0.1.

    Reply
  16. suzy
    March 10, 2011 at 4:47 am /

    Hi Robert,

    I tried using your solution but it seems not to work on my end.

    I get a “Sorry, no quotes are available for this order at this time.” on the one page checkout.

    The following are my setup:

    1. i enabled table rate shipping method ONLY.
    2. I only want x products to be free shipping y and z to have a minimum shipping cost of $20
    3. I enabled a promo with the following settings

    Rule Information:
    Rule Name: Free shipping on x products
    Status: Active
    Customers groups: All
    Coupon: No Coupon
    Uses per customer: 9999
    From date: 01/01/2011
    To date: 01/01/2012

    Conditions:
    As is

    Actions:
    Apply: Fixed amount discount
    discount amount: 0
    max qty discount is applied: 999
    discount qty step: 0
    Apply to shipping amount: No
    Free Shipping: For matching items only
    Stop further rules processing: Yes

    Rule:
    if any of these conditions are true:
    category is one of 4 Note: 4 is category of x product
    attribute set is x

    I troubleshoot the issue by placing a magento log before and after the condition to check if the code is going inside the modification you made.


    Mage::log("Im outside");
    Mage::log('rate: '.$rate);
    if (!empty($rate) && $rate['price'] >= 0)
    Mage::log("im inside");

    The output is
    debug(7): Im outside
    debug(7): rate:

    it shows the “rate” has a null value causing it not to go inside the condition where the modifications (roberts snippet) were installed.

    any ideas where i went south?

    Thanks,
    Suzy

    Reply
  17. suzy
    March 11, 2011 at 9:01 pm /

    Thanks for the reply Rob.

    its working fine now. Good job on this one. simple and it works.

    Reply
  18. Paul
    March 14, 2011 at 4:26 am /

    Hi Robert,

    Do you know if there is a way of altering the code for the Configuration/Shipping Methods/Free Shipping module so that Free shipping only appears in shopping cart checkout when an applicable customer from a customer group is logged in?

    i.e. If I put a customer into, say, the wholesale customer group, then free shipping always appears in their cart, but not for a NOT LOGGED IN or any other customer.

    I’ve just updated site to Magneto ver 1.5.1

    Many thanks in advance

    Reply
  19. Janzell
    March 17, 2011 at 6:19 pm /

    H Robert,

    Is this applicable with Mulitple Table Rates?

    Thanks,

    Reply
  20. Paul
    Paul
    March 29, 2011 at 10:49 pm /

    Hi, Great fix :D but i have a small problem. I get the free shipping method only with simple products. when i use a config product the free shipping isn’t working. This is with magento version 1.4.0.1. Any tips on this or will it only work on simple products?

    Reply
  21. Kamal
    Kamal
    April 1, 2011 at 7:41 pm /

    Hi,Robert!

    I have recently upgraded M from 1.3.2.4 to 1.4.2.0. I am applying table rates there with csv like this

    “Country”,”Region/State”,”Zip/Postal Code”,”Order Subtotal (and above)”,”Shipping Price”
    “AE”,”*”,”*”,0,5
    “AE”,”*”,”*”,50,15
    “AE”,”*”,”*”,200,20
    “IN”,”*”,”*”,0,5
    “IN”,”*”,”*”,25,100
    I am testing table rates.But i dont know why only i am getting only $5 in shipping method.

    I have checked this csv in another fresh 1.4.2.0 version, it works perfect. But again when i have changed this with weight vs destination and made changes according to it,then applying price vs destination with above rates. And using one page checkout, again i am getting $5 in shipping.I have searched out for this issue but not getting any answer.TIA

    Reply
  22. Aseem Sharma
    Aseem Sharma
    May 12, 2011 at 4:38 pm /

    But its not working for the configurable products……..
    how can i resolve this for configurable products ?

    Thanks

    Reply
  23. Helder
    Helder
    May 21, 2011 at 7:23 am /

    Hello,

    Nice article and very helpful. However, after following these instructions, I found that the only way that the Free shipping can work with this customization is if the rule is set to “For shipment with matching items only”.

    This is kind of a problem, because I was trying to set up a rule to apply free shipping for any product coming from an specific category, and the system keeps giving Free Shipping if the order contains a product from that category AND products from any other category.

    I even tried adding a condition like this one:

    If ALL of these conditions are TRUE :
    If an item is FOUND in the cart with ALL of these conditions true:
    Category is 45
    Category is not 1,2,3,4,5,6,7,8,9,10

    Any suggestions?

    Reply
  24. Vishal sanwar
    Vishal sanwar
    July 25, 2011 at 4:56 pm /

    hey Robert,

    my problem is that,i want to give free shipping to only US client,now plz give me solution, on here or send me mail as soon as possible……
    thanx
    in advance

    Reply
  25. james
    james
    July 27, 2011 at 5:34 am /

    My problem is in shipping methods….I want tried to enable the shipping table rates and the Fed ex rates the went to price cart rules enabled a new called shipping method…because I do not want the user to have a choice between the shipping methods given the type of products we carry. We live produce so some are very perishable and need to be next day and other items could be ground depending on our rules… the only choice we enabled for the user is a calendar to set a date for delivery

    Reply
  26. dinesh
    dinesh
    October 18, 2011 at 7:57 pm /

    In Magento While the free shipping is enable in admin. But the weight is exceed more than 10 kg i need to add each kilo 4 rupees. Create our own module and it is applicable only for United States calfornia state.

    Reply
  27. Walstra
    March 2, 2012 at 7:34 am /

    Dear Robert,

    I have a question and hope you are someone else can help.

    I use tablerate shipping method,but the Condition i set is price v. destination,not weight.

    when over $100 is free shipping

    But I found :
    the shopping cart Subtotal is $120.00
    I use coupon code cut off $30
    and the Grand Total is $90.00

    when i estimate the shipping, It calculate shipping cost base on subtotal ,not grand total,

    it shoudn’t be free shipping because it only charge $90,not over $1200

    I need change it to calculate shipping cost base on grand total or the shipping cost after calculating subtotal – discount.

    Hope that someone can help.

    Thanks

    Reply
  28. Carlos
    Carlos
    March 28, 2012 at 9:42 pm /

    Hi Robert,

    I’ve the same problem as the post above me. I’m using 1.5.1.
    This is a weird problem, I hope you have some insight in this.

    Thanks

    Reply
  29. Vimal
    Vimal
    August 21, 2012 at 10:01 pm /

    Dear Robert,

    I use tablerate shipping method,but the Condition i set is price v. destination,not weight.

    when over $100 is free shipping

    But I found :
    the shopping cart Subtotal is $120.00
    I use coupon code cut off $30
    and the Grand Total is $90.00

    when i estimate the shipping, It calculate shipping cost base on subtotal ,not grand total,

    I need change it to calculate shipping cost base on grand total or the shipping cost after calculating subtotal – discount.

    and please tell me where is this function $request->”getFreeShipping()”

    if i found getFreeShipping() i can change the condition to check Grand total , instead of subtotal

    please reply me ASAP

    Thanks

    Reply
  30. DROse
    DROse
    November 5, 2013 at 9:34 pm /

    Hi Robert,

    Just wondering if this thread is still active? I am having the problems now but with 1.7+ those things written here is not working anymore, do you have a update for this?

    My situation, price v destination and tablerate, the tablerate works but no luck for free shipping items, I did all this steps but to no avail

    Thank you!

    Reply

Add a Comment & Join the Discussion

Insert small snippets of code by using [code]{your_code_here}[/code]
For larger code blocks please use http://pastebin.com and paste your link.

You may also use the following HTML in your comment: <a href="" title=""> <abbr title="">
<acronym title=""> <blockquote cite=""> <cite> <em> <strike> <strong>