"isSession" field added to the "UpdateCustomerInput" type (#924)

This commit is contained in:
Geoff Taylor
2025-02-27 10:22:17 -05:00
committed by GitHub
parent 3baeb2bafa
commit 6b581743d7
2 changed files with 9 additions and 3 deletions
+3 -2
View File
@@ -47,9 +47,10 @@ class Customer extends Model {
* Customer constructor
*
* @param \WC_Customer|int|string $id - User ID.
* @param bool $is_session - Whether the customer is a session.
*/
public function __construct( $id = 'session' ) {
$this->data = 'session' === $id ? \WC()->customer : new WC_Customer( absint( $id ) );
public function __construct( $id = 'session', $is_session = false ) {
$this->data = 'session' === $id ? \WC()->customer : new WC_Customer( absint( $id ), $is_session );
$allowed_restricted_fields = [
'isRestricted',
'isPrivate',
+6 -1
View File
@@ -66,6 +66,10 @@ class Customer_Update {
'description' => __( 'Meta data.', 'wp-graphql-woocommerce' ),
'type' => [ 'list_of' => 'MetaDataInput' ],
],
'isSession' => [
'type' => 'Boolean',
'description' => __( 'Whether to save changes on the session or in the database', 'wp-graphql-woocommerce' ),
],
]
);
}
@@ -93,6 +97,7 @@ class Customer_Update {
*/
public static function mutate_and_get_payload() {
return static function ( $input, AppContext $context, ResolveInfo $info ) {
$is_session = isset( $input['isSession'] ) ? $input['isSession'] : false;
$session_only = empty( $input['id'] ) && ! is_user_logged_in();
$payload = null;
@@ -116,7 +121,7 @@ class Customer_Update {
$customer_args = Customer_Mutation::prepare_customer_props( $input, 'update' );
// Create customer object.
$customer = ! $session_only ? new WC_Customer( $payload['id'] ) : \WC()->customer;
$customer = ! $session_only ? new WC_Customer( $payload['id'], $is_session ) : \WC()->customer;
// Copy billing address as shipping address.
if ( isset( $input['shippingSameAsBilling'] ) && $input['shippingSameAsBilling'] ) {