Skip to content
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

Open
wants to merge 5 commits into
base: 2.x
Choose a base branch
from

Conversation

BobWez98
Copy link
Collaborator

@BobWez98 BobWez98 commented Feb 7, 2025

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, however customAttributeMetadataV2 does. We also had to change the mapping a bit.

3.x: #755

@BobWez98 BobWez98 requested a review from indykoning March 3, 2025 13:57
@BobWez98
Copy link
Collaborator Author

BobWez98 commented Mar 3, 2025

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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants