Dear developer,

Joomla! is not only the best CMS because of its core team; Joomla! is empowered by all the third-party extensions, professional or not, which add so many functionalities to any website.
We decided to open HikaShop to any addition using a the powerful Joomla Plugin system.

 

 

Introduction

HikaShop uses the Joomla Plugin system to handle its payment and shipping system. It also use it to handle other plugins. So there are three plugin groups defined for hikashop (hikashop, hikashoppayment and hikashopshipping). We will first talk about the API common to all of them and then the specific API for shipping and payment plugins.

So the first thing you have to do is to create a standard Joomla plugin. The group will be "hikashop" unless you create a payment or shipping plugin in which case it will respectively be "hikashoppayment" or "hikashopshipping". Then, you can install it on Joomla.
We recommend that you first learn how to create Joomla plugins before starting to create HikaShop plugins since HikaShop plugins are actually Joomla plugins: http://docs.joomla.org/Portal:Plugin_Development

How to create a HikaShop plugin

When you create a plugin for HikaShop, you have to extends your plugin from JPlugin.
In the plugin, create the functions with the name of the triggers.
Here you can see an example using two triggers: onBeforeOrderCreate and onAfterOrderCreate.

class plgHikashopName extends JPlugin {
	function plgHikashopName(&$subject, $config){
		parent::__construct($subject, $config);
	}

	// Call a trigger, in this example: onBeforeOrderCreate
	function onBeforeOrderCreate(&$order,&$send_email) {
		// Actions to do when my trigger is called
	}

	// Another trigger
	function onAfterOrderCreate(&$order) {
		// Actions to do when my trigger is called
	}
}



All the triggers have different parameters, you can find all our triggers below. Marc Studer also developed a nice plugin to help developers see what HikaShop trigger is used where on your website and you can find it here: https://github.com/garstud/hikashop_dump_events

How to create a HikaShop Payment plugin

First, I invite you read the information on the payment API below.

Then, download the Example payment plugin, unzip it and look at the files in it. Each line of the plugin is documented, presenting how a payment plugin should be created. It's a good base if you're a developer but never did any payment gateway integration before. You can also look at the other payment plugins we already developed, and which are included in HikaShop, by going in the folder plugins/hikashoppayment/ of your website.

Order API

We recommend you to have a look at the HikaShop history plugin, this HikaShop plugin, located on joomla/plugins/hikashop/history/history.php, is one of the easiest to understand the HikaShop plugin structure for a plugin.

You can use these functions:

Functions are called if they exist, you don't have to define them all.
The first 6functions are triggered by HikaShop when an order is save or deleted. The cron task is only available on commercial versions of HikaShop and this last function will only be triggered once you created your HikaShop cron task via the interface in the configuration page.

onBeforeOrderCreate(&$order,&$do)

This function will be triggered by HikaShop before a new order is saved. You will get the full order information in the $order object with loads of information enabling you to know everything about the order. The $do variable can be set to false in case you want to cancel the save of the order.

 

onBeforeOrderUpdate(&$order,&$do)

This function will be triggered by HikaShop before an order is updated. You will get in the $order object the information which is updated for the order. The $do variable can be set to false in case you want to cancel the save of the order.

 

onAfterOrderCreate(&$order,&$send_email)

This function will be triggered by HikaShop after an order is created. You will get the full order information in the $order object with loads of information enabling you to know everything about the order. The $send_email variable can be set to true/false in case you want to allow/disallow the email notification to the customer.

 

onAfterOrderConfirm(&$order,&$methods,$method_id)

 

This method will be called by HikaShop when the order is created at the end of the checkout. You might want to do some processing here. If you are developping a payment gateway plugin, you might want to redirect the customer to the gateway payment page. In the information sent to it, you will probably be able to specify a notification url. You might want to use a url like this: http://yourwebsite.com/index.php?option=com_hikashop&ctrl=checkout&task=notify&notif_payment=PAYMENT_PLUGIN_NAME&tmpl=component&lang=CURRENT_LANG_CODE where PAYMENT_PLUGIN_NAME and yourwebsite.com need to be replaced by your information. That will allow you to have the function onPaymentNotification of your plugin being triggered when hikashop receives a notification. Also, we highly recommend to add the lang parameter and replace CURRENT_LANG_CODE with the current 2 letter code of the current language so that the "status changed" email going to the user will be translated in the user's language.

We invite you to look at the paypal payment plugin for an example of implementation

 

 

onAfterOrderUpdate(&$order,&$send_email)

This function will be triggered by HikaShop after an order is updated. You will get in the $order object the information which is updated for the order. The $send_email variable can be set to true/false in case you want to allow/disallow the email notification to the customer.

 

onAfterOrderDelete($elements)

This function will be triggered by HikaShop after an order is deleted. You will get an id or an array of ids.

 

onHistoryDisplay(&$history)

This function will be triggered by HikaShop when the history of the order is displayed. You can use it to override the display of the history of an order.

 

onBeforeOrderExport(&$rows,&$this)

This function will be triggered by HikaShop before exporting the orders. $rows is an array of all the orders.

 

Product API

This API will enable you to write plugins in order to do some actions when products are created/updated/deleted or displayed

You can use these functions:

onBeforeProductCreate(&$element,&$do)

This function will be triggered by HikaShop before a product is created. The $element variable will be an object with the product information as attributes of the object. By setting the $do variable to false, you can cancel the creation of the product

 

onAfterProductCreate(&$element)

This function will be triggered by HikaShop after a product is created successfully. The $element variable will be an object with the product information as attributes of the object including the product_id

 

onBeforeProductUpdate(&$element,&$do)

This function will be triggered by HikaShop before a product is updated. The $element variable will be an object with the new product information as attributes of the object as well as the product_id. By setting the $do variable to false, you can cancel the update of the product

 

onAfterProductUpdate(&$element)

This function will be triggered by HikaShop after a product is updated successfully. The $element variable will be an object with the new product information as attributes of the object including the product_id

 

onBeforeProductDelete(&$ids,&$do)

This function will be triggered by HikaShop before one or several products are deleted. The $ids variable will be an array of product ids. By setting the $do variable to false, you can cancel the deletion of the products

 

onAfterProductDelete(&$ids)

This function will be triggered by HikaShop after one or several products are deleted successfully. The $ids variable will be an array of product ids.

 

onBeforeProductListingLoad(&$filters,&$order,&$parent, &$select, &$select2, &$a, &$b, &$on)

This function will be triggered by HikaShop the products are loaded in order to be displayed on products listings on the front end. The $filters variable will be an array of conditions which will then be combined in order to form the MySQL query which will be used to load the products. That can enable you to change the way the products are loaded on your website listings by adding or removing conditions on that query.
And you can also potentially add a left join by appending it at the end of the $on variable like that:
$on .= 'LEFT JOIN #__hikashop_price AS p ON b.product_id=p.price_product_id';
And then change the $order variable to use the p.price_value field so that the products get ordered by price.

 

onBeforeProductCopy(&$template,&$product,&$do)

This function will be triggered by HikaShop before copying a product. With this trigger, you can change the template of the product, and change the product's values in the object $product. $do can be set to false to cancel the copy.


onAfterProductCopy(&$template,&$product)

This function will be triggered by HikaShop after a product copy. You can retrieve the product data in the object $product.

