When using parent_id in /cart/add.js to create nested cart lines (e.g., a main product with a free gift nested underneath), the default order confirmation email renders the parent line item twice:
Once as a standalone item in the subtotal_line_items loop (because line.groups.size == 0 and it’s not a nested_line_child?)
Once as a deliverable group in the line_item_groups loop (with its children correctly shown underneath)
The subtotal/total calculations are correct — only the visual display is duplicated.
Steps to reproduce:
Add items to cart via /cart/add.js with a parent_id field on one of the items, creating a parent-child nested line relationship:
Hey everyone, Until Shopify come up with any solution use this workaround which I have tested with Order confirmation email template with default order confirmation template:
Create a backup of current order confirmation email template.
Add this liquid code to the top of the order confirmation email:
(This will save all parent variant ids inside variable for later use)
Later on find this line in email template (which is line items loop appears in 2 places) {% for line in subtotal_line_items %} using CTRL+F or Command+F and right after this line enter into new line and copy paste this code
This will basically skip the line items which are parent variants.
If order confirmation email template is modified then make sure the if condition variable which is line (from line.variant.id) in this case should be same as the variable name in the loop at for line in subtotal_line_items
Thanks, this works - I tested the same idea on a customized order confirmation template.
One edge case to watch: skipping by variant_id will also hide a second copy of the same product if it’s in the order without a nested child. Matching on line.id instead keeps that line.
contains is also a substring check, so wrapping IDs as ,{id}, avoids accidental matches. I also filtered with group.deliverable? so bundle parents aren’t mixed in with nested add-ons.
{% continue %} in the subtotal_line_items loops is the right call though - thanks for posting this.
Yes that’s right, In the case where the same product is added without nested product it will skip that but it will also show it as quantity like below: