Skip to content

Commit

Permalink
Add to cart
Browse files Browse the repository at this point in the history
  • Loading branch information
cctina516 committed Nov 7, 2024
1 parent 1eaa129 commit f4008a0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions blocks/commerce-cart/commerce-cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ export default async function decorate(block) {

const isEmptyCart = isCartEmpty(cart);

const DROPDOWN_MAX_QUANTITY = 20;

const dropdownOptions = Array.from(
{ length: parseInt(DROPDOWN_MAX_QUANTITY, 10) },
(_, i) => {
const quantityOption = i + 1;
return {
value: `${quantityOption}`,
text: `${quantityOption}`,
};
},
);

// Layout
const fragment = document.createRange().createContextualFragment(`
<div class="cart__wrapper">
Expand Down Expand Up @@ -76,6 +89,10 @@ export default async function decorate(block) {
attributesToHide: hideAttributes.split(',').map((attr) => attr.trim().toLowerCase()),
enableUpdateItemQuantity: enableUpdateItemQuantity === 'true',
enableRemoveItem: enableRemoveItem === 'true',
showDiscount: 'true',
showSavings: 'true',
quantityType: 'dropdown',
dropdownOptions,
})($list),

// Order Summary
Expand Down

0 comments on commit f4008a0

Please sign in to comment.