Skip to content

Commit 930bcc5

Browse files
committed
👌 IMPROVE: Updated customer registration points to log into the db
1 parent bb8ccec commit 930bcc5

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

admin/clwc-earning-loyalty-points.php

+19
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@
2727
function clwc_customer_registration( $user_id ) {
2828
// Check settings before adding any points.
2929
if ( 'on' == clwc_loyalty_points_activate() && 0 != clwc_earning_points_customer_registration() ) {
30+
// Get user data.
31+
$user_info = get_userdata( $user_id );
32+
$user_name = '';
33+
$user_email = '';
34+
35+
if ( $user_info ) {
36+
$user_email = $user_info->user_email;
37+
$user_name = $user_info->display_name;
38+
}
39+
3040
// Get user's loyalty points.
3141
$old_points = get_user_meta( $user_id, 'clwc_loyalty_points', TRUE );
3242

@@ -40,6 +50,15 @@ function clwc_customer_registration( $user_id ) {
4050

4151
// Update customer loyalty points.
4252
update_user_meta( $user_id, 'clwc_loyalty_points', $new_points, $old_points );
53+
54+
// Define a descriptive details string for the log entry.
55+
$details = sprintf(
56+
esc_html__( 'Customer awarded %d loyalty points for registering an account.', 'customer-loyalty-for-woocommerce' ),
57+
clwc_earning_points_customer_registration()
58+
);
59+
60+
// Log the usage of customer loyalty points.
61+
clwc_insert_loyalty_log_entry( $user_id, $user_name, $user_email, $new_points, $details );
4362
}
4463

4564
}

0 commit comments

Comments
 (0)