-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisplay users points for WooCommerce Points & Rewards
More file actions
39 lines (33 loc) · 1.3 KB
/
Copy pathdisplay users points for WooCommerce Points & Rewards
File metadata and controls
39 lines (33 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function woocommerce_points_rewards_my_points($atts, $content = null) { // **SHORTCODE** add string ($atts, $content=null)
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 );
ob_start(); // **SHORTCODE** object start
// 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/'
);
$content = ob_get_clean(); // **SHORTCODE**
return do_shortcode( $content ); // **SHORTCODE** place shortcode in content area
}
add_shortcode ('points_shortcode', 'woocommerce_points_rewards_my_points'); // **SHORTCODE** declare shortcode to be used [points_shortcode]
}