Disable free shipping for purchase below certain amount – OpenCart

If you are OC developer or shop owner, some time you might need to disable that  “Choose shipping method” option and make it default with some thing. For example, if customer make a purchase below certain amount say 10$, you wont have to provide free shipping, you need to put the flat rate shipping, then obviously, you dont want to show that select option between other shipping methods. How to to do this in OpenCart. well here is the trick. The ideas to disable all other shipping methods once the purchase total amount is less that  triggering  amount for free-shipping.


1. open this file /your_OpenCartInstallation_DIRcatalog/model/flat.php

2. find the line         $method_data = array();

3. below that line paste this code

         if ($this->cart->getSubTotal() > $this->config->get(‘free_total’)) {
         $status = FALSE;



thats all.


OpenCart Add To Cart Issue on Home Page

Some times, this error gonna eat your brain for a long time. I recently got an error on my OpenCart website that, My Add to Cart function is not working on Home Pages that the website loads first time. Once I go inside to a product then I come back to home page, yeah, Add to Cart Function is working. First time, I thought it would be JS issue but no, I wasted much time on that assumption.

The real villain is your Domain Name.  In my case, http://mywebsite.com  does not work with the Add to Cart Function on homage on Initial website loading. But it works with http://www.website.com. So I set my server redirection such as any kind of URL request should redirect to http://www.mywebsite.com 

MAIL function with OpenCart

Sometimes , email function with OpenCart may not work. You would wonder what  went wrong. Here is a simple tip. Go to your Store Settings, then click on Mail tab, check the mail parameter  option.

input the parameter like this



please note that  ‘-F’ is  very important, and no spaces between, in front or after that.

Add To Cart Function on OpenCart to a Button

If you want to enable Add to Cart function on a button, you simply follow these.

Code for button below

 <input type=”button” value=”<?php echo ‘ADD TO CART’; ?>” onclick=”addTOCART(‘<?php echo $product[‘product_id’]; ?>’);”  /> 

Code for JavaScript effect below

<script type=”text/javascript”>
function addTOCART(product_id, quantity) {
quantity = typeof(quantity) != ‘undefined’ ? quantity : 1;

url: ‘index.php?route=checkout/cart/add’,
type: ‘post’,
data: ‘product_id=’ + product_id + ‘&quantity=’ + quantity,
dataType: ‘json’,
success: function(json) {
$(‘.success, .warning, .attention, .information, .error’).remove();

if (json[‘redirect’]) {
location = json[‘redirect’];

if (json[‘success’]) {
$(‘#notification’).html(‘<div class=”success” style=”display: none;”>’ + json[‘success’] + ‘<img src=”catalog/view/theme/default/image/close.png” alt=”” class=”close” /></div>’);

try {
catch(err) {

$(‘html, body’).animate({ scrollTop: 0 }, ‘slow’);

$(“.heading”).animate({backgroundColor: “#FFFFFF”}, ‘slow’);

$(“.cart_arrow”).attr(“style”, “display: block;”);

$(“.heading”).animate({backgroundColor: “#585858”}, ‘slow’);


OpenCart :- Display all products in subcategories to the Parent Category Page

OpenCart is surely one of the best open source E-commerce framework available now. Its extensive and fast enough too. Here is one tip for a particular scenario you may face when you are building an OC based E-commerce website.

If you want to list or display all products of subcategories under a parent category on the parent category page,  I will explain again,

consider a Mobile Phone e-shop, it has 4 brands of mobiles such as Nokia, Samsung, Sony and Apple and these sub menu / sub category of a parent menu/category as Brands.

Brands ->


 – Samsung

 – Sony

 – Apple

Obviously, when you click on each sub categories such Nokia, Apple etc, it will display products under that but if you need to display all the products when you click on BRANDS, then what should you do ?

well its very simple..

NOTE:- take backup of original files you are going to edit. this is very very important.

go here.. In catalog/controller/product/category.php (or wherever you’re calling function model_catalog_product->getProducts) you have to add this line

 filter_sub_category = true:

into this part of code snippet

$data = array(
    'filter_category_id' => $top_category,
    'filter_sub_category' => true,
    'sort'               => $sort,
    'order'              => $order,
    'start'              => ($page - 1) * $limit,
    'limit'              => $limit

$product_total = $this->model_catalog_product->getTotalProducts($data);

Thats all.. now you click on the Parent category, it will show all categories under that one. But one problem, what about Refine search. Now both are mixed right? One thing to do, just remove the refine search code. Code snippet lies in this file.

open this file /catalog/view/theme/your_theme/template/product/product.tpl and find the lines where refine search is listed. Just delete or comment those lines.