Exclude Route Product From Quantity Count

JaRet_Watkins
Excursionist
18 0 5

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 %}
Replies 8 (8)

Ninthony
Shopify Partner
2329 350 1023

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 %}

 

 

If my solution helped you, please like it and accept it as the solution!
If you'd like to make any edits to your store, please send me a personal message and we can discuss what you'd like to accomplish 😄
JaRet_Watkins
Excursionist
18 0 5

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 ! 

Ninthony
Shopify Partner
2329 350 1023

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.

If my solution helped you, please like it and accept it as the solution!
If you'd like to make any edits to your store, please send me a personal message and we can discuss what you'd like to accomplish 😄
seebie
Visitor
1 0 0

Route is printing on a separate packing list for me. I need this gone from the packing list. Did this code help with that? 

marigold_aimee
Visitor
1 0 0

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. 

Jripla
Visitor
2 0 0

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! 

Joel49
Visitor
2 0 0

I have the same duplicate packing slip issue, was this ever resolved?

Bitsys
Visitor
1 0 0

Hello,

 

Where do I type in this code? I would love to use it.

 

Thank You