onBeforeProductExport((&$products,&$categories,&$this)

This function will be triggered by HikaShop before exporting products. You can find the products in the object $products, the categories in the object $categories. You can add or remove data or echo yourself the data before existing so that you can generate your own export format.

 

Category API

This API will enable you to write plugins in order to do some actions when categories are created/updated/deleted or displayed

You can use these functions:

onBeforeCategoryCreate(&$element,&$do)

This function will be triggered by HikaShop before a category is created. The $element variable will be an object with the category information as attributes of the object. By setting the $do variable to false, you can cancel the creation of the category

 

onAfterCategoryCreate(&$element)

This function will be triggered by HikaShop after a category is created successfully. The $element variable will be an object with the category information as attributes of the object including the category_id

 

onBeforeCategoryUpdate(&$element,&$do)

This function will be triggered by HikaShop before a category is updated. The $element variable will be an object with the new category information as attributes of the object as well as the category_id. By setting the $do variable to false, you can cancel the update of the category

 

onAfterCategoryUpdate(&$element)

This function will be triggered by HikaShop after a category is updated successfully. The $element variable will be an object with the new category information as attributes of the object including the category_id

 

onBeforeCategoryDelete(&$ids,&$do)

This function will be triggered by HikaShop before one or several categories are deleted. The $ids variable will be an array of category ids. By setting the $do variable to false, you can cancel the deletion of the categories

 

onAfterCategoryDelete(&$ids)

This function will be triggered by HikaShop after one or several categories are deleted successfully. The $ids variable will be an array of category ids.

 

onBeforeCategoryListingLoad(&$filters)

This function will be triggered by HikaShop the categories are loaded in order to be displayed on categories listings on the front end and back end. The $filters variable will be an array of conditions which will then be combined in order to form the MySQL query which will be used to load the categories. That can enable you to change the way the categories are loaded on your website listings by adding or removing conditions on that query.

Address API

You can use these functions:

onBeforeAddressCreate(&$element,&$do)

This function will be triggered by HikaShop before an address is created. The $element variable will be an object with the address information as attributes of the object. By setting the $do variable to false, you can cancel the creation of the address

 

onBeforeAddressUpdate(&$element,&$do)

This function will be triggered by HikaShop before an address information is updated. The $element variable will be an object with the new address information as attributes of the object. By setting the $do variable to false, you can cancel the update of the address

 

onAfterAddressCreate(&$element)

This function will be triggered by HikaShop after an address is created. The $element variable will be an object with the address information as attributes of the object.

 

onAfterAddressUpdate(&$element,&$do)

This function will be triggered by HikaShop after an address is updated. The $element variable will be an object with the address information as attributes of the object.

 

onBeforeAddressDelete(&$id,&$do)

This function will be triggered by HikaShop before one address is deleted. The $id variable will be an address id (integer). By setting the $do variable to false, you can cancel the deletion of the address

 

onAfterAddressDelete(&$id)

This function will be triggered by HikaShop after an address is deleted successfully. The $id variable will be an address id (integer).

 

 

Shipping API

You can use these functions:

onShippingDisplay(&$order,&$methods,&$usable_methods,&$messages)

This method will be called by HikaShop when it is displaying the shipping layout of the checkout process. There, it wants to display a list of possibe shipping options and asks the shipping plugins what are the possibilities for the current order information. In the $methods array, you will get all the methods found by the system which are published. You will first need to filter the $methods so that your plugin only work on your plugin method(s). Based on the restrictions set by the administrators on your method(s) and on the $order information you will have to decide whether or not your method(s) can be added to the $usable_methods array and add it/them.

Suppose that you are making a shipping plugin for a shipping service like UPS. Here, you would first filter your method options out of the $methods array. Then, connect to the UPS web service to decide, based on the $order information, what shipping methods are possible, and finally add then to the $usable_methods.

You can add error messages to the $messages in case no shipping methods were found.

 

onShippingSave(&$order,&$methods,&$shipping_id)

 

This method will be called by HikaShop after the customer selected a shipping method for his order during the checkout process. There, it needs the shipping plugin to check whether the method selected is possible for the order. In the $methods array, you will get all the methods found by the system which are published. You will first need to filter the $methods so that your plugin only work on the method selected by the customer. Based on the restrictions set by the administrators on your method(s) and on the $order information you will have to decide whether or not this method is possible and return true or false to allow or disallow it.

Suppose that you are making a shipping plugin for a shipping service like UPS. Here, you would first filter your method options out of the $methods array. Then, you could get the list of usable methods that you would have cached in the session in the function onShippingDisplay and see if the selected method is in them.

 

onShippingConfiguration(&$element)

 

This method will be called by HikaShop on the backend shipping method configuration page. You can set here some variables which will then be available in a view file of the plugin so that you can display additional configuraiton fields to the plugin. We invite you to look at the manual shipping plugin function as well as the manual_configuration_edit.php file. If you don't need any option for your plugin, you can leave this function empty.

 

onShippingConfigurationSave(&$element)

 

This method will be called by HikaShop on the backend when the shipping method configuration is saved. In most cases, you won't have to use this function.

 

 

shippingMethods(&$method)

 

This method will be called by HikaShop when a dropdown of shipping methods will be displayed like in the payment plugins' "shipping methods" option or the order details of the back end. It will give you an object with your method information and you will have to return an array like that:

return array('ID1'=>'Name 1','ID2'=>'Name 2');

You can look at the UPS shipping plugin for an example of implementation.

 

onAfterProcessShippings(&$usable_methods)

 

This method is not necessary for standard shipping plugin. It is called by HikaShop after the usable shipping methods have been determined, after the onShippingDisplay call to all ht eshipping methods. It allows you to reprocess them if you need to do some extra modifications once you know the available shipping methods for the current cart. For example, it's used by the TaxCloud plugin in order to calculate dynamically the tax on the shipping fees.

 

 

Payment API

You can use 6 functions:

onPaymentDisplay(&$order,&$methods,&$usable_methods)

This method will be called by HikaShop when it is displaying the payment layout of the checkout process. There, it wants to display a list of possibe payment options and asks the payment plugins what are the possibilities for the current order information. In the $methods array, you will get all the methods found by the system which are published. You will first need to filter the $methods so that your plugin only work on your plugin method(s). Based on the restrictions set by the administrators on your method(s) and on the $order information you will have to decide whether or not your method(s) can be added to the $usable_methods array and add it/them.

 

onPaymentSave(&$order,&$methods,&$payment_id)

 

This method will be called by HikaShop after the customer selected a payment method for his order during the checkout process. There, it needs the payment plugin to check whether the method selected is possible for the order. In the $methods array, you will get all the methods found by the system which are published. You will first need to filter the $methods so that your plugin only work on the method selected by the customer. Based on the restrictions set by the administrators on your method(s) and on the $order information you will have to decide whether or not this method is possible and return true or false to allow or disallow it.

 

onPaymentConfiguration(&$element)

 

This method will be called by HikaShop on the backend payment method configuration page. You can set here some variables which will then be available in a view file of the plugin so that you can display additional configuraiton fields to the plugin. We invite you to look at the paypal payment plugin function as well as the paypal_configuration.php file. If you don't need any option for your plugin, you can leave this function empty.

 

onPaymentConfigurationSave(&$element)

 

This method will be called by HikaShop on the backend when the payment method configuration is saved. In most cases, you won't have to use this function.

 

onAfterOrderConfirm(&$order,&$methods,$method_id)

 

This method will be called by HikaShop when the order payment is confirmed. You might want to do some processing here. If you are developping a payment gateway plugin, you might want to redirect the customer to the gateway payment page. In the information sent to it, you will probably be able to specify a notification url. You might want to use a url like this: http://yourwebsite.com/index.php?option=com_hikashop&ctrl=checkout&task=notify¬if_payment=PAYMENT_PLUGIN_NAME&tmpl=component&lang=CURRENT_LANG_CODE where PAYMENT_PLUGIN_NAME and yourwebsite.com need to be replaced by your information. That will allow you to have the function onPaymentNotification of your plugin being triggered when hikashop receives a notification. Also, we highly recommend to add the lang parameter and replace CURRENT_LANG_CODE with the current 2 letter code of the current language so that the "status changed" email going to the user will be translated in the user's language.

We invite you to look at the paypal payment plugin for an example of implementation

 

onPaymentNotification(&$statuses)

This method will be called by HikaShop when a payment notification is received for your plugin. Here you will have to make sure that the notification is securized and then you will be able to update the order based on the payment information.

The $statuses array will contain the statuses with, as key the status name and as value the appropriate translation.

The notification URL to use for that function to be triggered in your plugin will have to be like this: http://yourwebsite.com/index.php?option=com_hikashop&ctrl=checkout&task=notify&notif_payment=PAYMENT_PLUGIN_NAME&tmpl=component&lang=CURRENT_LANG_CODE where PAYMENT_PLUGIN_NAME and yourwebsite.com need to be replaced by your information. Also, we highly recommend to add the lang parameter and replace CURRENT_LANG_CODE with the current 2 letter code of the current language so that the "status changed" email going to the user will be translated in the user's language.

We invite you to look at the paypal payment plugin for an example of implementation

 

Vote API

 

onBeforeVoteCreate(&$element,&$do)

This method will be called by HikaShop before a vote is created, $element is an object, you can edit the information of this object before the save of the vote. $do allow you to cancel the save if you change its value to false.

 

onAfterVoteCreate(&$element)

This method will be called by HikaShop after a vote is created, $element is an object, you can execute an action after the save of the vote.


onBeforeVoteUpdate(&$element,&$do)

This method will be called by HikaShop before a vote is updated, $element is an object, you can edit the information of this object before the save of the vote. $do allow you to cancel the save if you change its value to false.


onAfterVoteUpdate(&$element)

This method will be called by HikaShop after a vote is updated, $element is an object, you can execute an action after the save of the vote.


onBeforeVoteDelete(&$element,&$do)

This method will be called by HikaShop before a vote is deleted, $element is an object, you can edit the information of this object before the vote is removed. $do allow you to not remove the vote if you change its value to false.


onAfterVoteDelete(&$element)

This method will be called by HikaShop after a vote is deleted, $element is an object, you can execute an action after the save of the vote.

 

Cart API

 

onBeforeCartUpdate(&$cartClass,&$cart,$product_id,$quantity,$add,$type,$resetCartWhenUpdate,$force,&$do) DEPRECATED use onBeforeCartSave instead

This method will be called by HikaShop before the cart is updated, the object $cartClass is the instance of the cart class which calls that trigger, $cart has the existing or the new cart information, $product_id is a variable with the id of the product added in the cart.
$quantity is the quantity of the product to add to the cart, the $add variable says whether the quantity replaces the quantity of the product already in the cart or is added to it, and finally, $type is a variable containing the type of the item to update generally 'product'

onBeforeCartSave(&$element,&$do)

This method will be called by HikaShop before the cart is saved, when a product is added, removed, modified, when a shipping or payment method is selected, etc. In the object $element, you can have an attribute cart_products which is an array of products to be added/modified. You can use the variable $do to cancel the save.

onAfterCartUpdate(&$cartClass,&$cart,$product_id,$quantity,$add,$type,$resetCartWhenUpdate,$force) DEPRECATED use onAfterCartSave instead

This method will be called by HikaShop after the cart is updated, the object $cartClass is the instance of the cart class which calls that trigger, $cart has the existing or the new cart information, $product_id is a variable with the id of the product added in the cart.
$quantity is the quantity of the product to add to the cart, the $add variable says whether the quantity replaces the quantity of the product already in the cart or is added to it, and finally, $type is a variable containing the type of the item to update generally 'product'

onAfterCartSave(&$element)

This method will be called by HikaShop after the cart is saved, when a product is added, removed, modified, when a shipping or payment method is selected, etc. In the object $element, you can have an attribute cart_products which is an array of products which were added/modified.

onAfterCartProductsLoad(&$cart)

This function will be triggered by HikaShop after the cart products are loaded. The object $cart contain all the cart data that is already loaded at that point.

onAfterCartShippingLoad(&$cart)

This function will be triggered by HikaShop after loading the shipping for the current cart. $cart contain all the cart datathat is already loaded at that point.

 

 

Checkout API

 

onCheckoutStepList(&$list)

This method will be called by HikaShop on the configuration page. The $list parameter is an empty array by default where you can add your own views for the checkout workflow so that you can have your own new step on the checkout.
You will need to use such code for that: $list['plg.shop.viewname'] = 'Name of my view for the user';
Thanks to that the user will be able to place your new view in the checkout workflow option of the configuration.

onBeforeCheckoutStep($controller, &$go_back, $original_go_back, &$controller)

Before your checkout view is displayed on the checkout, this function will be called by HikaShop. It allows you to add custom checks to your view in order to authorize the checkout to display your step only if the necessary conditions are met. For example, if your step requires the user to be logged in, you can add such check here and set the $go_back parameter to true if the user is not logged in.
The $original_go_back tells you on which step number the user was before going to the step of your view.
You should check the $controllerName parameter in order to add your check only for your checkout view and not others unless you want to specifically integrate with other views (not recommended).
Finally, the $controller parameter is the whole controller object. You'll find in it all the methods for the before/after check of the default views of HikaShop and some potentially useful attributes/methods...

onAfterCheckoutStep($controller, &$go_back, $original_go_back, &$controller)

After your checkout view is displayed on the checkout and that the user clicks on the "next" button, this function will be called by HikaShop. It allows you to add custom checks to your view in order to authorize the checkout to continue if the user filled what you want in your view or to do some processing with what the user did on your view. For example, if your step requires the user to fill a textarea, you can save the content of the textarea here and set the $go_back parameter to true if the user didn't enter something in it.
The $original_go_back tells you on which step number the user was for the display of your view.
You should check the $controllerName parameter in order to add your code only for your checkout view and not others unless you want to specifically integrate with other views (not recommended).
Finally, the $controller parameter is the whole controller object. You'll find in it all the methods for the before/after check of the default views of HikaShop and some potentially useful attributes/methods...

onCheckoutStepDisplay($layoutName, &$html, &$view)

This is where you can add the HTML of your view. you can either directly echo it or add it in the $html parameter and it will display on the checkout page at the place designed by the checkout workflow option.
You should check the $layoutName parameter in order to add your code only for your checkout view and not others unless you want to specifically integrate with other views (not recommended).
Finally, the $view parameter is the whole view object. You'll find in it all the methods for the loading of the default views data of HikaShop and some potentially useful attributes/methods...

onCheckoutWorkflowLoad(&$checkout_workflow, &$shop_closed, $cart_id)

This method will be called by HikaShop after the checkout workflow has been loaded. So it's the perfect place if you want to dynamically change the checkout workflow or if you want to close the checkout based on custom conditions.
The $checkout_workflow variable is an array. It contains a sub array with the key "steps". That sub array has a key "content" which has an array with an element with a key "task" with the name of the view ("login" or "address" for example).
The $shop_closed parameter is a boolean which allows you deactivate the checkout.
And $cart_id contains the id of the cart, in case you need to load it.

 

 

Display API

onDisplayImport(&$importData)

This function will be triggered by HikaShop when displaying the import interface. $importData is an array with the data for each tab.

onProductFormDisplay(&$element,&$html)

This function will be triggered by HikaShop when displaying the product form.

onProductDisplay(&$element,&$html)

This function will be triggered by HikaShop when displaying a product edition page.

onProductBlocksDisplay(&$element,&$html)

This function will be triggered by HikaShop when displaying the blocks of the product.

onAfterOrderProductsListingDisplay(&$order,$mail)

This function will be triggered by HikaShop after displaying the listing of the products present in an order. $order is an object with the data of the order.

onHikashopBeforeDisplayView(&$view)

This function will be triggered by HikaShop before displaying a view. $view is the instance of the view.

onHikashopAfterDisplayView(&$view)

This function will be triggered by HikaShop after displaying a view.

 

Coupon API

onBeforeCouponLoad(&$coupon,&$do)

This function will be triggered by HikaShop before loading a coupon. You can edit the $coupon object to change its values. If you set $do to false, you can cancel the loading of the coupon.

onBeforeCouponCheck(&$coupon,&$total,&$zones,&$products,&$display_error,&$error_message,&$do)

This function will be triggered by HikaShop before checking the coupon, with the object $coupon you can edit its values. $total contains the total price object, $zones contains the current zones and $products contains all the products data in the cart. You can set the $display_error variable to false if you don't want any error to be displayed and you can enter an error message in the $error_message variable. Finally, you can set $do to false to cancel the check and use the coupon as is provided that you keep $error_message empty.

onAfterCouponCheck(&$coupon,&$total,&$zones,&$products,&$display_error,&$error_message,&$do)

This function will be triggered by HikaShop after a coupon is checked, and before it is processed. you can find the same variables as the trigger "onBeforeCouponCheck".

 

Discount API

onBeforeDiscountCreate( &$discount, & $do)

This function will be triggered by HikaShop before a discount/coupon is created. $discount is an object with all the data about the discount/coupon. $do can cancel the creation of the discount/coupon if set to false.

onBeforeDiscountUpdate( &$discount, & $do)

This function will be triggered by HikaShop before a discount/coupon is updated . $discount is an object with all the data about the discount/coupon. $do can cancel the update of the discount/coupon if set to false.

onAfterDiscountCreate( &$discount)

This function will be triggered by HikaShop after a discount/coupon is created, $discount is the object with the discount/coupon data.

onAfterDiscountUpdate( &$discount)

This function will be triggered by HikaShop after a discount/coupon is updated, $discount is the object with the discount/coupon data.

onBeforeDiscountDelete( & $elements, & $do)

This function will be triggered by HikaShop before discounts/coupons are deleted. $elements is an array with a list of discount/coupon ids. $do can cancel the delete of the discounts/coupons if set to false.

onAfterDiscountDelete( & $elements )

This function will be triggered by HikaShop after discounts/coupons are deleted, $elements is an array with a list of discount/coupon ids.

 

User API

onBeforeUserCreate(&$element,&$do)

This function will be triggered by HikaShop before a user is created. $element contain the data about the user, you can change some of the information before his creation. $do allows you to cancel the creation if you set it to false.

onBeforeUserUpdate(&$element,&$do)

This function will be triggered by HikaShop before a user is updated. $element contain the data about the user, you can change some of the information before his update. $do allows you to cancel the update if you set it to false.

onAfterUserCreate(&$element)

This function will be triggered by HikaShop after a user is created, $element is an object with all the data about the user.

onAfterUserUpdate(&$element)

This function will be triggered by HikaShop after a user is updated, $element is an object with all the data about the user.

onBeforeUserDelete(&$elements,&$do)

This function will be triggered by HikaShop before users are deleted, $elements is an array with a list of user ids. If you set $do to false, you can cancel the deletion of the users.

onAfterUserDelete($elements)

This function will be triggered by HikaShop after a user is deleted, $elements is an array with a list of user ids.

onUserAccountDisplay(&$buttons)

This function will be triggered by HikaShop when displaying a user control panel. $buttons is an array with the buttons to be displayed on the user control panel. You can add or remove some buttons.

 

Filter API

onFilterDisplay(&$filter,&$html,&$divName,&$parent,&$datas)

This function will be triggered by HikaShop when filters are displayed when the type of the filter is not one of the standard ones. $filter is an object with the data of the filter and you need to put your HTML in the $html variable. (since HikaShop 2.1.1)

onFilterAdd(&$filter,&$filters,&$select,&$select2,&$a,&$b,&$on,&$order,&$divName,&$parent)

This function will be triggered by HikaShop when processing the filters when the type of the filter is not one of the standard ones. That allows you to modify the query loading the products on the current listing. (since HikaShop 2.1.1)

onFilterToLoad(&$filter,&$html,&$divName,&$parent)

This function will be triggered by HikaShop when loading the possible values of the filters when the type of the filter is not one of the standard ones.

onFilterTypeDisplay(&$allValues)

This function will be triggered by HikaShop when displaying the type of the filters. That allows you to add new types of filters via plugins by adding it in the $allValues array.

 

Fields API

onFieldDateDisplay($field_namekey,$field,&$value,&$map,&$format,&$size)

This function will be triggered by HikaShop when displaying a field of the type "Date".

onFieldDateCheckSelect(&$values)

This function will be triggered by HikaShop when the field date is selected. $values contain the values of the date field.

onFieldsLoad(&$externalValues)

This function will be triggered by HikaShop when the fields are loaded.

 

Other triggers

onBeforeCalculateProductPriceForQuantityInOrder(&$products)

This function will be triggered by HikaShop before calculating the product price for the quantity in the order. $products is an object with all the data about the products in the order.

onAfterCalculateProductPriceForQuantityInOrder(&$products)

This function will be triggered by HikaShop after calculating the product price for the quantity in the order. $products is an object with all the data about the products in the order.

onBeforeCalculateProductPriceForQuantity(&$product)

This function will be triggered by HikaShop before calculating the product price for the quantity. $product is the object with all the data about the product.

onAfterCalculateProductPriceForQuantity(&$product)

This function will be triggered by HikaShop after calculating the product price for the quantity. $product is the object with all the data about the product.


onBeforeDownloadFile(&$filename,&$do,&$file)

This function will be triggered by HikaShop before a file download. $filename is the path to the file, you can change it's value. $do allows you to cancel the download if you set it to false, and $file is an object containing the information about the file.


onBeforeMailPrepare(&$mail,&$mailer,&$do)

This function will be triggered by HikaShop before preparing a mail, you can change the data of the mail with the object $mail, change the sender, the subject, etc. $mailer is the Joomla mailer instance which will be used to send the email. $do allows you to cancel the mail if set to false.

onBeforeMailSend(&$mail,&$mailer)

This function will be triggered by HikaShop before sending a mail. $mail is an object with all the data about the mail, subject, body, sender, ... $mailer is the Joomla mailer instance which will be used to send the email.

onMailListing(&$plugin_files)

This function is triggered by HikaShop to allow third party plugins of the group "hikashop" to add their own emails to the listing of emails of HikaShop. That way, merchants can manage the emails via the menu System>Emails. $plugins_files is by default an empty array. The plugins have to add to it arrays containing several keys. Here is an example for HikaMarket :

  • file : The code of the email used in the file name prefixed with the third party extension. For example: "market.order_status_notification"
  • folder : The folder where the email files are located. That parameter is optional. If not provided, HikaShop will look in the default folder /media/com_hikashop/mail. For example: "/var/www/myshop/media/com_hikamarket/mail"
  • filename : The code of the email used in the file name. For example: "order_status_notification"
  • name : The name of the email that will appear on the listing. For example: "Market: Order status notification"

onBeforeSendContactRequest(&$element,&$send)

This function will be triggered by HikaShop before a contact request is sent. $element contain the product data, and $send allows you to send or not the contact request.


onViewsListingFilter(&$pluginViews,$client_id)

This function will be triggered by HikaShop when the listing of views is displayed on the backend. It allows you to add view files to the listing. $client_id tells you if it's for the frontend, the backend or both.

onHikashopCronTrigger(&$resultsTrigger)

This function will be triggered by HikaShop when a cron task trigger is received. You can use this function to regularily do some processing. You can add messages to the $messages array. They will be added to the notification emails.

 

onHikashopBeforeCheckDB(&$createTable, &$custom_fields, &$structure, &$helper)

This function will be triggered by HikaShop when someone clicks on the "check database" button of the HikaShop configuration, before the checks are launched.
Implementing it in your plugins is useful if your plugin adds columns/tables to the database and you want to make sure that the columns/tables are still present.
You'll mainly want to add the SQL to create your tables in the array $createTable and the columns you need in the $structure array (it's better to add a var_dump of that variable to get the exact structure you need).

 

