What's your biggest current challenge? Have your say in Community Polls along the right column.

Re: Show unfulfilled order total to customer/visitors of site

Show unfulfilled order total to customer/visitors of site

benpellwall
Shopify Partner
7 0 2

I'm trying to display the number of unfulfilled orders our store currently has ahead of a customer who might be placing an order.

 

It should work out the number of orders with the status unfulfilled there are at the time they are browsing and show the number.

 

The code I have been testing is as follows but it is returning 0 orders everytime, it should be 77.

 

{% assign unfulfilled_orders = 0 %}
{% for order in orders %}
  {% if order.fulfillment_status == 'unfulfilled' and order.created_at <= 'now' %}
    {% assign unfulfilled_orders = unfulfilled_orders | plus: 1 %}
  {% endif %}
{% endfor %}

The number of unfulfilled orders as of {{'now' | date: '%Y-%m-%d'}} is {{unfulfilled_orders}}.
Reply 1 (1)

Uhrick
Shopify Partner
433 68 102

hey, Benpellwall. I think the validation order.created_at probably shouldn't work, as 'now' usually only works with the filter. You can try to store {{ 'now | date: '%Y-%m-%d' }} in a variable and, then, see if it matches the way that order.created_at presents its date

Shopify Developer
Hire me for theme customizations at ricardomsilvestre@outlook.com or Upwork
Was my answer helpful to you? Please like or mark as solution