Pre-Order and New Releases collections via Flow

Pre-Order and New Releases collections via Flow

randallpjenkins
Visitor
1 0 0

I'm trying to create a workflow to handle a Pre-Order collection and New Releases collection via Flow. I have a Release Date in my Variant Metafields that I'd like to compare to "Now" or "Today" and essentially have anything in the future be placed into Pre-Order and anything in the past be removed. The New Releases would just be more about if that is within 60 days of "Now" or "Today".

 

It seems like this has to be done with the "Run code" action and javascript? I'm not super skilled in JS so wondering if someone has already worked this out for something or know a similar workaround?

Replies 3 (3)

PaulNewton
Shopify Partner
7746 679 1613

Hi @randallpjenkins try liquid first, even though liquid isn't the greatest for doing date to date comparisons.

So convert to seconds(strings) to in turn convert to a number for size/number comparison

 

{% assign now = 'now' | date: '%s' | plus: 0 %}
{% assign release_date = product.metafields.schedule.release_date | date: '%s' | plus: 0 %}
{% assign mydate = 'now' | date: '%s' %}
{% if now < release_date  %}
 {% comment %}logic for preorders ...{% endcomment %}
{% else %}
 {% comment %}logic for removal ...{% endcomment %}
{% endif %} 

 

 

Meanwhile with javascript you'd need to try and pass in that date info as inputs since the run-code-action doesn't do clock based functions.

But if you do tons of tuts online for doing date comparisons in javascript.

https://help.shopify.com/en/manual/shopify-flow/reference/actions/run-code#limitations:~:text=Random... 

 

If you need this automation built for you then contact me for services
Contact info in forum signature.
ALWAYS please provide context, examples: store url, theme name, post url(s) , or any further detail in ALL correspondence.

 

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org


JayAdra
Shopify Partner
194 15 51

What are you trying to achieve when marking a product as "Pre-order"? Do you just want different text on the ATC button, or a note on the product page? Or are you hoping to use a Pre-order purchase option (selling plan) in Shopify, so the fulfillment is correctly scheduled, partial payments are available etc.?

 

As Paul mentioned, if you just want to show some different text on the product page, it's probably easiest to code this in liquid.

 

For anything extra, I'd recommend using a pre-order app like ours to handle the scheduling of pre-orders, ensuring the customer is informed throughout their entire journey that it's a pre-order, and when the expected ship date is, and to offer things like partial pay/customizable discounts.

 

You can also set up simpler "back-order" functionality, which will let you just update the button text, show a note on the product page, and have a line item attribute carry through to checkout. This can easily be applied catalog-wide too (or for specific products).

 

I'd be happy to help walk you through any of this if you needed, or send you some step-by-step videos, just let me know (we have a 100% free plan with no commission fees too)!

heddykhalifa
Shopify Partner
236 18 53
Hey Randallpjenkins,
 

Heddy from Gameball: Loyalty Program & VIP here!

 

To handle Pre-Order and New Releases collections based on the Release Date in your Variant Metafields, you're right that this will likely require some custom JavaScript using the "Run code" action in Shopify Flow. You'll need to compare the metafield date to the current date (new Date()) in JavaScript. For Pre-Orders, check if the release date is in the future, and for New Releases, check if the release date is within 60 days of today's date.