File tree 2 files changed +9
-3
lines changed
2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -47,9 +47,10 @@ class Customer extends Model {
47
47
* Customer constructor
48
48
*
49
49
* @param \WC_Customer|int|string $id - User ID.
50
+ * @param bool $is_session - Whether the customer is a session.
50
51
*/
51
- public function __construct ( $ id = 'session ' ) {
52
- $ this ->data = 'session ' === $ id ? \WC ()->customer : new WC_Customer ( absint ( $ id ) );
52
+ public function __construct ( $ id = 'session ' , $ is_session = false ) {
53
+ $ this ->data = 'session ' === $ id ? \WC ()->customer : new WC_Customer ( absint ( $ id ), $ is_session );
53
54
$ allowed_restricted_fields = [
54
55
'isRestricted ' ,
55
56
'isPrivate ' ,
Original file line number Diff line number Diff line change @@ -66,6 +66,10 @@ public static function get_input_fields() {
66
66
'description ' => __ ( 'Meta data. ' , 'wp-graphql-woocommerce ' ),
67
67
'type ' => [ 'list_of ' => 'MetaDataInput ' ],
68
68
],
69
+ 'isSession ' => [
70
+ 'type ' => 'Boolean ' ,
71
+ 'description ' => __ ( 'Whether to save changes on the session or in the database ' , 'wp-graphql-woocommerce ' ),
72
+ ],
69
73
]
70
74
);
71
75
}
@@ -93,6 +97,7 @@ public static function get_output_fields() {
93
97
*/
94
98
public static function mutate_and_get_payload () {
95
99
return static function ( $ input , AppContext $ context , ResolveInfo $ info ) {
100
+ $ is_session = isset ( $ input ['isSession ' ] ) ? $ input ['isSession ' ] : false ;
96
101
$ session_only = empty ( $ input ['id ' ] ) && ! is_user_logged_in ();
97
102
$ payload = null ;
98
103
@@ -116,7 +121,7 @@ public static function mutate_and_get_payload() {
116
121
$ customer_args = Customer_Mutation::prepare_customer_props ( $ input , 'update ' );
117
122
118
123
// Create customer object.
119
- $ customer = ! $ session_only ? new WC_Customer ( $ payload ['id ' ] ) : \WC ()->customer ;
124
+ $ customer = ! $ session_only ? new WC_Customer ( $ payload ['id ' ], $ is_session ) : \WC ()->customer ;
120
125
121
126
// Copy billing address as shipping address.
122
127
if ( isset ( $ input ['shippingSameAsBilling ' ] ) && $ input ['shippingSameAsBilling ' ] ) {
You can’t perform that action at this time.
0 commit comments