Category Archives: Trick & Tips

How to remove twig cache in OC 3.x

There is a tiny developer menu in opencart 3.x that can be overlooked easily but it is very essential for every developer or store owner. All we know that since OC 3.x, it uses twig as template engine and we often need to remove twig cache. We can remove twig cache by removing files in storage/cache directory using ftp. Interesting that it is possible to remove template cache from developer menu that can be found admin dashboard easily. Here are the steps:

  1. First check you have enough permission to modify developer menu by editing User group.

2. Developer menu can be found in admin dashboard

3. It will open a popup whenever you click on developer menu. Now you can refresh/remove twig cache by clicking on Refresh icon. Also it is possible to remove SASS cache from that popup.

Shipping Cost per 100gm with additional $10

how to set following situation?

initial charge(Rate per parcel) $10
Plus rate per 100g or part thereof $1

So if customer buy an item of 300g
Total charge is $13 (1 x $10 + 3 x $1)

Thanks for your query. Please do following:

1. Under Price setting tab, Select Rate type is Weight.

I am assuming that your default weight unit is gram. If it is KG, then you will have to enter it accordingly. For example, 100 will be replaced with 0.1

Now enter following Unit Ranges:

Start . —- End . —- Cost —- per unit block —- Allow partial 
0 —- 999999 — 1 —– 100 – – — – – NO

Explanation:
——-
a. First define a big ranges 0 – 999999 so that it covers all weight
b. Per unit block ensure that it will charge $1 per 100 gram
c. Allow partial ensure that it will not charge partial block. SO it will charge $3 for 250 grams instead of $2.5

2. Under Price adjustment section, enter +10 into the field “Modifier” [+10 means it will add $10 with final cost]

how to overwrite default contact page by xform’s form?

You will have to follow following steps if you want to overwrite default contact form by form created by xform.

  1. Enable layout module option in Xform -> Integration.
  2.  Add following css rule Xform -> Other Tab into Custom CSS section. This is needed to hide default contact form.

3. Now navigate to Design -> Layout , Now edit Contact Layout. Finally add your form at Content bottom position.

That’s all.

 

How to install xshippingpro in OC 2.x?

Although I am giving screenshot of xshippingpro but these steps applicable for any module. So any module can be installed by following these steps.

First, unzip downloaded zip file.

You will get another zip file named get xshippingpro.ocmod.zip

 

Now, please Go to Admin -> Extensions -> Extension Installer.

Then select “xshippingpro.ocmod.zip” and click on continue.

Now please navigate to admin -> Extensions -> Shipping. Now click on Install button located beside X-shipping pro row.

Finally, go to Admin -> Extensions -> Modifications and now click on “Refresh” button

Congrats! You are done. Now it is ready for adding shipping method. New shipping method can be added from admin -> Extensions -> Shipping

Always display sub-categories in left side in opencart

By default sub-categories won’t be displayed until parent category become active. If you want to  keep sub-categories visible always, this hacks for you.

You need to modify two files.

Controller

catalog/controller/extension/module/category.php   [OC 2.3.x]
catalog/controller/module/category.php   [OC < 2.3 ]

Find following codes

Now replace above codes by following

 

View

catalog/controller/extension/module/category.tpl   [OC 2.3.x]
catalog/controller/module/category.tpl   [OC < 2.3 ]

You can replace all codes of template file by following

Good luck!

Moving Currency Selection from header to footer in opencart

If you want to move Currency selection dropdown from header to footer, you will need to following two files:

  1. catalog/controller/common/footer.php  Please add following code

Now  $currency is available inside catalog/view/theme/YOUR_THEME/template/common/footer.tpl so you can place it whatever you want in footer.tpl file i.e you will have place following code

 

 

 

Showing Breadcrumb on Homepage in opencart

By default opencart does not show breadcrumb on home page in default theme.  If you want to show breadcrumb on home page, you will have to modify two files.

Controllercatalog/controller/common/home.php, Add following code of lines just before the line $data[‘column_left’] = $this->load->controller(‘common/column_left’);

