Custom Behavior Events

Using this feature you can add your own 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 field Custom Behavior Events, add a new rule in this format: rulecode, rulename. You can add more rules, each on a new line.
  3. Insert the following code in the place where points should be charged:
$eventManager = $this->_objectManager->get('Magento\Framework\Event\ManagerInterface');
$eventManager->dispatch('mirasvit_rewards_behavior_rule_process', ['code' => 'rulecode', 'attr' => attribute]);


For example, to create a rule for the event 'user name changed' you should insert in the field Custom Behavior Events: customer_change_name, Change customer name rule

and 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