Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Once AbanteCart page/response load starts (init.php), all enabled extensions are loaded. At this time system has created instances of all extensions classes that responsible for hooks processing.
Control passed to Action class which is trying to define controller and method based on route variable. It checks if first part of route is an extension name and if it is, tries to load it.
Controller is loaded, it's method is executed and it is ready to render template. System is looking for template file.

  • first it looks for an override file - it will be named as template.override.tpl - any extensions can override template file. But if several extensions tries to override one file, file from extension with higher priority will be used.
  • if override is not found it is looking for template.pre.tpl and template.post.tpl - their content added before and after original template - any extensions can use pre and post files. if several extensions contain pre or postfiles - they all will be rendered according to extension priority
  • at last it is looking for template.tpl


How to develop Extensions: Let us show how to develop extension based on the example that will apply discount on all products

Extension unique id name will be - discount

  • create directory ../extensions/discount
  • create config file ../extensions/discount/config.xml

At minimum we need to add following settings

  1. discount_status - enabled/disabled
  2. discount_percent - percent of discount 
  3. discount message - message that will be shown on cart page 
  4. discount message for every product - how much you save
<?xml version="1.0"?>
<extension>
   <id>discount</id>
   <version>0.1.0</version>
   <cartversions>
        <item>0.9</item>
        <item>1.0</item>
    </cartversions>
   <dependencies></dependencies>
   <phpmodules></phpmodules>
   <layout></layout>
   <priority>10</priority>
   <type>extensions</type>
   < category>discount</ category>
   <settings>
 <item id="discount_status">
            <type>checkbox</type>
            <default_value>0</default_value>
   	</item>
       <item id="discount_percent">
           <type>input</type>
           <default_value>10</default_value>
       </item>
       <item id="discount_message">
           <type>input</type>
           <default_value>We are pleased to annouce september discounts</default_value>
       </item>
       <item id="discount_product_message">
           <type>input</type>
           <default_value>Old price: %s, You save: %s</default_value>
       </item>
   </settings>
</extension>


  • No labels