onHikashopAfterCheckDB(&$messages)

This function will be triggered by HikaShop when someone clicks on the "check database" button of the HikaShop configuration, after the checks are launched.
The $messages variable will contain all the success/error messages that will be displayed to the user. You can potentially modify them, add yours, etc

 

onCheckSubscription($subscription_level, &$infos)

This function will be triggered by HikaShop when checking the subscriptions. $subscription_level is the variable with the level of the subscription to check, you can change this value. $infos contains the information about the subscription.

 

Main objects

Here are the main objects to know in HikaShop. You can see all the objects parameters.

$order - create

$product

Template overrides

First, you can override any view defined in HikaShop by using the interface available via the menu Display->Views. The modifications you will make will be saved in your template and you won't loose them when you update HikaShop.

Second, you can also override some of the display functions within HikaShop. You will be able to override the display of images, etc:

For the images:

You need to create the file templates/YOUR_TEMPLATE/html/hikashop_image.php. We invite you to look at the file administrator/components/com_hikashop/helpers/image.php for the default code of the functions you will define in it. In that file, you will be able to define the functions:

hikashop_image_toggle_js(&$obj) => You can define here the javascript to handle the display of multiple images on the product pages.

hikashop_small_image_link_render(&$obj,$path,$addpopup,$optionslink,$html) =>That function displays the HTML code of the small thumbnails of the image display on the product page. This function is only called on the product page when there are several images for a product.

