Shopify themes, liquid, logos, and UX
Hi there,
I know this has been done but wonder if anyone can help. I have a yarn store and sell patterns. I have the below code from a site called ravelry to it will take the customer to add the pattern they have bought to their raverly library (it is a knitting thing)
The code works great. What I am having trouble with it getting it only to appear if one of the items bought has download in the variant title or product title (could be multiple items to check, but only want the button to appear once.
If anyone has any ideas on how to do the for loop as we have tried loads of different options but nothing works.
So this is the code for the button which I know works...
<script>
Shopify.Checkout.OrderStatus.addContentBox('<h2>Ravelry library</h2>',
'<p>' +
'Your order includes pdf files available via Ravelry' +
'</p>' +
'<span class="sdd-checkout-item-button">' +
'<form action="https://www.ravelry.com/shopify/89997/add_to_library" method="post">' +
'<input type="hidden" name="customer_url" value="{{order.order_status_url}}" />' +
'<input type="hidden" name="email" value="{{checkout.email}}" />' +
'<input type="hidden" name="order_number" value="{{checkout.order_number}}" />' +
'<input type="submit" value="add pattern(s) to your ravelry library" />' +
'</form>' +
'</span>');
</script>
Thank you so much of you can help.
Jamo
Hi @JamoDesigns
What do you mean by,
only want the button to appear once.
Can you clarify?
Hi thanks for responding.
Meant if the person had bought 4 patterns, don't want the button to appear 4 times if in a loop.
Thanks,
Jamo
Request you to try with below code in the additional script.
{% for item in order.line_items %}
{% if item.title contains "download" %}
<script>
Shopify.Checkout.OrderStatus.addContentBox('<h2>Ravelry library</h2>',
'<p>' +
'Your order includes pdf files available via Ravelry' +
'</p>' +
'<span class="sdd-checkout-item-button">' +
'<form action="https://www.ravelry.com/shopify/89997/add_to_library" method="post">' +
'<input type="hidden" name="customer_url" value="{{order.order_status_url}}" />' +
'<input type="hidden" name="email" value="{{checkout.email}}" />' +
'<input type="hidden" name="order_number" value="{{checkout.order_number}}" />' +
'<input type="submit" value="add pattern(s) to your ravelry library" />' +
'</form>' +
'</span>');
</script>
{% endif %}
{% endfor %}
Hope this will help...
Hi thanks,
Sorry did not work. With liquid just wondering if the if will be case sensitive. Will do a few tests when I get some free time.
Thanks for your help.
Jamo
Let me know once you are done with your test.
We can fix this if want?
Hi Jamo,
In case you're still looking for a solution, our digital products app - FileJar has as integration with Ravelry for that final step of displaying the "Add pattern to library" button both on the Thank You page and on the Order status page. The button only gets displayed once, even if multiple designs were purchased.
You can find it here:
Hey Community 👋 Did you know that March 15th is National Everything You Think Is W...
By JasonH Apr 1, 2025Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025