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?
User | RANK |
---|---|
206 | |
170 | |
77 | |
56 | |
52 |
Make the shift from discounts to donations, and witness your business not only thrive fina...
By Holly Dec 4, 2023On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023You've downloaded the Search & Discovery app from the Shopify App store, and as you're ...
By Skye Nov 8, 2023