Skip to content

Commit

Permalink
bump (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
fnhipster authored Mar 8, 2024
1 parent 91c9ac3 commit a46a997
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 38 deletions.
42 changes: 25 additions & 17 deletions blocks/product-details/product-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,33 @@ export default async function decorate(block) {
slots: {
Actions: (ctx) => {
// Add to Cart Button
ctx.appendButton((next) => ({
text: 'Add to Cart',
icon: 'Cart',
variant: 'primary',
onClick: async () => {
try {
if (!next.valid) {
ctx.appendButton((next, state) => {
const adding = state.get('adding');
return {
text: adding ? 'Adding to Cart' : 'Add to Cart',
icon: 'Cart',
variant: 'primary',
disabled: adding || !next.data.inStock,
onClick: async () => {
try {
state.set('adding', true);

if (!next.valid) {
// eslint-disable-next-line no-console
console.warn('Invalid product', next.values);
return;
}

await addProductsToCart([{ ...next.values }]);
} catch (error) {
// eslint-disable-next-line no-console
console.warn('Invalid product', next.values);
return;
console.warn('Error adding product to cart', error);
} finally {
state.set('adding', false);
}

await addProductsToCart([{ ...next.values }]);
} catch (error) {
// eslint-disable-next-line no-console
console.warn('Error adding product to cart', error);
}
},
}));
},
};
});

// Add to Wishlist Button
// ctx.appendButton(() => ({
Expand Down
52 changes: 38 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@dropins/storefront-cart": "0.1.0-alpha12",
"@dropins/storefront-checkout": "0.1.0-alpha23",
"@dropins/storefront-order-confirmation": "0.1.0-alpha14",
"@dropins/storefront-pdp": "^0.2.2-alpha12",
"@dropins/tools": "latest"
"@dropins/storefront-pdp": "0.2.2-alpha14",
"@dropins/tools": "0.18.0"
}
}
2 changes: 2 additions & 0 deletions scripts/__dropins__/storefront-pdp/396.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions scripts/__dropins__/storefront-pdp/606.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion scripts/__dropins__/storefront-pdp/713.js

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions scripts/__dropins__/storefront-pdp/997.js

This file was deleted.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion scripts/__dropins__/storefront-pdp/runtime.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a46a997

Please sign in to comment.