WooCommerce Points and Rewards Developer Documentation

Actions / Filters Reference ↑ Back to top

  • apply_filters( 'wc_points_rewards_my_account_points_events', 5, get_current_user_id() ); — Use this to control the number of points log records that are shown to the user on the My Account page.
  • apply_filters( 'manage_woocommerce_page_wc_points_rewards_points_log_columns', $columns ); — Use this to change the columns that are displayed on the points log list table.
  • manage_woocommerce_page_wc_points_rewards_manage_points_columns — Use this to change the columns that are displayed on the manage points list table.
  • apply_filters( 'wc_points_rewards_manage_points_list_table_class_name', 'WC_Points_Rewards_Manage_Points_List_Table' ); — Use this to change the class that is loaded for the manage points list table.
  • apply_filters( 'wc_points_rewards_points_log_list_table_class_name', 'WC_Points_Rewards_Points_Log_List_Table' ); — Use this to change the class that is loaded for the points log list table.
  • apply_filters( 'wc_points_rewards_settings', array(...) ); — Use this to add or remove settings from the Points & Rewards settings page.
  • apply_filters ( 'wc_points_rewards_earn_points_message', $message, $points_earned ); — Use this to control the “You will earn X points” message that is displayed on the cart/checkout page.
  • apply_filters ( 'wc_points_rewards_redeem_points_message', $message, $discount_available ); — Use this to control the “Use X points for a $Y discount” message that is displayed on the cart/checkout page.
  • apply_filters( 'wc_points_rewards_event_description', $event_description, $event_type ); — Use this to control what description is shown for the event types listed in the points log.
  • apply_filters( 'wc_points_rewards_set_points_balance', $points_balance, $user_id, $event_type ); — Use this to modify the points balance to set when called from WC_Points_Rewards_Manager::set_points_balance()
  • apply_filters( 'wc_points_rewards_increase_points', $points, $user_id, $event_type, $order_id, $data ); — Use this to modify the points increase when called from WC_Points_Rewards_Manager::increase_points()
  • apply_filters( 'wc_points_rewards_decrease_points', $points, $user_id, $event_type, $order_id, $data ); — Use this to modify the the points decreased when called from WC_Points_Rewards_Manager::decrease_points()
  • apply_filters( 'wc_points_rewards_user_points_balance', $points_balance, $user_id ); — Use this to modify the points balance returned for the given user ID.
  • apply_filters( 'wc_points_rewards_single_product_message', $message ); — Use this to modify the message displayed on the single product page.

Integrating a plugin with Points & Rewards ↑ Back to top

It’s easy to add support for Points & Rewards to your plugin. By doing so, customers can earn points for actions taken within your plugin, which adds value to your plugin and Points & Rewards alike. For example, an email newsletter plugin might allow customers to earn points for subscribing to a newsletter. There are three steps you need to take in order to add support:

  1. Add your own settings to allow the admin to enable or set the number of points a customer will earn for taking an action. Use the wc_points_rewards_action_settings filter to add your settings to the Points & Rewards settings page in the Points Earned for Actions section. The wc_points_rewards_action_settings filter takes an array of standard WooCommerce settings arrays, and returns the same. The minimum fields required to add a setting are ‘title’ and ‘id’, while ‘desc_tip’ is recommended.
  2. Add a detailed description string for your action’s event type. As part of providing a third party integration you will create a unique action event slug. This slug should be meaningful, short, and likely to be unique, for instance “mailchimp-newsletter-signup”. You should return a detailed description string for your event type by hooking into the wc_points_rewards_event_description filter which accepts an event description, event type and event object and returns an event description.
  3. When the user takes the specified action (e.g. signing up a newsletter), add points to their account by using WC_Points_Rewards_Manager::increase_points( $user_id, $points_to_add, $event_type, $data, $order_id );. $user_id, $points_to_add, and $event_type are required. You should retrieve the value set by the admin for the points to add, and use the current users ID as the user ID. The event type can be an custom string, but it’s recommended to use something specific to your plugin (e.g. ‘mailchimp-newsletter-signup’).

Putting it all together:

WooCommerce - the most customizable eCommerce platform for building your online business.

Back to the top