View   catalog/view/theme/YOUR_THEME/template/common/home.tpl , add following lines of code after <div class=”container”> or as per your theme.

That’s all.  It is recommended to use OCmod for modifying file instead of modifying directly, otherwise it will be lost in future update.

Feeling lazy! NO worry, I attached an OCmod. You can install through opencart extension installer.  Finally, refresh your modifications list in Admin -> Extensions -> Modification

Click here to download breadcrumbonhome.ocmod.xml 

What is Multi-Categories Rule in xshippingpro?

Xshippingpro matches rule categories with cart categories one by one during checkout. So it never permit a category that are not listed under rule categories. But often one product could be assigned to more than categories.  To work properly, you should enter all categories of a product to the rule categories list although it is not comfortable to enter each category for a single products.

Multi-Categories Rule can help in this case. You don’t need to put every categories of a product to the rule category list. Instead you can select only one of them, and choose Multi-Categories Rule to “Any” that will do affect same thing as entering all categories to rule category list.

multi-category

For example, you have a product which was assigned to category A, Category B and Category C. By default, you will have to select category A, Category B and Category C under xshippingpro category rule. But if you choose Multi-Categories Rule to “Any“, then it is enough to choose category A only under xshippingpro category rule to work properly. It will be same thing as choosing category A, Category B and Category C.

Multi-Categories Rule will help to save your time a bit.

 

 

 

 

 

Free shipping just for certain products using xshippingpro

It is very easy to setup free shipping for the certain products using xshippingpro. Please do following for achieving this scenario:

  1. Create a new method and give it a name
  2. Now go to Category/Product tab. Select category rule is “Any of the selected products”. Now select applicable products.
  3. Now go to Price Setting Tab and select rate type is “Flat”. Now enter price is 0

That’s all. It is very easy, isn’t it?

To know more about Product/Category rule, check this article 

 

 

Unit Ranges in details in xshippingpro

For each method you can define multiple ranges e.g weight ranges or quantity ranges and a separate cost for that range.
For example, consider a shipping requirements where you need following:

1. For the first 3 items, cost is $5
2. For the remaining each item cost is $2

In this scenario, we need two unit range rows. Since it is related with quantity, so must
select rate type is “Quantity”. Then you will have to enter following unit ranges.

Start    End       Cost        Per Unit Block       Allow Partial
0            3            5               0                                       NO
4           9999       2             1                                        NO
Finally you will have to select final price to cumulative. why cumulative? Because you want to sum up two ranges cost together.

Q. So what will be shipping cost for 5 items from above scenario?

A. For first 3 item, $5 (According first unit range)
For remaining 2 item (2 x $2) $4 (According second unit range)
——————————————
Cumulative cost $9

So shipping cost will be $9
Q. What is Per Unit Block?

A. Per Unit Block simply means per unit. For example, in our above scenario, we want to charge
$2 per item after the first 3 items. So Per unit block is 1. Thats why we have entered Per unit block is 1
for second unit range (second row) for our described shipping scenario.
Q. What is Allow Partial?

A. Sometimes you might need to charge for the half block or half item. Sometimes you don’t want
to allow partila block. Moreover you want to charge for the full block cost in case of partial block. Consider following scenario:
1. if weight is less 3kg, cost will be $5 per kg
2. if weight is greater than 3kg, cost will be flat rate $10
In this scenario, we need two unit range rows. Since it is related with weight, so must
select rate type is “weight”. Then you will have to enter following unit ranges.

Start    End       Cost        Per Unit Block       Allow Partial
0            3            5               0                                       NO
4           9999       10             0                                        NO

Since we don’t need summed cost of each rows together in this scenario. So final cost will be single NOT cumulative.

So what will be cost of 3kg?   Total block 3, cost of each block $5 so cost is $15 (3*5) (according to first row)
So what will be cost of 4kg?   Flat rate $10 (according to second row)
So what will be cost of 2.5kg?   Total block 2.5, cost of each block $5 so cost is $15 (3*5, 2.5 rounds to 3 depending on Allow Partial) (according to first row).
But if you would set “Allow Partial” is Yes, cost would be $12.5 (2.5*5)