Custom Expected Shipping Date without using a third party Shopify App

Custom code to show an expected ship date without the need of an external app. I use this instead of a separate app as it doesn’t slow down the site as much. The drawback is that there is no interface to maintain it and it requires a bit of programming.

There are two different ways to use it. Either you have a standard shipping time for the vendor or you use tags to define the shipping time. Just insert the code at the desired location and use any CSS to format it accordingly.

Expected Ship Date:

{% assign SHMvendor = product.vendor %}
{% assign SHMtags = producttags %}

<!--vendor option - just replace [vendor] with your own vendor-->
{% if SHMvendor contains '[vendor]' %}{% assign DaysFrom = 14 | times: 86400 %} {% assign DaysTo = 21 | times: 86400 %}{% endif %}
<!--vendor option - just replace [vendor] with your own vendo -->

<!--tags option - just replace [tag] with your own tag you specify to indicate the shipping date-->
{% if SHMtags contains '[tag]' %}{% assign DaysFrom = 14 | times: 86400 %} {% assign DaysTo = 21 | times: 86400 %}{% endif %}
<!--tags option - just replace [tag] with your own tag you specify to indicate the shipping date-->

{% assign wday = "now" | plus: DaysFrom | date: "%a" %}
{% if wday == 'Sat' %}
{% assign DaysFrom = DaysFrom | plus: 172800 %}
{% assign DaysTo = DaysTo | plus: 172800 %}
{% endif %}
{% if wday == 'Sun' %}
{% assign DaysFrom = DaysFrom | plus: 86400 %}
{% assign DaysTo = DaysTo | plus: 86400 %}
{% endif %}

{% assign wday = "now" | plus: DaysTo | date: "%a" %}
{% if wday == 'Sat' %} {% assign DaysTo = DaysTo | plus: 172800 %} {% endif %}
{% if wday == 'Sun' %} {% assign DaysTo = DaysTo | plus: 86400 %} {% endif %}

{% if DaysFrom > 0 %}
<strong>{{ "now" | date: "%s" | plus: DaysFrom | date: "%a, %b %d, %Y" }}</strong> to <strong>{{ "now" | date: "%s" | plus: DaysTo | date: "%a, %b %d, %Y" }}</strong>
{% endif %}

Leave a Reply

Your email address will not be published. Required fields are marked *