hikashop_image_link_render(&$obj,$path,$addpopup,$optionslink,$html) =>That function displays the HTML code of the big thumbnail of the image display on the product page.

 

For the characteristics:

You need to create the file templates/YOUR_TEMPLATE/html/hikashop_characteristics.php. We invite you to look at the file administrator/components/com_hikashop/type/characteristic.php for the default code of the function you will define in it. In that file, you will be able to define the function:

hikashop_characteristics_html(&$element,&$params,&$obj) => The $element variable will contain the whole product information from which you can extract the characteristics information and the params variable can help you get some parameters from the HikaShop configuration. The $obj variable will be the instance of the characteristic display class. That way, when you get the code from the characteristic.php file, you can just replace $this by $obj and it should work. You need to return the HTML of the characteristics selection at the end of your function.

 

For the quantity input:

You need to create the file templates/YOUR_TEMPLATE/html/hikashop_button.php. We invite you to look at the file administrator/components/com_hikashop/helpers/cart.php for the default code of the function you will define in it. In that file, you will be able to define the function:

hikashop_quantity_render($html,$i,$max_quantity,$min_quantity) => The $html variable will contain the HTML of the "add to cart" button, the $i variable will contain a unique int which will be different for each quantity input on the page, the $max_quantity and $min_quantity will contain the min and max quantity possible for the product. You need to return the whole HTML at the end of your function.

