-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[2.x] Get option labels with attribute options in the cart #726
base: 2.x
Are you sure you want to change the base?
Conversation
Updated PR |
@@ -37,4 +37,8 @@ export const attributes = computedAsync( | |||
{ lazy: true, shallow: false }, | |||
) | |||
|
|||
window.attributeLabel = (attributeCode) => { | |||
return Object.values(attributes.value)?.find((attribute) => attribute.code === attributeCode)?.name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we might want to return a computed value of this expression.
attributes is a lazy computed async. It will only be fetched when it's used and returns a default value in the meantime.
calling attributeLabel
might give us undefined back while the request is still going and it will not be able to update.
if we wrap this in a computed function it has the chance to rerender with the updated attributes
This PR is a solution to not having option labels in the cart attributes. Sadly the
customAttributeMetadata
query does not support getting the option labels, howevercustomAttributeMetadataV2
does. We also had to change the mapping a bit.3.x: #755