Skip to content

Instantly share code, notes, and snippets.

@Lonsdale201
Created November 9, 2023 23:59
Show Gist options
  • Select an option

  • Save Lonsdale201/4707959f44a93a363e71347e0bd33123 to your computer and use it in GitHub Desktop.

Select an option

Save Lonsdale201/4707959f44a93a363e71347e0bd33123 to your computer and use it in GitHub Desktop.
WooCommerce Points and Rewards get current user point balance shortcode
function hw_current_user_points_shortcode() {
// Csak bejelentkezett felhasználóknál jelenjen meg valami
if ( is_user_logged_in() ) {
$user_id = get_current_user_id();
// A felhasználó pontegyenlegének lekérdezése a WC_Points_Rewards_Manager osztály használatával
$points = WC_Points_Rewards_Manager::get_users_points( $user_id );
// Ellenőrizzük, hogy a felhasználónak van-e pontja
if ( empty( $points ) ) {
// Ha nincsenek pontok, adjon vissza egy üzenetet
return 'Még nincs pontod.';
} else {
// Ha vannak pontok mutasd
return 'Pontjaid: ' . esc_html( $points );
}
}
return 'Bejelentkezés szükséges a pontok megtekintéséhez.';
}
add_shortcode( 'current_user_points', 'hw_current_user_points_shortcode' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment