Last active
July 20, 2023 04:58
-
-
Save tjmapes/d6363438bce087f777933b2df5bea398 to your computer and use it in GitHub Desktop.
Shopify shipping logic with liquid dates example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{%- comment -%} | |
Shopify uses RUBY, so we will too. | |
For help - Ruby Date Format (strftime) Cheat Sheet: | |
http://www.strfti.me | |
{%- endcomment -%} | |
{% comment %} | |
Below you'll find the liquid logic for a store that has 3 day shipping, and ships 7 days a week | |
{% endcomment %} | |
{%- assign date_format = "%A, %B %d" -%} | |
<p>Planned ship date is: {{'now' | date: "%s" | plus : 259200 | date: date_format }}.</p> | |
{% comment %} | |
Below you'll find the liquid logic for a store that has 2 *business day* shipping and doesn't ship on the weekends (only ships Monday - Friday). | |
// | |
Shipping Calendar: | |
Thur = Mon | |
Fri = Tue | |
Sat = Wed | |
Sun = Tue | |
Mon = Wed | |
Tue = Thur | |
Wed = Fri | |
// | |
{% endcomment %} | |
{%- assign date_format = "%A, %B %d" -%} | |
{%- assign todayDate = 'now' | date: "%w" -%} | |
<p>Shipping starts at just $3.50! Planned ship date is: | |
{%- unless todayDate == "4" or todayDate == "5" or todayDate == "6" -%} | |
{%- comment -%} If today is Thur(4), Fri(5), Sat(6) = 4 days out because it ships two business days later {%- endcomment -%} | |
{{'now' | date: "%s" | plus : 345600 | date: date_format }}. | |
{%- else -%} | |
{%- comment -%} If today is Sun(0), Mon(1), Tue(2), Wed(3) = 2 days out {%- endcomment -%} | |
{{'now' | date: "%s" | plus : 172800 | date: date_format }}. | |
{% endunless %} | |
</p> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment