Skip to content

Commit 9d558a0

Browse files
committed
Fix tests
1 parent 9d33a71 commit 9d558a0

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

includes/classes/Feature/WooCommerce/OrdersHPOS.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ public function set_order_data( $post_args, $post_id ) {
9696
$post_indexable = Indexables::factory()->get( 'post' );
9797
$order = wc_get_order( $post_id );
9898

99-
$post_args['post_type'] = $order->get_type();
99+
$post_args['post_status'] = $this->sanitize_order_status( $order->get_status( 'edit' ) );
100+
$post_args['post_type'] = $order->get_type();
100101
$post_args['post_parent'] = $order->get_changes()['parent_id'] ?? $order->get_data()['parent_id'] ?? 0;
101102
$post_args['post_date'] = gmdate( 'Y-m-d H:i:s', $order->get_date_created( 'edit' )->getOffsetTimestamp() );
102103
$post_args['post_date_gmt'] = gmdate( 'Y-m-d H:i:s', $order->get_date_created( 'edit' )->getTimestamp() );
@@ -306,4 +307,17 @@ public function add_elasticsearch_success_to_orders( $orders ) {
306307

307308
return $orders;
308309
}
310+
311+
/**
312+
* Sanitize order status. We need to add the 'wc-' prefix to the status if it doesn't have it.
313+
*
314+
* @param string $order_status Order status.
315+
* @return string Sanitized order status.
316+
*/
317+
protected function sanitize_order_status( $order_status ) {
318+
if ( 'wc-' === substr( $order_status, 0, 3 ) ) {
319+
return $order_status;
320+
}
321+
return sprintf( 'wc-%s', $order_status );
322+
}
309323
}

0 commit comments

Comments
 (0)