How to create/duplicate a module?
How to create/duplicate a module?
This guide applies to all versions of OpenCart 1.x (eg 1.3.x, 1.4.x, 1.5.x, etc)
It is very rare that this will be needed. Even when you think you have to duplicate a module like "flat rate", it is actually best done using one of the zone based options like weight-based or zone plus.
But in any case, for those that are hell bent on duplicating existing sideboxes, payment, or shipping modules. This hi-level breakdown should get you going.
1. CHOOSE THE FILES
First think of which module you new module is most similar too. In this example, we will make a clone of the "Cash on Delivery" payment module and name it "Cash on Pickup".
There are generally 6-8 files that need to be cloned for each module, and they follow a similar structure:
1. admin/controller/payment/cod.php
2. admin/language/english/payment/cod.php
3. admin/view/template/payment/cod.tpl
4. catalog/controller/payment/cod.php
5. catalog/language/english/payment/cod.php
6. catalog/model/payment/cod.php
7. catalog/view/theme/default/template/payment/cod.tpl
2. CLONE & EDIT THE FILES
Use your favorite FTP client (like ftp wanderer)
1. Goto the path for each file above
2. download the cod.* file to your local pc (e.g. c:\cop)
3. rename it to "cop" (be sure to note the extension as either .php or .tpl)
4. Use a good (free) text editor like notepad++ to edit the file.
5a. In the notepad++ menu, Goto "Search->Replace..."
- Find what: cod
- Replace with: cop
Click "REPLACE ALL"
5b. For language files, be sure to change wording as appropriate. Example "Cash on Delivery" should be changed to "Cash on Pickup".
5c. For modules that use underscores (i.e. pp_standard) You must ensure that the class name at the top of the controller & model files does NOT have this _ after doing the replace all.
Correct: class ControllerPaymentPPStandard extends
Incorrect: class ControllerPaymentPP_Standard extends
6. Save the file.
7. Now reupload the new file to the same directory path. Now you should have a cod and cop file next to it.
8. Delete the local file in c:\cop
9. Repeat for each file, one by one.
3. INSTALL THE NEW FILES
Now that we have the new files uploaded, they should likely be seen by the OpenCart payment module system.
1. In the OpenCart Admin section, goto Extension->Payment
2. If everything is right so far, you should see the new "Cash on Pickup" module waiting to be installed
3. Click Install
4. Click Edit. If there are no errors then configure it appropriately. If there are errors, you likely missed a step in the edit. Note what file the error is in and check that file, tracing back your edit steps above
5. Save the configuration
6. Goto the customer checkout process and verify there are no errors. You should see a new Cash on Pickup payment option.
Done.
It is very rare that this will be needed. Even when you think you have to duplicate a module like "flat rate", it is actually best done using one of the zone based options like weight-based or zone plus.
But in any case, for those that are hell bent on duplicating existing sideboxes, payment, or shipping modules. This hi-level breakdown should get you going.
1. CHOOSE THE FILES
First think of which module you new module is most similar too. In this example, we will make a clone of the "Cash on Delivery" payment module and name it "Cash on Pickup".
There are generally 6-8 files that need to be cloned for each module, and they follow a similar structure:
1. admin/controller/payment/cod.php
2. admin/language/english/payment/cod.php
3. admin/view/template/payment/cod.tpl
4. catalog/controller/payment/cod.php
5. catalog/language/english/payment/cod.php
6. catalog/model/payment/cod.php
7. catalog/view/theme/default/template/payment/cod.tpl
2. CLONE & EDIT THE FILES
Use your favorite FTP client (like ftp wanderer)
1. Goto the path for each file above
2. download the cod.* file to your local pc (e.g. c:\cop)
3. rename it to "cop" (be sure to note the extension as either .php or .tpl)
4. Use a good (free) text editor like notepad++ to edit the file.
5a. In the notepad++ menu, Goto "Search->Replace..."
- Find what: cod
- Replace with: cop
Click "REPLACE ALL"
5b. For language files, be sure to change wording as appropriate. Example "Cash on Delivery" should be changed to "Cash on Pickup".
5c. For modules that use underscores (i.e. pp_standard) You must ensure that the class name at the top of the controller & model files does NOT have this _ after doing the replace all.
Correct: class ControllerPaymentPPStandard extends
Incorrect: class ControllerPaymentPP_Standard extends
6. Save the file.
7. Now reupload the new file to the same directory path. Now you should have a cod and cop file next to it.
8. Delete the local file in c:\cop
9. Repeat for each file, one by one.
3. INSTALL THE NEW FILES
Now that we have the new files uploaded, they should likely be seen by the OpenCart payment module system.
1. In the OpenCart Admin section, goto Extension->Payment
2. If everything is right so far, you should see the new "Cash on Pickup" module waiting to be installed
3. Click Install
4. Click Edit. If there are no errors then configure it appropriately. If there are errors, you likely missed a step in the edit. Note what file the error is in and check that file, tracing back your edit steps above
5. Save the configuration
6. Goto the customer checkout process and verify there are no errors. You should see a new Cash on Pickup payment option.
Done.

Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
-

