0

so I'm making a little redirect on my Shopify website that runs on Liquid given that a customer doesn't have an active subscription-based upon a one day time requirement but every time the page loads, it seems to redirect anyway. expirationDate is the Order created_at plus 1 day. I just don't understand why the conditional expirationDate < today_date is forcing a redirect even when the expirationDate is further in time than the current date.

Values that show on the webpage:

expirationDate: January 29, 2020 05:12PM today_date: January 28, 2020 06:49PM

{% capture expirationDate %} {{ ordercreatedat | date: '%s' | plus: 86400 | date: '%B %d, %Y %I:%M%p' }} {% endcapture %}
{% assign today_date = 'now' | date: '%B %d, %Y %I:%M%p' %}
    <p>{{ expirationDate }}
    <p>{{ today_date }}
{% if expirationDate < today_date %}
   <script>
     window.location = "google.com"
   </script>
{% else %}
    <div class="rte">
    {{ page.content }}
    </div>
{% endif %}
Snooder
  • 33
  • 5
  • Does this answer your question? [Date comparison Logic / in Liquid Template Filter](https://stackoverflow.com/questions/47577336/date-comparison-logic-in-liquid-template-filter) – drip Jan 29 '20 at 15:58
  • Another possible duplicate: https://stackoverflow.com/questions/59670547/date-comparison-logic-in-liquid-filter – Dave B Jan 29 '20 at 19:09
  • Thanks @DaveB, your advice on modifying the filter was just what I needed – Snooder Jan 30 '20 at 03:05
  • Glad you were able to find an answer! – Dave B Jan 30 '20 at 15:46

0 Answers0