Merge pull request #24441 from woocommerce/fix/24416

[Tracker] Prevent PHP warning when order date is empty
This commit is contained in:
Rodrigo Primo 2019-08-21 16:14:49 -03:00 committed by GitHub
commit bfc469123f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 7 deletions

View File

@ -48,13 +48,12 @@ class WC_Orders_Tracking {
*/
public function track_order_status_change( $id, $previous_status, $next_status ) {
$order = wc_get_order( $id );
$date = $order->get_date_created();
$properties = array(
'order_id' => $id,
'next_status' => $next_status,
'previous_status' => $previous_status,
'date_created' => $date->date( 'Y-m-d' ),
'date_created' => $order->get_date_created() ? $order->get_date_created()->date( 'Y-m-d' ) : '',
'payment_method' => $order->get_payment_method(),
);
@ -80,7 +79,7 @@ class WC_Orders_Tracking {
$order = wc_get_order( $id );
$date_created = $order->get_date_created()->date( 'Y-m-d H:i:s' );
// phpcs:disable WordPress.Security.NonceVerification.NoNonceVerification
$new_date = sprintf(
$new_date = sprintf(
'%s %2d:%2d:%2d',
isset( $_POST['order_date'] ) ? wc_clean( wp_unslash( $_POST['order_date'] ) ) : '',
isset( $_POST['order_date_hour'] ) ? wc_clean( wp_unslash( $_POST['order_date_hour'] ) ) : '',
@ -91,8 +90,8 @@ class WC_Orders_Tracking {
if ( $new_date !== $date_created ) {
$properties = array(
'order_id' => $id,
'status' => $order->get_status(),
'order_id' => $id,
'status' => $order->get_status(),
);
WC_Tracks::record_event( 'order_edit_date_created', $properties );
@ -129,9 +128,9 @@ class WC_Orders_Tracking {
$referer = wp_get_referer();
if ( $referer ) {
$referring_page = parse_url( $referer );
$referring_page = wp_parse_url( $referer );
$referring_args = array();
$post_edit_page = parse_url( admin_url( 'post.php' ) );
$post_edit_page = wp_parse_url( admin_url( 'post.php' ) );
if ( ! empty( $referring_page['query'] ) ) {
parse_str( $referring_page['query'], $referring_args );