Shopify themes, liquid, logos, and UX
Hi everyone!
Our store uses Order Printer to print out the packing list for an order. We also use optional Route insurance that customers can use to protect their shipment.
I'm trying to build something in our invoice that says "There are XX products in this order" so that when we pick and pack orders, we can ensure that we have the correct number of products in the package. However, because some orders have route insurance, this counts as a "product" in the list of products. I'm trying to figure out how to exclude this product from the addition of products.
Here's my code:
{% assign totalProductsOrdered = 0 %}
{% for line_item in line_items %}
{% assign totalProductsOrdered = totalProductsOrdered | plus: line_item.quantity %}
{% endfor %}
Later in the template I have this:
Total number of items in order: {{ totalProductsOrdered }}
What I want is to filter out Route insurance as a product in the object totalProductsOrdered.
Can I do something like this:
{% assign totalProductsOrdered = totalProductsOrdered | plus: line_item.quantity | where: line_item.requires_shipping != false %}
I don't know if your code works, but since the Route insurance is a product I would check for the handle in the line_item loop and l would use an unless statement to just not add 1 to the totalProductsOrdered variable. I don't know exactly what the handle is but it would look something like:
{% assign totalProductsOrdered = 0 %}
{% for line_item in line_items %}
{% unless line_item.handle == 'route-insurance' %}
{% assign totalProductsOrdered = totalProductsOrdered | plus: line_item.quantity %}
{% endunless %}
{% endfor %}
Thank you!
That code didn't work but this did:
{% unless line_item.title contains 'Route' %}
{% assign totalProductsOrdered = totalProductsOrdered | plus: line_item.quantity %}
{% endunless %}
This works for me because we'll never have a product title with the word Route.
Thanks again @Ninthony !
Not a problem. Like I said I didn't actually know the handle of the product. I would personally suggest using the products handle as opposed to title, only because of case sensitivity and the fact maybe you would have Route in any of your other product titles. Whatever works for you though.
Route is printing on a separate packing list for me. I need this gone from the packing list. Did this code help with that?
I'm also having the issue of Route printing as a separate page when printing packing slips. How/where do I play around with inserting code to remove it? Complete novice.
I am having the same issue as well with the separate packing slip for Route. After chatting with Route support and Shopify Support this morning, they both said this looks like a known limitation between Route and Shopify at this time, and my feedback would be sent to the developer team/engineer team so that they may consider adding this feature in the future but can't promise this feature will be added.
Hoping it gets added soon!
I have the same duplicate packing slip issue, was this ever resolved?
Hello,
Where do I type in this code? I would love to use it.
Thank You
Are you ready to take your business to the next level? Look no further than the latest ...
By SarahF_Shopify Apr 15, 2024We’re keeping the ball rolling to make sure you’re always ahead of the game. So buckle ...
By JasonH Apr 8, 2024Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024