Also, please note that it only works if the option for "Display the quantity field on the product page" is set to "Ajax Input" in the configuration of HikaShop.

 

For the buttons:

You need to create the file templates/YOUR_TEMPLATE/html/hikashop_button.php. We invite you to look at the file administrator/components/com_hikashop/helpers/cart.php for the default code of the function you will define in it. In that file, you will be able to define the function:

hikashop_button_render($map,$name,$ajax,$options,$url) => The $map variable contains the name of the button, the $name variable contains the value of the button (what the user see). The $ajax variable can contains additional attributes for the HTML element of your button as well as the $options attribute. The $url variable can contain a URL where to redirect when the button is used as a link. You need to return the whole HTML of your buttons at the end of your function.

 

For the product quantity calculation:

That is useful when you have to calculate the price of goods based on additional paramaters than just the quantity. For example, if you sell your products by length or by m², you can create one or two custom fields of the table "item" via the menu Display->Custom fields so that they appear on your product pages and you will be able to use the value entered by users in the quantity price calculations. You need to create a joomla system plugin. We invite you to look at the files administrator/components/com_hikashop/classes/currency.php and administrator/components/com_hikashop/classes/order.php for the default code of the functions you will define in it. In that file, you will be able to define the functions:

hikashop_product_price_for_quantity_in_cart(&$product) => The $product variable will contain all the information of the product in the cart. You can look at the function calculateProductPriceForQuantity for more information on how that can be used to redefine the quantity calculation of products in the cart

