There’s a lot of actions available to let your customers earn points. We have added hooks for most methods to let you add your custom rules or conditions for earning points.
First Order
This hook will be called when a customer places his first order. It is called when the order reaches the processing or complete status, depending on your settings.
Hook Details
add_filter( 'trigger_lws_woorewards_events_firstorder', 'your_function', 10, 3 );
/** @param $multiplier (float)
* @param $event (\LWS\WOOREWARDS\Events\FirstOrder)
* @param $order (WC_Order)
* @return $points
**/
function your_function( $multiplier, $event, $order )
{
/** set your own code */
return $multiplier;
}
Function Parameters
Your function will receive 3 parameters and needs to return the number of points earned.
Name | Type | Direction | Description |
---|---|---|---|
$multiplier | Float | IN / OUT | Multiplication to apply to the points given by the event. See notice below |
$event | FirstOrder | IN | Earning Method Object (LWS\WOOREWARDS\Events\FirstOrder) |
$order | WC_Order | IN | WooCommerce Order object |
Place an order
This hook will be called when a customer places an order. It is called when the order reaches the processing or complete status, depending on your settings.
Hook Details
add_filter( 'trigger_lws_woorewards_events_ordercompleted', 'your_function', 10, 3 );
/** @param $multiplier (float)
* @param $event (\LWS\WOOREWARDS\Events\OrderCompleted)
* @param $order (WC_Order)
* @return $points
**/
function your_function( $multiplier, $event, $order )
{
/** set your own code */
return $multiplier;
}
Function Parameters
Your function will receive 3 parameters and needs to return the number of points earned.
Name | Type | Direction | Description |
---|---|---|---|
$multiplier | Float | IN / OUT | Multiplication to apply to the points given by the event. See notice below |
$event | OrderCompleted | IN | Earning Method Object (LWS\WOOREWARDS\Events\OrderCompleted) |
$order | WC_Order | IN | WooCommerce Order object |
Spend Money
This hook will be called when a customer places an order. It is called when the order reaches the processing or complete status, depending on your settings.
Hook Details
add_filter( 'trigger_lws_woorewards_events_orderamount', 'your_function', 10, 3 );
/** @param $points (float)
* @param $event (\LWS\WOOREWARDS\Events\OrderAmount)
* @param $order (WC_Order)
* @return $points
**/
function your_function( $points, $event, $order )
{
/** set your own code */
return $points;
}
Function Parameters
Your function will receive 3 parameters and needs to return the number of points earned.
Name | Type | Direction | Description |
---|---|---|---|
$points | Float | IN / OUT | Points earned when placing the order. Depends on the order amount. |
$event | OrderAmount | IN | Earning Method Object (LWS\WOOREWARDS\Events\OrderAmount) |
$order | WC_Order | IN | WooCommerce Order object |
Registration Anniversary
This hook will be called on a customer’s registration anniversary.
Hook Details
add_filter( 'trigger_lws_woorewards_events_anniversary', 'your_function', 10, 4 );
/** @param $multiplier (Float)
* @param $event(\LWS\WOOREWARDS\PRO\Events\Anniversary)
* @param $userId (Int)
* @param @param $date (Date) registered date based anniversary
* @return $points
**/
function your_function( $multiplier, $event, $userId, $date )
{
/** set your own code */
return $multiplier;
}
Function Parameters
Your function will receive 4 parameters and needs to return the number of points earned.
Name | Type | Direction | Description |
---|---|---|---|
$multiplier | Float | IN / OUT | Multiplication to apply to the points given by the event. See notice below |
$event | Annniversary | IN | Earning Method Object (LWS\WOOREWARDS\PRO\Events\Anniversary) |
$userId | Int | IN | Id of the wordpress user (WP_User) |
$date | Date | IN | Last triggered anniversary date |
Receive badges
This hook will be called when a customer has earned all the badges of the earning method.
Hook Details
add_filter( 'trigger_lws_woorewards_pro_events_badge', 'your_function', 10, 4 );
/** @param $multiplier (Float)
* @param $event(\LWS\WOOREWARDS\PRO\Events\Badge)
* @param $userId (Int)
* @param $badge (Int) unlocked badge Id
* @return $points
**/
function your_function( $multiplier, $event, $userId, $badge )
{
/** set your own code */
return $multiplier;
}
Function Parameters
Your function will receive 4 parameters and needs to return the number of points earned.
Name | Type | Direction | Description |
---|---|---|---|
$multiplier | Float | IN / OUT | Multiplication to apply to the points given by the event. See notice below |
$event | Badge | IN | Earning Method Object (LWS\WOOREWARDS\PRO\Events\Badge) |
$userId | Int | IN | Id of the wordpress user (WP_User) |
$badge | Badge | IN | The earned badge (\LWS\WOOREWARDS\PRO\Core\Badge) |
Sponsored Orders
This hook will be called when a customer places an order. It is called when the order reaches the processing or complete status, depending on your settings. It will give points to the customer’s sponsor.
Hook Details
add_filter( 'trigger_lws_woorewards_events_sponsoredfirstorder', 'your_function', 10, 3 );
/** @param $multiplier (float)
* @param $event (\LWS\WOOREWARDS\Events\SponsoredFirstOrder)
* @param $order (WC_Order)
* @return $points
**/
function your_function( $multiplier, $event, $order )
{
/** set your own code */
return $multiplier;
}
Function Parameters
Your function will receive 3 parameters and needs to return the number of points earned.
Name | Type | Direction | Description |
---|---|---|---|
$multiplier | Float | IN / OUT | Multiplication to apply to the points given by the event. See notice below |
$event | OrderAmount | IN | Earning Method Object (LWS\WOOREWARDS\Events\SponsoredFirstOrder) |
$order | WC_Order | IN | WooCommerce Order object |
Multiplier notice
On the hooks above, there’s a $multiplier variable sent to functions. Here’s how it works
Multiplier notice
The $multiplier value will be multiplied by the number of points given in the method to earn points. Here are some examples :
You’ve set that customers earn 20 points when performing the action : You will receive a $multiplier value of 1. If you return a value of 2, the customer will receive 20 x 2 = 40 points.
You’ve set that customers earn 1 points when performing the action : You will receive a $multiplier value of 1. If you return a value of 16, the customer will receive 1 x 16 = 16 points.