Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


    Cloudron Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular

    WooCommerce Coupon expired early I believe due to UTC time

    WordPress (Developer)
    3
    5
    245
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • d19dotca
      d19dotca last edited by

      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?

      --
      Dustin Dauncey
      www.d19.ca

      martinkbs 1 Reply Last reply Reply Quote 0
      • martinkbs
        martinkbs @d19dotca last edited by

        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.

        Captura de pantalla 2021-10-01 a las 11.15.20.png

        With that, the WooCommerce coupon will expire on the date and time that you have defined as its limits. πŸ˜‰

        d19dotca 1 Reply Last reply Reply Quote 1
        • girish
          girish Staff last edited by girish

          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.

          1 Reply Last reply Reply Quote 1
          • d19dotca
            d19dotca @martinkbs last edited by

            @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.

            --
            Dustin Dauncey
            www.d19.ca

            1 Reply Last reply Reply Quote 0
            • d19dotca
              d19dotca last edited by

              @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):

              Screen Shot 2021-09-30 at 9.35.52 PM.png

              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.

              --
              Dustin Dauncey
              www.d19.ca

              1 Reply Last reply Reply Quote 1
              • First post
                Last post
              Powered by NodeBB