<img src="abc.png" />
    
call to replace anchor tags contains '/admin' in href

Hooks

Available in Enterprise Plan and above.

Hooks are useful functions/codes that execute before or after a specific event happens on a store. For example, after a new customer created, before the products list or reviews listing, etc.

Adding Hooks

To add a hook in your store, go to AdvanceSettings > Hooks section in StoreHippo Admin Panel. Click on Add New and provide details in the following fields:

Entity

Enter the entity name on which the user wants to execute hooks. For example, ms.orders, ms.products, etc.

Command

Enter the entity command on which user wants to execute hooks. For example, list, add and many more.

Mode

Choose the mode of hooks. Following are the two modes:

1. Prehooks

Prehooks are function/code that is executed before the command handler. Prehooks are executed in order of priority. Highest priority prehooks executed first and so on.

Example: If you want to list only published products, the write a prehook on list command of products entity:

function (req, res, next) {
    if (!req.query) {
        req.query = {}
    }
    if (!req.query.filters) {
        req.query.filters = [];
    }
    req.query.filters.push({field: 'publish', value: '1', operator: 'equal'});
    next();
}

2. Posthooks

Posthooksare executed after the command handler.Posthooksare executed in order of priority like prehooks. Highest priority prehooks executed first and so on.

Example: If you want to send a welcome msg to the user after registration, then write aposthookon add command of the user entity.

function (req, res, next) {
    // code to send sms 
    next();
}

Action

Select the action that you want to perform.

Send Mail

Send mail notifications to the customer if a user selects this action.

Settings

  • Mailer: Select the mail template which user wants to send on the execution of this hook.
  • To: Provide email id of the recipient user. This field also supports the handlebar.
  • Attachment Field: User can provide URL or field name in which file is stored.

Execute Handlers

Handler: User can add custom code that will execute before or after command execution according to the mode.

Priority

If multiple hooks are added on a single entity command than this field decides the priority of execution.

Description

Enter the description of the hook.