Personalized checkout and custom promotions with Shopify Scripts
I have 2 order attributes in an order (see screenshot) and want to display a box foreach of them on the order status page.
On my Order Status Page i have the following script
{% if order.attributes.trackingcodes_post_nl %}
{% assign alltrackinglinks_post_nl = {{order.attributes.trackingcodes_post_nl}} | split: "," %}
<script>Shopify.Checkout.OrderStatus.addContentBox('<h2>POST NL Versand :</h2>{% for member in alltrackinglinks_post_nl %}<h3>Link zur Sendung: <a href="https://jouw.postnl.nl/track-and-trace/{{ member }}-{{shipping_address.country_code}}-{{ shipping_address.zip}}?language=en">Klick hier</a></h3>{% endfor %}')</script>
{% endif %}
{% if order.attributes.trackingcodes_dpd %}
{% assign alltrackinglinks_dpd = {{order.attributes.trackingcodes_dpd}} | split: "," %}
<script>Shopify.Checkout.OrderStatus.addContentBox('<h2>DPD Versand : </h2>{% for member in alltrackinglinks_dpd %}<h3>Link zur Sendung: <a href="https://tracking.dpd.de/status/de_DE/parcel/{{ member }}">Klick hier</a></h3>{% endfor %}')</script>
{% endif %}
The Problem
Unfortunately order.attributes.trackingcodes_dpd is not found and never displayed.
Only the 1st attribute (trackingcodes_post_nl) is loaded correctely.
What am i doing wrong ?
Ok i fixed it. I had an additional line break between the 2 order attributes. This seems to be a problem when accessing it via order.attributes.
User | RANK |
---|---|
2 | |
2 | |
2 | |
2 | |
2 |
Transform this holiday season into a shopping spree. Plus, learn how to effortlessly open ...
By Jasonh Dec 8, 2023Make 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, 2023