WooCommerce Coupon expired early I believe due to UTC time
-
Hello,
I have a new customer who wanted me to help them make a new coupon in WooCommerce for a launch sale which was supposed to go until end of September. There's a few hours left in the day of September 30, 2021, but they said they had a customer just try and it says it expired (the expiry date is set to October 1, 2021). I believe it's because the WordPress install sees the time as October 1 by a few hours because of UTC (which is basically about ~8 hours ahead of me in Pacific Time).
I've worked around it by temporarily extending it by a day, but how would I permanently resolve this for future times? If a user wants a coupon to expire on October 1, then a customer submitting an order on September 30th even at 11 PM should still be successfully able to use the coupon code. How does one permanently resolve this behaviour?
Has anyone else run into this issue before?
-
Hi @d19dotca ,
It is a common problem when the time zone is not configured correctly in WordPress.
You just have to adjust the time zone with the capital of your country, and WordPress will automatically adjust the web to match the local time.
With that, the WooCommerce coupon will expire on the date and time that you have defined as its limits.
-
I guess we have to ask WooCommerce what timezone/time they take into account when checking for expiry. But looking into server time seems like an easy way to circumvent expiry Usually, coupons are polled for expiry on the WooCommerce side. So, if anything, it's possible WooCommerce servers behaving differently than expected?
Also, apart from what @martinkbs said, I think you can also change the timezone in php.ini using
date.timezone = "US/Pacific"
for example. -
@martinkbs mine is correctly configured for the time zone; so that doesnβt seem to be the issue (I meant to include that in my original post sorry for missing that). It seems to be working off the server time and not the local time zone time.
-
@martinkbs & @girish - So I found the documentation for WooCommerce which does seem to state that it uses the time zone: https://docs.woocommerce.com/document/smart-coupons/how-to-set-expiry-time-with-the-expiry-date/
However that definitely wasn't my experience. Here's a screenshot I took yesterday and meant to include in my original posting, showing the local time zone not yet at October 1st but the server time was October 1st, which is why I strongly believed the code was marked expired because it was looking at the server time instead (it was the only explanation that made sense):
I have created a new coupon code for them which I set to expire on November 1 so I'll try to remember to test out later in the evening of October 31st. I'll also try to duplicate this website to a staging domain and test as well as that'll probably be much quicker so I won't have to wait hahaha. I'll try to report back with my test results.