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

🐛 Quick order list and combined listings #3373

Conversation

lhoffbeck
Copy link
Contributor

@lhoffbeck lhoffbeck commented Mar 26, 2024

PR Summary:

Fixes JS error when reloading the quick order list section and titles for combined listings products

What approach did you take?

JS error

  • We were throwing a JS error because the custom element was already defined. I wrapped the element definition in an existence check like we do elsewhere in dawn

Variant titles

  • Combined listings are a group of related products, surfaced as a single product. In this case, we can't accurately rely on has_only_default_variant to determine whether a variant is default or not, because has_only_default_variant still returns false if a combined listing is made up of child products that each only have a single variant. For example, if we have a combined listing "Pants" that has children "Pants - blue", "Pants - green" where both blue and green have no additional options, the product has 2 total variants where each is a default variant.
  • To fix this, I am currently relying on a default option name and default variant name check, but IMO we should fix this by extending the variant drop to have a is_default_variant value. This also enabled us to simplify quick order list row input to just take a variant instead of a product or a variant.
  • My changes also fix a bug I introduced where products with only default variants show Default title instead of the product title.

Visual impact on existing themes

Combined listing parent

Before

Screenshot 2024-03-26 at 2 57 31 PM

After

Screenshot 2024-03-26 at 2 56 35 PM

Combined listing child

Before
Screenshot 2024-03-26 at 2 57 35 PM

After

Screenshot 2024-03-26 at 2 56 39 PM

Product with options

Before
Screenshot 2024-03-26 at 2 57 40 PM

After

Screenshot 2024-03-26 at 2 56 43 PM

Product with only default variant

Before

Screenshot 2024-03-26 at 2 57 45 PM

After

Screenshot 2024-03-26 at 2 56 50 PM

Demo links

Links

Steps

  • In Admin, the theme with changes is called with PR changes, theme before the changes is called without PR changes
  • With the changes, verify that quick order list titles display as expected
  • With the changes, go to the combined listing parent and verify that there is not a JS error like Uncaught SyntaxError: Identifier 'QuickOrderListRemoveButton' has already been declared (at quick-order-list.js:1:1) when switching options

Checklist

…ing product-info class and migrating product-update specific logic out of the VariantSelects class. A product wrapper enables children to more trivially perform global updates by providing a heirarchical "namespace"--i.e. child publishes event, parent captures and declaratively updates other children VS child updates siblings. By extracting the VariantSelects onChange logic to use this pattern, VariantSelects is able to be a single-purpose class, it is easier to understand why siblings are updated, and we were able to eliminate some really gross logic that handled variant change updates differently depending on the wrapping context.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I highly recommend hiding whitespace to make this diff easier to understand

confirm: 'confirm',
remove: 'remove',
cancel: 'cancel'
if (!customElements.get('quick-order-list-remove-button')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We actually already have these changes on main . It was from the quick add bulk PR

https://github.com/Shopify/dawn/blob/main/assets/quick-order-list.js#L1

I recommend rebasing off of main

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh amazing 🙏 🙏 🙏 🙏

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ill review again when it's updated :)

I also see this PR https://screenshot.click/28-40-bgg2h-6n5o1.png
has conflicts that need to be fixed #3289

@lhoffbeck lhoffbeck mentioned this pull request May 17, 2024
9 tasks
@lhoffbeck lhoffbeck force-pushed the lh-prototype-combined-listing-pdp-section-updates branch from 2a22f8a to 7e35aa4 Compare May 23, 2024 16:06
@lhoffbeck
Copy link
Contributor Author

Closing, this has been fixed by a few other PRs

@lhoffbeck lhoffbeck closed this May 23, 2024
@lhoffbeck lhoffbeck deleted the bug-quick-order-list-and-combined-listings branch May 23, 2024 19:44
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.

None yet

2 participants