Qphoria - Administrator
- Posts: 18237
- Joined: Mon Jul 21, 2008 7:02 pm

Re: How to duplicate a module?
very usefull, thanks..
- Donce
- Posts: 68
- Joined: Fri Aug 28, 2009 12:22 pm
Re: How to create/duplicate a module?
Be sure to match case when replacing the old names with your new names.
For example: imaginetech's Your Box module uses a combination of camel-case (e.g: YourBox) and lower-case (e.g yourbox).
Suppose you wanted to change the module to be called 'My Box', you'd replace these names as 'MyBox' and 'mybox' respectively.
If using a wysiwyg text editor check the 'Match Case' option while replacing.
For example: imaginetech's Your Box module uses a combination of camel-case (e.g: YourBox) and lower-case (e.g yourbox).
Suppose you wanted to change the module to be called 'My Box', you'd replace these names as 'MyBox' and 'mybox' respectively.
If using a wysiwyg text editor check the 'Match Case' option while replacing.
- yegga
- Posts: 138
- Joined: Mon Sep 07, 2009 9:03 pm
Re: How to create/duplicate a module?
We really need a karma button on this forum 
Brill breakdown!
Matt

Brill breakdown!
Matt
- Code: Select all
It was like that when I found it, honest!
-

moggiex - Posts: 182
- Joined: Mon Nov 09, 2009 1:55 pm
Re: How to create/duplicate a module?
it's awesome. Thanks very much
- jimmy_zjw
- Posts: 2
- Joined: Tue Nov 17, 2009 6:40 am
Re: How to create/duplicate a module?
very usefull 

Welcome to osCommerce Asia! Our professional development team provides a complete solution of excellent and first-class osCommerce-based web site for your e-commerce business.We offer a variety of services including the Template Customization, customized module development, search engine optimization, eCommerce site data maintenance and technical support, and eCommerce solutions and consulting.
- dingsword
- Posts: 50
- Joined: Sat Dec 05, 2009 2:25 pm
Re: How to create/duplicate a module?
Hi all, is there a way to duplicate "categories" module/box in homepage? I explain better my need: I have two main products categories (really different and not related), i.e. "Car accessories" and "Mobile phone".
I would like to show Car products and Mobile phone products in two separate boxes in OC home page.
many thanks in advance,
Max
I would like to show Car products and Mobile phone products in two separate boxes in OC home page.
many thanks in advance,
Max
Arvixe Web Hosting / OpenCart Community Liaison - Looking for quality OpenCart hosting? Try Arvixe
My last mods: Partita IVA e CF | Pro EU VAT Number | US Tax ID and Exempt | VAT Exemption for disabled | Customer Tax Exemption | Sales Agents | Dropshipping
If I helped you please donate!
My last mods: Partita IVA e CF | Pro EU VAT Number | US Tax ID and Exempt | VAT Exemption for disabled | Customer Tax Exemption | Sales Agents | Dropshipping
If I helped you please donate!
-

madimar - Posts: 1023
- Joined: Thu Sep 24, 2009 10:27 am
Re: How to create/duplicate a module?
Yes. The same concept applies from the first post.
1. admin/controller/module/category.php
2. admin/language/english/module/category.php
3. admin/view/template/module/category.tpl
4. catalog/controller/module/category.php
5. catalog/language/english/module/category.php
6. catalog/view/theme/default/template/module/category.tpl
1. admin/controller/module/category.php
2. admin/language/english/module/category.php
3. admin/view/template/module/category.tpl
4. catalog/controller/module/category.php
5. catalog/language/english/module/category.php
6. catalog/view/theme/default/template/module/category.tpl

Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
-

Qphoria - Administrator
- Posts: 18237
- Joined: Mon Jul 21, 2008 7:02 pm

Re: How to create/duplicate a module?
hmmm, then, how to associate some categories to first Categories box and others to second categories box?
Arvixe Web Hosting / OpenCart Community Liaison - Looking for quality OpenCart hosting? Try Arvixe
My last mods: Partita IVA e CF | Pro EU VAT Number | US Tax ID and Exempt | VAT Exemption for disabled | Customer Tax Exemption | Sales Agents | Dropshipping
If I helped you please donate!
My last mods: Partita IVA e CF | Pro EU VAT Number | US Tax ID and Exempt | VAT Exemption for disabled | Customer Tax Exemption | Sales Agents | Dropshipping
If I helped you please donate!
-

madimar - Posts: 1023
- Joined: Thu Sep 24, 2009 10:27 am
Re: How to create/duplicate a module?
I have this available for v1.3.4 already if you like here:
http://www.unbannable.com/ocstore/cat_box_clone
It allows you to choose which category box to assign the category to from the admin section when creating the category.
http://www.unbannable.com/ocstore/cat_box_clone
It allows you to choose which category box to assign the category to from the admin section when creating the category.

Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
-

Qphoria - Administrator
- Posts: 18237
- Joined: Mon Jul 21, 2008 7:02 pm

Re: How to create/duplicate a module?
Interesting! It is exactly what I'm looking for. Does it work also with 1.3.2?
Anyway I will do an exercise trying to develop it by myself... or I'll let you know soon!
Thank you very much for usual support.
Max
Anyway I will do an exercise trying to develop it by myself... or I'll let you know soon!
Thank you very much for usual support.
Max
Arvixe Web Hosting / OpenCart Community Liaison - Looking for quality OpenCart hosting? Try Arvixe
My last mods: Partita IVA e CF | Pro EU VAT Number | US Tax ID and Exempt | VAT Exemption for disabled | Customer Tax Exemption | Sales Agents | Dropshipping
If I helped you please donate!
My last mods: Partita IVA e CF | Pro EU VAT Number | US Tax ID and Exempt | VAT Exemption for disabled | Customer Tax Exemption | Sales Agents | Dropshipping
If I helped you please donate!
-

