Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 更改“Woocommerce”中显示的点事件数;积分及;“奖励”;插件_Php_Wordpress_Woocommerce_Hook Woocommerce_Points - Fatal编程技术网

Php 更改“Woocommerce”中显示的点事件数;积分及;“奖励”;插件

Php 更改“Woocommerce”中显示的点事件数;积分及;“奖励”;插件,php,wordpress,woocommerce,hook-woocommerce,points,Php,Wordpress,Woocommerce,Hook Woocommerce,Points,我正在使用WooCommerce“积分和奖励”插件为客户添加积分。 客户可以在其帐户中查看其积分的历史记录。 目前,在用户的帐户页面中仅显示5点事件 我在插件中找到了函数: function woocommerce_points_rewards_my_points() { global $wc_points_rewards; $points_balance = WC_Points_Rewards_Manager::get_users_points( get_current_us

我正在使用WooCommerce“积分和奖励”插件为客户添加积分。 客户可以在其帐户中查看其积分的历史记录。 目前,在用户的帐户页面中仅显示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/'
    );
}

有没有办法用自己的函数覆盖事件的数量?

正如您所见,您可以使用
wc\u points\u rewards\u my\u account\u points\u events
filter hook更改显示的事件数量,方法如下:

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文件。测试和工作