hikashop_product_price_for_quantity_in_order(&$product) => The $product variable will contain all the information of the product in the order. You can look at the function loadFullOrder for more information on how that can be used to redefine the quantity calculation of products in the order

 

Overriding classes from the classes, helpers, types or controllers folders of the backend:

If you need to modify some code in a file of one of these folders, we would recommend instead to create an override of the file in your Joomla template.
You can do it by copying the file in administrator/components/com_hikashop/XXXX/yyy.php to templates/YOUR_TEMPLATE/html/com_hikashop/admnistrator/XXXX.yyy.override.php (for the frontend) or administrator/templates/YOUR_TEMPLATE/html/com_hikashop/admnistrator/XXXX.yyy.override.php (for the backend) and then changing the class name in that file to add Override at the end of the class name. That way, you can have your override file actually include the core file of HikaShop and your override class extend on the original class so that you only override the methods and attributes of the class that you need to instead of using completely your customized file.

 

Database Structure

Here is a database structure diagram for HikaShop 2.5.0:

database

You can download here a mwb file of that schema in order to visualize it in MySQL Workbench.

Code samples

When you use the code samples described in this part of the documentation, you first need to include the line below before them in order to load the HikaShop main files :

if(!@include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')){ return false; }

 

 

If you want to load a product from the database, you can do like that :

$productClass = hikashop_get('class.product');

$product=$productClass->get($product_id);

 

 

If you want to add a HikaShop product to the cart, you can use the code :

$cartClass = hikashop_get('class.cart');

$cartClass->update($product_id,$quantity);

 

 

If you want to load the current cart data, you can use the code :

$cartClass = hikashop_get('class.cart');

$cart = $cartClass->loadFullCart();

The products in the cart will be available in the attribute as an array of product objects:

$cart->products

 

If you want to load the whole information of an order, you can use the code :

$orderClass = hikashop_get('class.order');

$order = $orderClass->loadFullOrder($order_id, true, false);

Similarly to the cart, the products will be available in the attribute as an array of product objects:

$order->products

 

If you want to create a new order, you can use such code:

$order = new stdClass();

$order->order_full_price = 100;

$order->order_currency_id = 1;

$order->order_user_id = 64;

...etc...

$product = new stdClass();

$product->order_product_quantity = 1;

$product->order_product_price = 100;

...etc...

$order->products = array($product);

$orderClass = hikashop_get('class.order');

$orderClass->save($order);