All things Shopify and commerce
Hello,
My store does local delivery. I need to modify the order status and order confirmation page based on the day of the week of the order date. If the customer orders on Friday or Saturday, then the delivery is Monday. If not, the delivery will be tomorrow.
I started to use this code, but I'm not sure if the capture date will reference today's date or the order date. Can you please me help me figure out the correct code to use.
{% capture day %}{{ 'now' | date: '%A' }}{% endcapture %}{% case day %} {% when 'Sunday' %}tomorrow {% when 'Monday' %} tomorrow {% when 'Tuesday' %}tomorrow {% when 'Wednesday' %} tomorrow {% when 'Thursday' %}tomorrow {% when 'Friday' %}Monday {% when 'Saturday' %} Monday{% endcase %}
I'm not sure if the capture date will reference today's date or the order date
While it should be at the time that "now" when it's rendered unfortunately I think it's ambiguous because of cache'ing either on the users end or shopifys servers.
So if you did it thursday "now" would output tomorrow and you then again visited friday but it's cached from thursday it would say tomorrow.
Really you'd want to support this with frontend javascript checking either a clock api , or the users system time(keeping in mind users system time is also unreliable)
{%- capture day -%}
{{- 'now' | date: '%A' -}}
{%- endcapture -%}
{%- case day -%}
{%- when 'Sunday' -%}tomorrow
{%- when 'Monday' -%}tomorrow
{%- when 'Tuesday' -%}tomorrow
{%- when 'Wednesday' -%}tomorrow
{%- when 'Thursday' -%}tomorrow
{%- when 'Friday' -%}Monday
{%- when 'Saturday' -%}Monday
{%- endcase -%}
Alt
{%- capture day -%}
{{- 'now' | date: '%A' -}}
{%- endcapture -%}
{%- case day -%}
{%- when 'Friday' -%}Monday
{%- when 'Saturday' -%}Monday
{%- else -%}tomorrow
{%- endcase -%}
Save time & money ,Ask Questions The Smart Way
Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com
Problem Solved? ✔Accept and Like solutions to help future merchants
Answers powered by coffee Buy Paul a ☕ Coffee for more answers or donate to eff.org
Thanks Paul! I appreciate the quick response! Thanks for the simplified version of the code.
"So if you did it thursday "now" would output tomorrow and you then again visited friday but it's cached from thursday it would say tomorrow." Does this mean the caching will work in my favor to retain tomorrow or Monday depending on the day the customer ordered?
If not, is there a way to reference the day of the order created on date instead of 'now'?
I use your alternate code provided, but I checked the order confirmation email preview and the words are jumbled together. See screenshot below.
Can you adjust the code? Forgive me, but I don't have any experience with coding.
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024