我正在使用WooCommerce "Points & Rewards“插件来向客户添加点数。顾客可以在他的帐户中查看他的观点的历史。目前,用户的帐户页面中只显示了5个点事件。
我在插件中找到了这个函数:
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/'
);
}有任何方法可以用自己的函数覆盖事件的数量吗?
发布于 2018-05-09 18:21:35
如您所见,您可以使用wc_points_rewards_my_account_points_events筛选器钩子来更改显示的点事件的数量,这样:
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
}甚至在一行中更短:
add_filter( 'wc_points_rewards_my_account_points_events', function( $events, $user_id ){ return 20; }, 10, 2 );代码在您的活动子主题(或活动主题)的function.php文件中。测试和工作。
https://stackoverflow.com/questions/50257081
复制相似问题