I'm using the WooCommerce "Points & Rewards" plugin to add points to customers. The customer can view the history of his points in his account. At the moment there are only 5 point events displayed in the account page of the user.
I found the function in the plugin:
function woocommerce_points_rewards_my_points() {
global $wc_points_rewards;
$points_balance = WC_Points_Rewards_Manager::get_users_points( get_current_user_id() );
$points_label = $wc_points_rewards->get_points_label( $points_balance );
$count = apply_filters( 'wc_points_rewards_my_account_points_events', 5, get_current_user_id() );
// get a set of points events, ordered newest to oldest
$args = array(
'orderby' => array(
'field' => 'date',
'order' => 'DESC',
),
'per_page' => $count,
'paged' => 0,
'user' => get_current_user_id(),
);
$events = WC_Points_Rewards_Points_Log::get_points_log_entries( $args );
// load the template
wc_get_template(
'myaccount/my-points.php',
array(
'points_balance' => $points_balance,
'points_label' => $points_label,
'events' => $events,
),
'',
$wc_points_rewards->get_plugin_path() . '/templates/'
);
}
Is there any way to override the number of events with an own function?
As you can see you can use wc_points_rewards_my_account_points_events
filter hook to change the number of displayed points events, this way:
add_filter( 'wc_points_rewards_my_account_points_events', 'filter_wcpr_my_account_points_events', 10, 2 );
function filter_wcpr_my_account_points_events( $events, $user_id ) {
return 20; // Change to 20 instead of 5
}
Or even shorter in one line:
add_filter( 'wc_points_rewards_my_account_points_events', function( $events, $user_id ){ return 20; }, 10, 2 );
Code goes in function.php file of your active child theme (or active theme). Tested and works.