Skip to content

Conversation

@vedanshujain
Copy link
Contributor

All Submissions:

Changes proposed in this Pull Request:

In #33638, we updated usage of $post->post_date with $order->get_created_date(). Unfortunately, this also induced a bug because by default, created_at functions returns a GMT based date. So when displaying, we will display a GMT-based date in the order details box, which when updated, will be set as the actual created date.

This PR fixes the issue by using a timezone offset date-time instead.

How to test the changes in this Pull Request:

  1. Make sure your site is on a timezone other than UTC +0.
  2. Go to the new order screen, and click on create to publish a new order (no need to add any details).
  3. Without this PR, you will notice that the order created date is updated to UTC+0, with this PR order created date will stay the same.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully run tests with your changes locally?
  • Have you created a changelog file for each project being changed, ie pnpm changelog add --filter=<project>?

FOR PR REVIEWER ONLY:

  • I have reviewed that everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities. I made sure Linting is not ignored or disabled.

@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Sep 15, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Sep 15, 2022

Test Results Summary

Commit SHA: 7bda141

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests11800201200m 41s
E2E Tests186001018717m 46s
To view the full API test report, click here.
To view the full E2E test report, click here.
To view all test reports, visit the WooCommerce Test Reports Dashboard.

@Konamiman
Copy link
Contributor

Tested on a UTC+2 shop, creating an order at 9h local time.

Without the fix:
date_created_gmt: 5h
date_updated_gmt: 7h
Order time in orders list: 7h

With the fix:
date_created_gmt: 7h
date_updated_gmt: 7h
Order time in orders list: 9h

So yes, the fix seems to be working as expected.

@Konamiman Konamiman self-requested a review September 15, 2022 07:11
Konamiman
Konamiman previously approved these changes Sep 15, 2022
@Konamiman Konamiman merged commit f534823 into trunk Sep 15, 2022
@Konamiman Konamiman deleted the fix/order_displayed_time branch September 15, 2022 10:05
@github-actions github-actions bot added this to the 7.0.0 milestone Sep 15, 2022
@github-actions
Copy link
Contributor

Hi @Konamiman, thanks for merging this pull request. Please take a look at these follow-up tasks you may need to perform:

  • Add the release: add testing instructions label

@roykho roykho mentioned this pull request Sep 15, 2022
8 tasks
roykho added a commit that referenced this pull request Sep 15, 2022
* Use localised time when displaying order date. (#34687)

* Cherry pick fix and prep for 6.9.2 release

Co-authored-by: Vedanshu Jain <[email protected]>
@falkdav
Copy link

falkdav commented Sep 16, 2022

I've updated to WooCommerce 6.9.2 but still have the issue!
How can I fixit it?

My timezone is UTC-3 (Brazil), language: pt_BR.
PHP Version: 7.4.30
WooCommerce DB version: 6.9.2

@Konamiman
Copy link
Contributor

Hi @falkdav, this fix will be included in WooCommerce 7.0. WooCommerce 6.9.2 was a fix release built on top of the 6.9.0 branch and doesn't include this change (we only include fixes for critical issues in fix releases).

As a hint, you can always look at the "Milestone" section in the sidebar of a merged pull request to know in which release version will it be included:

image

@vedanshujain
Copy link
Contributor Author

Actually, this fix was also included in 6.9.2 as part of the fix release process, even though the milestone is set to 7.0.

Note that if an order is updated from the wp-admin while the bug was present, then it may have changed the created date which is what you might be seeing. You can manually switch back the order created date.

To confirm, can you verify if this happens for a new order as well (or an old order that was not updated while the bug was active during WC 6.9 or WC 6.9.1)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plugin: woocommerce Issues related to the WooCommerce Core plugin.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants