[COT] Initialize order date props during `read()` as GMT (#34474)

* Load order date props as timestamps in COT
This commit is contained in:
Jorge A. Torres 2022-08-30 05:30:03 -05:00 committed by GitHub
parent f813153ac5
commit 45563f0c11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Initialize order dates in the COT datastore using the correct timezone.

View File

@ -828,11 +828,18 @@ SELECT type FROM {$this->get_orders_table_name()} WHERE id = %d;
if ( ! isset( $prop_details['name'] ) ) {
continue;
}
$prop_value = $order_data->{$prop_details['name']};
if ( 'date' === $prop_details['type'] ) {
$prop_value = $this->string_to_timestamp( $prop_value );
}
$prop_setter_function_name = "set_{$prop_details['name']}";
if ( is_callable( array( $order, $prop_setter_function_name ) ) ) {
$order->{$prop_setter_function_name}( $order_data->{$prop_details['name']} );
$order->{$prop_setter_function_name}( $prop_value );
} elseif ( is_callable( array( $this, $prop_setter_function_name ) ) ) {
$this->{$prop_setter_function_name}( $order, $order_data->{$prop_details['name']}, false );
$this->{$prop_setter_function_name}( $order, $prop_value, false );
}
}
}