madimar - Posts: 1023
- Joined: Thu Sep 24, 2009 10:27 am
Re: How to create/duplicate a module?
I have followed the instructions for creating a duplicate module..... I have it installed works fine.... the one question I have is.....
the new module is "cash on pick up"
When a customer proceeds to check out they are given the payment options where they can choose cash on pickup BUT when they choose cash on pickup they are still being charged the shipping fee (which isn't necessary as they are picking up the item themselves). Is there a way to avoid the shipping charge from being applied when they choose to pay cash at time of pickup?
Thanks anyone for any help and or suggestions.
DJ
the new module is "cash on pick up"
When a customer proceeds to check out they are given the payment options where they can choose cash on pickup BUT when they choose cash on pickup they are still being charged the shipping fee (which isn't necessary as they are picking up the item themselves). Is there a way to avoid the shipping charge from being applied when they choose to pay cash at time of pickup?
Thanks anyone for any help and or suggestions.
DJ
- shadoblix
- Posts: 32
- Joined: Sun Dec 13, 2009 5:49 pm
Re: How to create/duplicate a module?
Unfortunately the horse and the carriage don't line up well here. The Cash on Pickup was just an example, but it would only work if you didn't charge shipping. Technically the COD and COP should be shipping modules. Or clone the free ship and rename it to "Pickup" then set the COP to only show IF the pickup shipping is chosen.

Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
-

Qphoria - Administrator
- Posts: 18237
- Joined: Mon Jul 21, 2008 7:02 pm

Re: How to create/duplicate a module?
Hi Qphoria,
Thanks for the instruction. I want to duplicate a sidebox using Information module, to add in news and sub modules. Would you please advise which files I need to duplicate. Thanks in advance!
Desmond
Thanks for the instruction. I want to duplicate a sidebox using Information module, to add in news and sub modules. Would you please advise which files I need to duplicate. Thanks in advance!
Desmond
- des2006
- Posts: 2
- Joined: Mon Jan 04, 2010 11:33 am
Re: How to create/duplicate a module?
using the info from this post:
viewtopic.php?f=22&t=6696&view=unread&sid=3f0b2b9568062f0e719452cfe9dd518e#p43198
I'll let you figure out the rest
viewtopic.php?f=22&t=6696&view=unread&sid=3f0b2b9568062f0e719452cfe9dd518e#p43198
I'll let you figure out the rest

Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
-

Qphoria - Administrator
- Posts: 18237
- Joined: Mon Jul 21, 2008 7:02 pm

Re: How to create/duplicate a module?
Thanks Qphoria,
In fact I have done the above to duplicate information files to another ones which I called Event files. In the files, I changed all the words with information to event. In the Mysql I duplicate ocinformation and ocinformation_description to ocevent and ocevent_description. Uploaded and tested in the Admin, could install and enable the Event module.
However, the ocevent and ocevent_description had no data written in. The Catalog column (in the Admin page) did not show the Event module. Going to the Online shop just showed a blank page. Until Idisabled the Event module, the online shop resumed to normal.
Would you please advise where the problem is. Many thanks!
Desmond
In fact I have done the above to duplicate information files to another ones which I called Event files. In the files, I changed all the words with information to event. In the Mysql I duplicate ocinformation and ocinformation_description to ocevent and ocevent_description. Uploaded and tested in the Admin, could install and enable the Event module.
However, the ocevent and ocevent_description had no data written in. The Catalog column (in the Admin page) did not show the Event module. Going to the Online shop just showed a blank page. Until Idisabled the Event module, the online shop resumed to normal.
Would you please advise where the problem is. Many thanks!
Desmond
Qphoria wrote:using the info from this post:
viewtopic.php?f=22&t=6696&view=unread&sid=3f0b2b9568062f0e719452cfe9dd518e#p43198
I'll let you figure out the rest
- des2006
- Posts: 2
- Joined: Mon Jan 04, 2010 11:33 am
Re: How to create/duplicate a module?
Ah ok.. so you are 90% there.
The last step is the database (model) stuff. Since information has its own model file
Clone the
admin/model/catalog/information.php
file to event.php as well. That is your missing link
The last step is the database (model) stuff. Since information has its own model file
Clone the
admin/model/catalog/information.php
file to event.php as well. That is your missing link

Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
-

Qphoria - Administrator
- Posts: 18237
- Joined: Mon Jul 21, 2008 7:02 pm

Re: How to create/duplicate a module?
I've been trying to create a new shipping method based on weight based shipping. In Admin section everything is working just fine but in the Store checkout gives php errors. I've done this new shipping method as here have been instructed (5 files copied and renamed and find->replaced). What can cause these fatal errors? Is there a simple 'How-to create a new shipping method in Opencart for Dummies'
?
?The Finnish OpenCart Forum | Finnish OpenCart Add-ons
"Real programmers don't document. If it was hard to write, it should be hard to understand."
"Real programmers don't document. If it was hard to write, it should be hard to understand."
- Miguelito
- Posts: 807
- Joined: Sun Jan 10, 2010 2:11 pm
Re: How to create/duplicate a module?
Could someone please give simple instructions how to create a new shipping method based on weight based shipping? I'm having gray hair with fatal errors...
The Finnish OpenCart Forum | Finnish OpenCart Add-ons
"Real programmers don't document. If it was hard to write, it should be hard to understand."
"Real programmers don't document. If it was hard to write, it should be hard to understand."
- Miguelito
- Posts: 807
- Joined: Sun Jan 10, 2010 2:11 pm
Re: How to create/duplicate a module?
I've seen a lot of new shipping methods in the contributions section so I think someone would have a clue...?
The Finnish OpenCart Forum | Finnish OpenCart Add-ons
"Real programmers don't document. If it was hard to write, it should be hard to understand."
"Real programmers don't document. If it was hard to write, it should be hard to understand."
- Miguelito
- Posts: 807
- Joined: Sun Jan 10, 2010 2:11 pm
Who is online
Users browsing this forum: mameha and 16 guests













