Post navigation

well,as a zen cart developer,you may have lots of zen cart template. Don’t you bother with zen cart installation. Though you can make a batch script to generate mass zen cart websites, it will take you a lot of disk space and make you headache while searching for a special zen cart template.

so why not keep all the zen cart template in a single zen cart website.when you need to test some special zen cart template,specify a parameter with the value of template name and zen cart will take the parameter as the current template,no bother to do zen cart admin setting once and once again.

so how? the adoption of the zen cart core code is simple,as below:

Copy includes/init_includes/init_templates.php to includes/init_includes/overrides/init_templates.php,change the code like below:

save,then browse your zen cart website with url like this http://www.abcdomain.com/?t=temp1.zen cart will looking for the template temp1,if exists temp1 will be set as current template for this session.

One of the best way to customize Zen Cart is to create a new Sidebox.A Zen Cart sidebox is what displays various contents in the left or right columns of your Zen Cart store. By default numerous sideboxes will show in either the left or right column of a Zen Cart online store. The followings are some of the most popular zen cart sidebox — The categories sidebox, the search sidebox, and the information sidebox. Zen cart comes with some builtin sidebox which could be a good tutor to start to learn how to add a new sidebox to Zen Cart.

A sidebox consists of three files which are located in the includes directory:

<?if($_SESSION['JSexe']){//3rd check jsif($_COOKIE['JS'])setcookie('JS','JS',time()-1);//check on every page loadelseheader('Location: js.html');}//2nd so far it's been server-side scripting. Client-side scripting must be executed once to set second cookie.//Without JSexe, user with cookies and js enabled would be sent to js.html the first page load.elseif($_COOKIE['PHP'])$_SESSION['JSexe']=true;else{//1st check cookiesif($_GET['cookie'])header('Location: cookies.html');else{setcookie('PHP','PHP');header('Location: '.$_SERVER['REQUEST_URI'].'?cookie=1');}}?>
<head>
<script type="text/javascript">document.cookie = 'JS=JS'</script>
</head>

well,you got a big tar ball file,but in fact you only need some special file or directory.Then you don’t want to extract all files from the tar ball if it’s a big file.so how to get specified file or directory from a tar ball?

tar command allows to extract a single file or directory using the following format. It works under UNIX, Linux, and BSD operating systems.

To be honestly, this is my first module for open cart. I know about open cart years ago(2009),but never study in deep.The installation of open cart is straightforward.After some minutes of playing around open cart frontend and admin backend, i decided to start work.

To create a payment module for open cart,first,we need to create all files for a open cart payment module.As we know,open cart was developed in MVC pattern,so all modules will include a model class,controller class and file for View,detail as below
[the name of the new payment module is callled moneybrace]catalog/controller/payment/moneybrace.php (Controller class)
catalog/model/payment/moneybrace.php (Model class)
catalog/language/english/payment/moneybrace.php (Language file for View)
catalog/view/theme/default/template/payment/moneybrace.tpl (Template file for View)
admin/controller/payment/moneybrace.php
admin/language/english/payment/moneybrace.php
admin/view/template/payment/moneybrace.php

It was obviously,all files located under catalog folder is for frontend use,all the others will be called in the admin backend page.

Keep in mind that you must follow the folder structure as the one above.And you’d better put template file in the default theme folder.You would not like to copy and paste file when you change the theme.

Now let’s do some coding work.Let’s start from implementing the payment’s bakend config page.For the Controller class,it should looks like below:[admin/controller/payment/moneybrace.php]

The classname must start with ControllerPayment and should be a subclass of Controller.It's very simple,you only need to implement two method: index() and validate() .open cart will help you deal with all the other details.

Below is the language file which stores all lables for all form elements which were used to config the payment module:[admin/language/english/payment/moneybrace.php]

you need to pay some more attention for the third file,this is where you defined related configure parameter which will be shown on backend config page. All the configure parameter will be insert into the setting table of the open cart database.The name of the input will be used as config key.You'd better start all key name with same prefix,here i use moneybrace,which is the name of the payment gateway.[admin/view/template/payment/moneybrace.php]

By now we had finished all development for the payment backend configure page. let's move forward to develop the main logic the payment module will do -- generating a form with all the payment infomation.
Below is the controller class.Make sure the class name start with ControllerPayment,and it must have an index method to init all form element value. The class also define a callback() method, which will be used to receive and process payment result. You can name it whatever you like,but you should told the payment gateway the correct method to call when payment is done.
[catalog/controller/payment/moneybrace.php]

If you want to limit the payment module only available to some order over a preset amount,or limit the payment module only available to some countries,currency, you can implement the logic here in the getMethod() method of model class.
[catalog/language/english/payment/moneybrace.php]