redSHOP:Product Plugin

From redWIKI
Jump to: navigation, search

Contents

Example joomla Plugin for Product Page

To add more flexibility into Product Page (or other page of redSHOP later) you can create a redSHOP plugin of joomla for product template.

Here we will list the Events available and their functionality.


List of Events:

1. onPrepareProduct:

This is the first stage in preparing product for output and is the most common point for product orientated plugins to do their work. New enhancement, Added some JavaScript override function to add/manage product when adding to cart. _Java-script functions for overrides:_ I function `directCartSubmit(frmCartName,product_id,relatedprd_id,giftcard_id,frmUserfieldName,totAttribute,totAccessory,totUserfield)` Function can be override when AJAX cart is set off. We can customize this function is our own way. Even redSHOP core functionality. II function `getExtraParams()` Function can be override when AJAX cart is on. We can add more parameters to send such variables. Even we can validate the add to cart. Main use of both the function is, we can send extra parameters into cart page.

2. onAfterDisplayProductTitle:

This is a request for information that should be placed between the product heading and the product body.

3. onBeforeDisplayProduct:

This is a request for information that should be placed immediately before the product template start.

4. onAfterDisplayProduct:

This is a request for information that should be placed immediately after the product template.

5. onBeforeProductSave:

This is an event that is called right before the product is saved into the database.

6. onAfterProductSave:

This is an event that is called after the product is saved into the database.

7. onSameCartProduct

This is an event that is called when same product is going to add into cart session. We can get access to add external variable into cart before cart session is set.

8. onBeforeSetCartSession

This is an event that is called when another product is going to add into cart session. We can get access to add external variable into cart before cart session is set.

9. onStartCartTemplateReplace

This is an event that is called when cart template replacement is started.

10. onCartItemDisplay

This is an event that is called in cart item loop. Plugin can add extra behaviour or tag into cart template using this event.

11. atEndCartTemplateReplace

This is an event that is called at the end of the cart template.

12. beforeOrderPlace

This is an event that is called before placing an order.

13. afterOrderPlace

This is an event that is called after placing an order.

14. afterOrderItemSave

This is an event that is called after order item saved into table. This event is called into order item loop.

15. onOrderItemDisplay

This is an event that is called into order detail page into order item loop (frontend).

16. toHighlightGrid

This is an event that is using into back-end order listing page. In to grid column, below checkbox. This event is called to add heightlighter from which order can be identified that plugin enhancment is included into this order.

17. onBackendOrderDetailFooter

This is an event that is called from back-end order detail view on Footer.

18. setProductCustomPrice

Method is trigger from the redSHOP product front-end helper from getProductNetPrice function to set custom price for product using plugin.

19. onReorderCartItem

Method is trigger from the redSHOP Order item loop to reorder or copy the same item in redSHOP cart.

   `@params`: `$itemData` is an array which will contain Order Item information for cart session.

20. onAjaxOrderStatusUpdate

Method will trigger from redSHOP Back-end Order Status button from Order listing page. It means, it will be called on AJAX Order Status Update batch.

   `@params`: `$data` - Is a `$_POST` array contains information of orders.

21. onBeforeImageLoad

This method will trigger when displayAdditionImage of product image.

   `@params`: `$get` - Will contains product image information like below.

   <?php
   $get['product_id']
   $get['main_imgwidth']    
   $get['main_imgheight']   
   $get['property_data']    
   $get['subproperty_data'] 
   $get['property_id']      
   $get['subproperty_id']

Add to cart button JavaScript Trigger

Now, it is easy to set JavaScript trigger function on add to cart button.

Create Trigger function in your plugin js file or you can use your existing js function

   var MyAddToCartTrigger = function(){
   console.log("Hello, from My trigger function");
   };

Register Trigger function from your plugin js file

   // Set Trigger for add to cart button
   redShopJsTrigger.push(MyAddToCartTrigger);

Create another trigger in another plugin js file

   var SecondAddToCartTrigger = function(){
       console.log("Hello, from Second trigger function");
   };

Register Second Trigger function from your plugin js file

   // Set Trigger for add to cart button
   redShopJsTrigger.push(SecondAddToCartTrigger);

Now, both function will be trigger on click of redSHOP add to cart button

How to use redSHOP Javascript Triggers

Create Trigger function in your plugin js file or you can use your existing js function

var onChangePropertyDropdown = function(allArg, selectedProperty){
    console.log(allArg);
    console.log(selectedProperty);
};

Register Trigger function from your plugin js file

// Set Trigger for add to cart button
redSHOP.onChangePropertyDropdown.push(onChangePropertyDropdown);
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox