Skip to content

Commit 79c6035

Browse files
Checkout mutation: Add or Update order metas (#484)
* Checkout mutation: Add or Update order metas * Checkout mutation: Update order metas Co-authored-by: Geoff Taylor <[email protected]>
1 parent 71be042 commit 79c6035

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

includes/data/mutation/class-checkout-mutation.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ public static function process_checkout( $data, $input, $context, $info, &$resul
600600

601601
// Add meta data.
602602
if ( ! empty( $input['metaData'] ) ) {
603-
self::add_order_meta( $order_id, $input['metaData'], $input, $context, $info );
603+
self::update_order_meta( $order_id, $input['metaData'], $input, $context, $info );
604604
}
605605

606606
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
@@ -698,20 +698,20 @@ public static function get_value( $input ) {
698698
}
699699

700700
/**
701-
* Add meta data not set in WC_Checkout::create_order().
701+
* Add or update meta data not set in WC_Checkout::create_order().
702702
*
703703
* @param int $order_id Order ID.
704704
* @param array $meta_data Order meta data.
705705
* @param array $input Order properties.
706706
* @param AppContext $context AppContext instance.
707707
* @param ResolveInfo $info ResolveInfo instance.
708708
*/
709-
public static function add_order_meta( $order_id, $meta_data, $input, $context, $info ) {
709+
public static function update_order_meta( $order_id, $meta_data, $input, $context, $info ) {
710710
$order = \WC_Order_Factory::get_order( $order_id );
711711

712712
if ( $meta_data ) {
713713
foreach ( $meta_data as $meta ) {
714-
$order->add_meta_data( $meta['key'], $meta['value'] );
714+
$order->update_meta_data( $meta['key'], $meta['value'] );
715715
}
716716
}
717717

includes/utils/class-session-transaction-manager.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ public function update_transaction_queue( $source, $args, $context, $info ) {
124124
return;
125125
}
126126

127-
128127
// Bail if transaction has already been completed. There are times when the underlying action runs twice.
129128
if ( ! is_null( $this->transaction_id ) ) {
130129
$transaction_queue = get_transient( "woo_session_transactions_queue_{$this->session_handler->get_customer_id()}" );
@@ -167,7 +166,7 @@ public function next_transaction() {
167166
} elseif ( $this->transaction_id === $transaction_queue[0]['transaction_id'] ) {
168167
return true;
169168
} elseif ( true === $this->did_transaction_expire( $transaction_queue ) ) {
170-
// If transaction has expired, remove it from the queue array and continue loop
169+
// If transaction has expired, remove it from the queue array and continue loop.
171170
array_shift( $transaction_queue );
172171
$this->save_transaction_queue( $transaction_queue );
173172
}
@@ -244,6 +243,11 @@ public function save_transaction_queue( $queue = array() ) {
244243
set_transient( "woo_session_transactions_queue_{$this->session_handler->get_customer_id()}", $queue );
245244
}
246245

246+
/**
247+
* Create transaction timestamp.
248+
*
249+
* @return void
250+
*/
247251
public function set_timestamp() {
248252
$transaction_queue = $this->get_transaction_queue();
249253

@@ -270,7 +274,7 @@ public function get_timestamp_threshold() {
270274
* Whether the transaction has expired. This helps prevent infinite loops while searching through the transaction
271275
* queue.
272276
*
273-
* @param $transaction_queue
277+
* @param array $transaction_queue Transaction queue.
274278
*
275279
* @return bool
276280
*/

vendor/composer/installed.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
'type' => 'wordpress-plugin',
66
'install_path' => __DIR__ . '/../../',
77
'aliases' => array(),
8-
'reference' => 'a0de0f51fec44fb5c50a23a3bf31a7035344b9f7',
8+
'reference' => '3be01c1f984984cb8abaab397941f05e452e4dfb',
99
'name' => 'wp-graphql/wp-graphql-woocommerce',
1010
'dev' => false,
1111
),
@@ -25,7 +25,7 @@
2525
'type' => 'wordpress-plugin',
2626
'install_path' => __DIR__ . '/../../',
2727
'aliases' => array(),
28-
'reference' => 'a0de0f51fec44fb5c50a23a3bf31a7035344b9f7',
28+
'reference' => '3be01c1f984984cb8abaab397941f05e452e4dfb',
2929
'dev_requirement' => false,
3030
),
3131
),

0 commit comments

Comments
 (0)