Update status only when its changed. (#38696)
This commit is contained in:
commit
b0c06849a9
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
|
||||
Update status only when it's changed.
|
|
@ -1816,8 +1816,8 @@ FROM $order_meta_table
|
|||
|
||||
$changes['type'] = $order->get_type();
|
||||
|
||||
// Make sure 'status' is correct.
|
||||
if ( array_key_exists( 'status', $column_mapping ) ) {
|
||||
// Make sure 'status' is correctly prefixed.
|
||||
if ( array_key_exists( 'status', $column_mapping ) && array_key_exists( 'status', $changes ) ) {
|
||||
$changes['status'] = $this->get_post_status( $order );
|
||||
}
|
||||
|
||||
|
|
|
@ -2130,4 +2130,20 @@ class OrdersTableDataStoreTests extends WC_Unit_Test_Case {
|
|||
|
||||
$this->assertEquals( 1, $result );
|
||||
}
|
||||
|
||||
/**
|
||||
* @testDox When saving an order, status is automatically prefixed even if it was not earlier.
|
||||
*/
|
||||
public function test_get_db_row_from_order_only_prefixed_status_is_written_to_db() {
|
||||
$order = wc_create_order();
|
||||
|
||||
$order->set_status( 'completed' );
|
||||
$db_row_callback = function ( $order, $only_changes ) {
|
||||
return $this->get_db_row_from_order( $order, $this->order_column_mapping, $only_changes );
|
||||
};
|
||||
|
||||
$db_row = $db_row_callback->call( $this->sut, $order, false );
|
||||
|
||||
$this->assertEquals( 'wc-completed', $db_row['data']['status'] );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue