feat: better cart and order item attributes, with labels #5253
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #5208
Impact: minor
Type: feature
Issue
CartItem
andOrderItem
haveattributes
array, butlabel
wasnull
andvalue
was pulled from the wrong product field.OrderItem
always had empty array.One underlying problem is that we had no label for variants, which is why we have null attribute labels.
A related problem is general confusion around
title
vs.optionTitle
fields for variants.Solution
attributeLabel
string field toProducts
of type "variant"attributeLabel
string field to allCatalogProductVariant
attributeLabel
,optionTitle
, andtitle
fields on that form, to help avoid more confusion.attributes
array onOrderItem
s when they are createdattributes
array onCartItem
s when they are createdattributeLabel
to a default value inProducts
andCatalog
collections. For top-level variants, set to "Variant". For option variants, set to "Option".label
for allattributes
on allCartItem
to a default value inCart
collection. For first attribute, set to "Variant". For second attribute, if present, set to "Option".NOTE: I opted not to do #5206 in this PR to avoid it becoming too large.
Breaking changes
As long as migrations run, nothing should break. If client code is using cart item
attributes
and depending on what thevalue
of them currently is (the full title), it may need to be updated.Testing
attributeLabel
field for any variant or option in aCatalogItemProduct
.