• I just noticed, in my woocommerce, an order is stated there it was made on 10/29/2023. however in this plugin print invoice and print receipt page it generates, it states the order date is 10/30/2023. i think the plugin is using the server timezone. maybe it should use the wordpress configured time zone. I think you could change in the file includes\wcdn-template-functions.php the function wcdn_get_order_info

    where it says:

    $fields['order_date'] = array(
        'label' => __( 'Order Date', 'woocommerce-delivery-notes' ),
        'value' => date_i18n( get_option( 'date_format' ), strtotime( $wdn_order_order_date ) ),
    );
    


    replace it with:

    // Get the WordPress timezone
    $timezone = get_option('timezone_string') ? get_option('timezone_string') : 'UTC';
    
    // Convert the order's date to the WordPress timezone
    $order_date_object = new DateTime( $wdn_order_order_date, new DateTimeZone( 'UTC' ) );
    $order_date_object->setTimezone( new DateTimeZone( $timezone ) );
    $order_date_formatted = $order_date_object->format( get_option( 'date_format' ) );
    
    $fields['order_date'] = array(
        'label' => __( 'Order Date', 'woocommerce-delivery-notes' ),
        'value' => $order_date_formatted,
    );
    

    note that chatgpt helped make that change above, so please check it for yourself to see it it is good.

    • This topic was modified 1 year, 1 month ago by radial.
    • This topic was modified 1 year, 1 month ago by radial.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter radial

    (@radial)

    I have not yested this yet, but this might work if you put it into functions.php to override the bugged code

    function custom_fix_order_date_timezone($fields, $order_id) {
        // Get the order creation date in the server's timezone
        $wdn_order_order_date = get_post_field('post_date', $order_id, 'raw');
    
        // Get the WordPress timezone
        $timezone = get_option('timezone_string') ? get_option('timezone_string') : 'UTC';
    
        // Convert the order's date to the WordPress timezone
        $order_date_object = new DateTime($wdn_order_order_date, new DateTimeZone('UTC'));
        $order_date_object->setTimezone(new DateTimeZone($timezone));
        $order_date_formatted = $order_date_object->format(get_option('date_format'));
    
        $fields['order_date'] = array(
            'label' => __('Order Date', 'woocommerce-delivery-notes'),
            'value' => $order_date_formatted,
        );
    
        return $fields;
    }
    
    add_filter('wcdn_get_order_info', 'custom_fix_order_date_timezone', 10, 2);
    
    nick1122

    (@nick1122)

    Hi Radial,

    I have checked the issue in our site, and the plugin appears to be working fine with order date.

    Please create the ticket here on our support tool so that we can communicate in detail. Additionally, please provide more information about the error and in which order template you are getting the date error.

    Regards,
    Nikhil.

    Thread Starter radial

    (@radial)

    fyi i think the code snippet i posted above doesnt work, and i dont see how i can delete that. what does work is the initial code modification i posted in the OP.

    I have opened a ticket for you on your portal and included a video of the issue thanks

    • This reply was modified 1 year ago by radial.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Order Date incorrect’ is closed to new replies.