Points Hooks
Points Hooks

Knowledge Base

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.

NameTypeDirectionDescription
$multiplierFloatIN / OUTMultiplication to apply to the points given by the event. See notice below
$eventFirstOrderINEarning Method Object (LWS\WOOREWARDS\Events\FirstOrder)
$orderWC_OrderINWooCommerce 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.

NameTypeDirectionDescription
$multiplierFloatIN / OUTMultiplication to apply to the points given by the event. See notice below
$eventOrderCompletedINEarning Method Object (LWS\WOOREWARDS\Events\OrderCompleted)
$orderWC_OrderINWooCommerce 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.

NameTypeDirectionDescription
$pointsFloatIN / OUTPoints earned when placing the order. Depends on the order amount.
$eventOrderAmountINEarning Method Object (LWS\WOOREWARDS\Events\OrderAmount)
$orderWC_OrderINWooCommerce 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.

NameTypeDirectionDescription
$multiplierFloatIN / OUTMultiplication to apply to the points given by the event. See notice below
$eventAnnniversaryINEarning Method Object (LWS\WOOREWARDS\PRO\Events\Anniversary)
$userIdIntINId of the wordpress user (WP_User)
$dateDateINLast 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.

NameTypeDirectionDescription
$multiplierFloatIN / OUTMultiplication to apply to the points given by the event. See notice below
$eventBadgeINEarning Method Object (LWS\WOOREWARDS\PRO\Events\Badge)
$userIdIntINId of the wordpress user (WP_User)
$badgeBadgeINThe 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.

NameTypeDirectionDescription
$multiplierFloatIN / OUTMultiplication to apply to the points given by the event. See notice below
$eventOrderAmountINEarning Method Object (LWS\WOOREWARDS\Events\SponsoredFirstOrder)
$orderWC_OrderINWooCommerce 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.

Was this article helpful?
Dislike 0
Views: 516

Continue reading

Next: Custom Emails