Last active
January 26, 2019 15:03
-
-
Save tjmapes/027ed12f7bb54be9a29e6305df756199 to your computer and use it in GitHub Desktop.
Shopify liquid logic for determining ship date
This file contains hidden or 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 -%} | |
// This uses RUBY to format the dates since Shopify uses RUBY. | |
// For help - Ruby Date Format (strftime) Cheat Sheet: | |
// https://www.shortcutfoo.com/app/dojos/ruby-date-format-strftime/cheatsheet | |
{%- endcomment -%} | |
{%- assign date_format = "%A, %B %d" -%} | |
<p>Shipping starts at just $3.50! Planned ship date is: | |
{%- assign todayDate = 'now' | date: "%w" -%} | |
{%- if collection.metafields.global.status == 'today' -%} | |
{%- if todayDate == "0" or todayDate == "6" -%} | |
{%- comment -%} If today is Monday or Sunday, 4 days out {%- endcomment -%} | |
{{'now' | date: "%s" | plus : 345600 | date: date_format }}. | |
{%- elsif todayDate == "5" -%} | |
{%- comment -%} If today is Saturday, 5 days out {%- endcomment -%} | |
{{'now' | date: "%s" | plus : 432000 | date: date_format }}. | |
{%- else -%} | |
{%- comment -%} If today is Tue/Wed/Thu/Fri, 6 days out {%- endcomment -%} | |
{{'now' | date: "%s" | plus : 518400 | date: date_format }}. | |
{%- endif -%} | |
{%- else -%} | |
{%- if todayDate == "2" or todayDate == "3" -%} | |
{%- comment -%} If today is Wednesday or Thursday, 2 days out {%- endcomment -%} | |
{{'now' | date: "%s" | plus : 172800 | date: date_format }}. | |
{%- elsif todayDate == "0" or todayDate == "1" -%} | |
{%- comment -%} If today is Monday or Tuesday, 3 days out {%- endcomment -%} | |
{{'now' | date: "%s" | plus : 259200 | date: date_format }}. | |
{%- else -%} | |
{%- comment -%} If today is Friday or Saturday, 4 days out {%- endcomment -%} | |
{{'now' | date: "%s" | plus : 345600 | date: date_format }}. | |
{%- endif -%} | |
{%- endif -%} | |
</p> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment