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] Ensure variant id is converted to an integer #3491

Merged
merged 4 commits into from
May 28, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions assets/quick-order-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,11 @@ if (!customElements.get('quick-order-list')) {
this.cartUpdateUnsubscriber = subscribe(PUB_SUB_EVENTS.cartUpdate, (event) => {
const variantIds = [];
this.querySelectorAll('.variant-item').forEach((item) => {
variantIds.push(item.dataset.variantId);
variantIds.push(parseInt(item.dataset.variantId));
sofiamatulis marked this conversation as resolved.
Show resolved Hide resolved
});

if (
event.source === this.quickOrderListId ||
(event.cartData.items && variantIds.some((element) => !event.cartData.items.includes(element)))
(event.cartData.items && event.cartData.items.some((element) => !variantIds.includes(element.variant_id)))
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't quite work because of the negation inside the .some callback.

Suggested change
(event.cartData.items && event.cartData.items.some((element) => !variantIds.includes(element.variant_id)))
!event.cartData.items?.some((element) => variantIds.includes(element.variant_id))

Copy link
Contributor Author

@sofiamatulis sofiamatulis May 28, 2024

Choose a reason for hiding this comment

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

👀 Fixed here: https://screenshot.click/28-32-99kt3-lx6e4.mp4

I also noted that well have to eventually make this logic a bit more nitfy.

event.cartData.items returns the entire cart and if the element wasnt updated we shouldnt be updating it. The pubsub should return only the new variants that were updated

) {
return;
}
Expand Down
Loading