File tree Expand file tree Collapse file tree
includes/classes/Feature/WooCommerce Expand file tree Collapse file tree Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments