Hi,
My store needs to get the current datetime that the Checkout’s page built-in “Pay Now” button (or “Complete order" button) was clicked and compare that date with the current product’s sale end period.
For example:
Product Name: Product 1
Product’s Sale End: 10/01/2025 23:30
Date time that customer’s clicked the “Buy Now” button from the product page: 10/01/2025 23:28
In the Checkout page, the customer took 5 minutes to enter his/her information, and managed to click the “Pay Now” (or “Complete order”) on 23:33. So it was already passed the product’s sale end period.
I tried using Checkout UI extension and Shopify function.
-
Checkout UI extension can get the current datetime when it’s value is only when the checkout page loads.
-
Shopify function cannot get the current datetime (it returns 1970-01-01). I also tried passing attributes from the client but the current datetime passed via attributes is also the datetime that the checkout page loaded. So it defeats the purpose of getting the actual datetime when the pay now button is clicked.
Another idea is subscribing to webhook on “order creation” to get the actual datetime it was processed. However, the order was already placed, and the customer already saw that it was confirmed. It’s not a good idea to cancel the order if the processed date has passed the product’s sale end period. Is there a way to validate first before showing the “Order confirmed page”? To show a message instead or block checkout if sale period has pased.
Or is there any other idea to do the requirement? Please see screenshot for reference.

