How to Hide All Shipping Methods When “Free Shipping” is Active
Written by Johnathan Shaw in Tips, Tutorials on June 19, 2013 | 18 Comments
Have you always wanted to hide all other shipping methods when “Free Shipping” is active, so it’s the only shipping choice that appears? You can do so with two simple code edits, as detailed below. In OpenCart versions 1.5.2 - 1.5.5, perform these core file modifications:
IN BOTH:
/catalog/controller/checkout/cart.php /catalog/controller/checkout/shipping_method.php
BEFORE:
$this->session->data['shipping_methods'] = $quote_data;
ADD:
if (isset($quote_data['free'])) { $free_only['free'] = $quote_data['free']; $quote_data = $free_only; }
If you’re using OpenCart 1.5.0 or 1.5.1 versions, the files are instead named:
/catalog/controller/checkout/shipping.php /catalog/controller/total/shipping.php
For 1.4.x OpenCart versions, the files are:
/catalog/controller/checkout/guest_step_2.php /catalog/controller/checkout/shipping.php
And that’s all you need! Any other shipping method — including ones you’ve installed — will not appear when Free Shipping is active.
18 Comments on "How to Hide All Shipping Methods When “Free Shipping” is Active"
Hello,
Could someone help me.
I’m using similar method to show only one shipping method if in product activated this option.
But now I need to show two shipping methods. So how I need to modify this code
isset($quote_data['free'])) {
$free_only['free'] = $quote_data['free'];
$quote_data = $free_only;
to get for example two methods - pickup and courier?
Perfect, it works!
Thanks a lot for the solution.
OC ver. 1.5.6
For cart.php: by line 774
For shipping_method.php: by line 47
OPENCART 2.0+
Go To:-
/catalog/controller/checkout/shipping.php
/catalog/controller/checkout/shipping_method.php
Find:-
$this->session->data['shipping_methods'] = $quote_data; //shipping.php
$this->session->data['shipping_methods'] = $method_data; //shipping_method.php
Then Add Below Code Before This
if (isset($quote_data['free']))
{
$free_only['free'] = $quote_data['free'];
$quote_data = $free_only;
}
***Note Replace “$quote_data” by “$method_data” in shipping_method.php
Hi Johnathan, can you tell us how to do it in Opencart 2.0.1.1?
Thanks in advance
That’s likely something that needs to be changed in your quick checkout code. I’d try asking the developer to see if they could give you any direction on it.
This was super helpful. cheers.
I’m using a “fast checkout” mod that allows for the increase and decrease of product quantities on the checkout page itself.
If you “+” items qty’s through to the free ship threshold, the free ship option is shown but not selected.
Is this something that can be changed in opencart’s code or something to be looked at by the quick checkout dev?
Thanks for all your great tips!
Thanks for the tip, it came in very useful for a client!
The edits are the same for 1.5.6. This post was written before it came out.
Can you make a tutorials how to make only Free Shipping appear when active for opencart 1.5.6?
Worked like a charm with the addition for pick up as well. Simple and quick. Thank you.
The rate format for Weight Based Shipping should be [weight:cost, weight:cost, etc.] so you should be able to show a $0.00 cost shipping for a 0 weight like this:
0:0.00
If that doesn’t work, you can certainly do it with my Weight-Based Shipping (www.opencartx.com/weight-based-shipping) extension, or you can restrict any method by weight using Restrict Shipping Methods (www.opencartx.com/restrict-shipping-methods).
Hello, I am trying to configure my company’s website so that if the weight is 0 the shipping cost is free - always, and no other shipping options are available. I tried doing this with weight based shipping, and it gave multiple shipping options for the 0 weight.
Can you point me in the right direction? As far as I can tell I can either edit weight based shipping so that only the lowest shipping price shows or modify both free shipping and the cart and shipping methods pages.
That’s fast! Genius, that worked. Thank you very much.
You can try changing the code edit to this, which may work:
if (isset($quote_data['free'])) {
$free_only['free'] = $quote_data['free'];
$free_only['pickup'] = $quote_data['pickup'];
$quote_data = $free_only;
}
Is it still possible to accept pick up from store? Like adding something to code? Thank you, gtrz
Excellent post thank you! I was just about to buy this addon and found this page
Thanks Johnathon for the timely post - which saved me a considerable amount of time and headaches on how to resolve showing other shipping methods when free method condition had been reached. To make life a little simpler at my end I have set up a little VQMOD to make the changes you outlined.
It really deedpns on in what way it doesn’t work for you. Any error messages, anything in vqmod logs? You will need to tune it if you aren’t using the default theme.You might want to mail us a line with the link if it is online so we can check it out, but it will probably take some time.