How to disable other shipping methods if Free Shipping is available in OpenCart 2.x

Hello guys!

In this post I will show you another nice trick which you can integrate in your OpenCart 2.x store. I will demonstrate you how to show only the free shipping method option in the payment methods section if the customer is eligible for it.

Get the modification for OpenCart 3.x here!

If you have read our previous posts, you already know that we use OCMod functionality in OpenCart to apply our small modifications. 

This is the code needed for the modification:

    <name>Show Only Free Shipping if Available</name>
	<version>1.0 (Initial)</version>
	<file path="catalog/model/shipping/*.php">
			<search><![CDATA[if ($status) {]]></search>
			<add position="before"><![CDATA[
			if (get_class($this)!='ModelShippingFree') {
              if (($this->config->get('free_status') == 1) && (float)$this->cart->getTotal() >= $this->config->get('free_total')) {
                 $status = false;

You have to copy it and save it like this - showfreeshippingonly.ocmod.xml. You can use another name, but make sure to preserve the extension .ocmod.xml. After that, you just have to install the modification using the Extension Installer in OpenCart and refresh all OCMod files from Extensions > Modifications.

This is the end result:

That’s all!

If you have any questions, make sure to use the comments section which you can find below.

Join 11,000+ subscribers receiving actionable E-commerce advice

* Unsubscribe any time

Trending blogs

comments powered by Disqus