Skip to content
  1. Home
  2. Docs
  3. WooRewards
  4. Hooks and Code Snippets
  5. Earning Methods Hooks

Earning Methods Hooks

There’s a lot of methods 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
Standard
Pro

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  $points (float)
  * @param  $event (\LWS\WOOREWARDS\Events\FirstOrder)
  * @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 Number of points earned when placing the order
$event FirstOrder IN Earning Method Object (LWS\WOOREWARDS\Events\FirstOrder)
$order WC_Order IN WooCommerce Order object

 

Place an order
Standard
Pro

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  $points (float)
  * @param  $event (\LWS\WOOREWARDS\Events\OrderCompleted)
  * @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 Number of points earned when placing the order
$event OrderCompleted IN Earning Method Object (LWS\WOOREWARDS\Events\OrderCompleted)
$order WC_Order IN WooCommerce Order object

 

Spend Money
Standard
Pro

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
Pro

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  $points (Float)
  * @param  $event(\LWS\WOOREWARDS\PRO\Events\Anniversary)
  * @param  $userId (Int)
  * @param  @param $date (Date) registered date based anniversary
  * @return $points 
**/
function your_function( $points, $event, $userId, $date )
{
    /** set your own code */
    return $points;
}

Function Parameters

Your function will receive 4 parameters and needs to return the number of points earned.

Name Type Direction Description
$points Float IN / OUT Points earned for the anniversary
$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

 

Earn one ore more badges
Pro

This hook will be called when a customer has earned all the badges of the earning method.

Hook Details

add_filter( 'trigger_lws_woorewards_events_badge', 'your_function', 10, 4 );

/** @param  $points (Float)
  * @param  $event(\LWS\WOOREWARDS\PRO\Events\Badge)
  * @param  $userId (Int)
  * @param  @param $date (Date) registered date based anniversary
  * @return $points 
**/
function your_function( $points, $event, $userId, $date )
{
    /** set your own code */
    return $points;
}

Function Parameters

Your function will receive 4 parameters and needs to return the number of points earned.

Name Type Direction Description
$points Float IN / OUT Points earned for the anniversary
$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)

 

Scroll To Top