Shopify's transactional emails, such as order confirmations and shipping updates, can display Bundles in a grouped view. Prior to this update Shopify used flat views to display all order line items as a linear list, while a grouped view nests items under their bundle parent. As a transactional email Partner, you can implement this view using the [GraphQL Admin API](/docs/api/admin-graphql).
For example, in the following image, a bundle of products is left ungrouped in an order confirmation email:
In this image, the products in a Bundle are presented in a grouped view:
## Step 1: Querying for the `lineItemsGroup` data
Whether you're displaying Bundles as a grouped view or as a flat view, you'll first need to query the `lineItems` on your `order`. The following query leverages [`order`](docs/api/admin-graphql/unstable/queries/order) and is kept simple for demonstration purposes, add additional fields as needed for your purposes.
> Tip:
> The following example is limited to the price after any discounts are applied. You could optionally retrieve and later calculate the price before discounts and total discounts.
> Note:
> At this point you have all the data needed to display Bundles as a flat view. When displaying line items you'll note which products are part of a bundle.
The relevant fields we're requesting are:
- `title`: The title of the line item, potentially a Bundle component
- `quantity`: The quantity of the line item
- `discountedTotalSet.shopMoney.amount`: The total price of the line item after any discounts
- `discountedTotalsSet.shopMoney.currencyCode`: The currency code of the total price
- `lineItemGroup`: The Bundle parent of the line item, if it exists
- `id`: The unique identifier of the `lineItemGroup`
- `title`: The title of the Bundle parent product
- `quantity`: The quantity of the Bundle parent product
## Step 2: Grouping Bundles
After you've retrieved `lineItemGroup` data, you'll group the Bundle components under the parent product to make it easier to present them as a grouped view.
Any product with a `null` `lineItemGroup` field is not part of a Bundle and should be displayed as a standalone product.
Passing in our above result to this function, results in a data structure that looks like this:
With this data you can display your Bundles as a grouped view in your transactional emails.
## Step 3: Calculating the bundle price
The last thing you'll need to do is calculate the total price of a bundle if you want to display it. This is a simple sum of the prices of the components.
By passing in each bundle object, the above will total up the price of all the components in the bundle. You'll need to modify this depending on the fields you queried. For example, if you queried `discountedTotalSet`, you'll get the total discounted price of the line item accounting for any quantity. If instead you used `discountedUnitPriceSet`, you'd get the discounted price per unit and will need to account for price and quantity in your calculation.