Score:0

How to display a shipment method as an order item row in csv or table view

cn flag

I am creating a csv order view with a relationship to pull in referenced order items, and it gives a row for each order item as expected :

Order 1, item 1 title, item price,
Order 1, item 2 title, item price,
Order 2, item 1 title, item price,
Order 2, item 2 title, item price,
Order 2, item 3 title, item price,

I would also like to add only one extra row for every unique order that contains the referenced shipment for that order. In drupal 7, shipping charges were line items so this happened automatically with the line items being added to the view. In Drupal 8^ they are on the shipment entity.

I would like the following rows:

Order 1, item 1 title, price,
Order 1, item 2 title, price,
Order 1, shipment method title, rate,
Order 2, item 1 title, item price,
Order 2, item 2 title, item price,
Order 2, item 3 title, item price,
Order 2, shipment method title, rate,

Instead of the product title, I would want to display the shipment method title for that row, and instead of the product price, I would want to display the shipping rate for that row.

I'm assuming I'll need to use views pre_render or something like this. I briefly looked at views_row_insert, but that seems to just add results on the nth row, which for this view would not work. One order may have 5 order items, one view might have 20 order items, but each order will only have one row for the shipping method and rate for the order.

My other thought is to try and create one duplicate row for each order, and then alter the title and price to the shipment method and rate. ¯_(ツ)_/¯

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.