Skip to main content

How to create custom behavior events

This feature allows you to add custom ways for customers to earn points.

  1. To create a new Custom behavior rule, go to Marketing -> Promotions -> Reward Points -> Settings -> Advanced Settings.
  2. In the Custom behavior events field, add a new rule in this format: rulecode, rulename. You can add multiple rules, each on a new line.
  3. Insert the following code in the place where points should be awarded:
$eventManager = $this->_objectManager->get('Magento\Framework\Event\ManagerInterface');
$eventManager->dispatch('mirasvit_rewards_behavior_rule_process', ['code' => 'rulecode', 'attr' => attribute]);

Example

For example, to create a rule for the event 'user name changed,' insert the following in the Custom behavior events field:
customer_change_name, Change customer name rule

Custom behavior event

Custom behavior event

Then, insert the following code:

$eventManager = $this->_objectManager->get('Magento\Framework\Event\ManagerInterface');
$eventManager->dispatch('mirasvit_rewards_behavior_rule_process', ['code' => 'customer_change_name', 'attr' => $customer->getName()]);
Note

The variable $customer should be defined