In 1.x line items held both the purchased products and non-product adjustments such as discounts and shipping.
In 2.x we're separating the two: line items hold only products. Adjustments will hold discounts, shipping, fees.
I've been reading Silverstone's data modelling book, and he has a chapter about orders, and he also argues for separating line items and adjustments.
However, he has an argument for dropping the "line" part of the name:
Many models will portray orders having "order line items." The reason that this model does not call them "order line items" is that this term connotes physical lines on an order form. The physical lines on an order form often encompass many other things aside from the items that have been ordered. For instance, there may be notes to records adjustments, taxes, estimated freight costs, explanations, and other descriptive detail for the order. Rather than portray the entity as capturing each of the documented lines on an order form, the ORDER ITEM entity represents a major information need for the order, namely the items or products that have been ordered."
This would mean the following changes:
entity_type: commerce_line_item -> commerce_order_item
entity class: LineItem -> OrderItem
reference field: $order->line_items -> $order->items.
Is this a change we want to make? I don't care much, but I thought it was worth discussing.
A different naming might signal better that the underlying assumptions have changed.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | consider_renaming_line-2603478-10.patch | 239.56 KB | mglaman |
| #4 | rename_line_items_to_items-2603478-4.patch | 72.96 KB | vasike |
Comments
Comment #2
mglamanI still like the naming of line item. Even though something is for shipping or adjustments, it's still a line item on an order or invoice. When I receive an estimate from a contractor, like for physical work, my possible credits are still a line item on the invoice.
Comment #3
bojanz commentedThat's exactly Silverstone's point. In Commerce 2.x adjustments (shipping, discounts) are not line items.
Comment #4
vasikethere is patch for this:
Comment #5
rszrama commentedIf we're making the change, I believe we should at least use "order items" throughout (e.g. the field would be named order_items, not just items).
I'm not entirely convinced by the reasoning of the book. It seems like he'd only accept products as order items, when we actually do use line items for shipping fees, adjustments, etc. The only thing we don't is taxes, but I actually don't think I've ever seen an invoice from an OMS that itemized taxes along with everything else. It's always either in a column alongside the unit price of the line item or else in the order totals area somewhere near the footer.
I'm not saying we shouldn't change it, but line items has definitely been the nomenclature for quite some time. Are we not using line items for shipping charges or order level discounts in 2.x?
Comment #6
bojanz commentedYes, the point is that according to the current plan we are using line items only for products in 2.x Everything else is an adjustment.
That's what makes Silverstone's point valid.
vasike was a bit too quick to write a patch, since we've had no consensus on the rename.
Comment #7
rszrama commentedI may need you to remind me here why we wouldn't consider using a line item for shipping costs in the new model. Sorry, I'm sure we've chatted about it before.
Comment #8
bojanz commentedDiscussed with Matt, we agreed we want to see this happen before the beta.
I ended up having less strong opinions on the dilemma, but it does feel like "order item" emphasizes that the items belong to the order, which is something we'll want to enforce on the transactional level as well.
Comment #9
mglamanHere goes nothing.
Comment #10
mglamanPR: https://github.com/drupalcommerce/commerce/pull/503
Let the review madness begin!
Comment #11
bojanz commentedWe're no longer considering :)
Comment #13
mglamanMERGED!