| @@ -188,31 +188,38 @@ | ||
| 188 | 188 | // right, and it is the same order throughout. |
| 189 | 189 | return $response; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - /** Persist the order behavior assigned to a controller-owned protocol phase. */ | |
| 193 | - public function persist( string $phase, int $id, array $payload, array $current = array(), array $response_data = array(), array $context = array() ): void { | |
| 194 | - if ( 'create_before_identity' === $phase ) { | |
| 195 | - $this->order_payload->persist_tax_ids( $id, $payload, true ); | |
| 196 | - } elseif ( 'create_after_identity' === $phase ) { | |
| 197 | - $this->stamp_order_audit( $id, $payload, true ); | |
| 192 | + /** Persist tax IDs before the identity proof. */ | |
| 193 | + public function after_create( int $id, array $payload ): void { | |
| 194 | + $this->order_payload->persist_tax_ids( $id, $payload, true ); | |
| 195 | + } | |
| 196 | + | |
| 197 | + /** Stamp audit metadata and add the creation note after the identity proof. */ | |
| 198 | + public function after_identity( int $id, array $payload ): void { | |
| 199 | + $this->stamp_order_audit( $id, $payload, true ); | |
| 200 | + $order = wc_get_order( $id ); | |
| 201 | + if ( $order ) { | |
| 202 | + Order_Notes::add_creation_note( $order, get_current_user_id(), $order->get_meta( '_pos_store' ) ); | |
| 203 | + } | |
| 204 | + } | |
| 205 | + | |
| 206 | + /** Restore audit metadata and tax IDs after recovery. */ | |
| 207 | + public function after_recovery( int $id, array $payload ): void { | |
| 208 | + $this->stamp_order_audit( $id, $payload, false ); | |
| 209 | + $this->order_payload->persist_tax_ids( $id, $payload, true ); | |
| 210 | + } | |
| 211 | + | |
| 212 | + /** Persist till metadata, tax IDs, reassignment, and email changes after update. */ | |
| 213 | + public function after_update( int $id, array $payload, array $current, array $response_data, array $context ): void { | |
| 214 | + $this->stamp_order_till_meta( $id, $payload ); | |
| 215 | + $this->order_payload->persist_tax_ids( $id, $payload, false ); | |
| 216 | + $this->persist_cashier_store_reassignment( $id, $current, $response_data, $context ); | |
| 217 | + if ( ! empty( $context['clear_email'] ) ) { | |
| 198 | 218 | $order = wc_get_order( $id ); |
| 199 | 219 | if ( $order ) { |
| 200 | - Order_Notes::add_creation_note( $order, get_current_user_id(), $order->get_meta( '_pos_store' ) ); | |
| 201 | - } | |
| 202 | - } elseif ( 'create_recovery' === $phase ) { | |
| 203 | - $this->stamp_order_audit( $id, $payload, false ); | |
| 204 | - $this->order_payload->persist_tax_ids( $id, $payload, true ); | |
| 205 | - } elseif ( 'update' === $phase ) { | |
| 206 | - $this->stamp_order_till_meta( $id, $payload ); | |
| 207 | - $this->order_payload->persist_tax_ids( $id, $payload, false ); | |
| 208 | - $this->persist_cashier_store_reassignment( $id, $current, $response_data, $context ); | |
| 209 | - if ( ! empty( $context['clear_email'] ) ) { | |
| 210 | - $order = wc_get_order( $id ); | |
| 211 | - if ( $order ) { | |
| 212 | - $order->set_billing_email( '' ); | |
| 213 | - $order->get_data_store()->update( $order ); | |
| 214 | - } | |
| 220 | + $order->set_billing_email( '' ); | |
| 221 | + $order->get_data_store()->update( $order ); | |
| 215 | 222 | } |
| 216 | 223 | } |
| 217 | 224 | } |
| 218 | 225 | |