Skip to content

Commit 4eeefc0

Browse files
committed
fix(data-listeners): handle no user in wc data update
1 parent 9cee51d commit 4eeefc0

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

includes/class-data-listeners.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,22 @@ public static function item_changed( $item_id, $status_from, $status_to, $item )
5858
$relationship = 'parent';
5959
}
6060
}
61-
return [
61+
$result = [
6262
'id' => $item_id,
6363
'user_id' => $item->get_customer_id(),
64-
'user_name' => $item->get_user()->display_name,
64+
'user_name' => '',
6565
'email' => $item->get_billing_email(),
6666
'status_before' => $status_from,
6767
'status_after' => $status_to,
6868
'formatted_total' => wp_strip_all_tags( $item->get_formatted_order_total() ),
6969
'payment_count' => method_exists( $item, 'get_payment_count' ) ? $item->get_payment_count() : 1,
7070
'subscription_relationship' => $relationship,
7171
];
72+
$user = $item->get_user();
73+
if ( $user ) {
74+
$result['user_name'] = $user->display_name;
75+
}
76+
return $result;
7277
}
7378

7479
/**
@@ -80,5 +85,4 @@ public static function item_changed( $item_id, $status_from, $status_to, $item )
8085
public static function user_updated( $user_data ) {
8186
return $user_data;
8287
}
83-
8488
}

0 commit comments

Comments
 (0)