@feedmepos/order-plugin-gallery 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const maxItemInCategoryPlugin = ({ sdk, onAfterComputeMenuState, onBeforeSubmitOrder, pluginParams, }) => {
|
|
2
2
|
const MIN_ITEMS = 1;
|
|
3
|
-
const MAX_ITEMS =
|
|
3
|
+
const MAX_ITEMS = 1;
|
|
4
4
|
const categoryLimitConfig = pluginParams?.categoryLimitConfig || {};
|
|
5
5
|
onBeforeSubmitOrder(() => {
|
|
6
6
|
if (!categoryLimitConfig.categoryId) {
|
|
@@ -48,7 +48,7 @@ const maxItemInCategoryPlugin = ({ sdk, onAfterComputeMenuState, onBeforeSubmitO
|
|
|
48
48
|
};
|
|
49
49
|
const toast = (message) => {
|
|
50
50
|
sdk.ui.toast.show({
|
|
51
|
-
title:
|
|
51
|
+
title: message,
|
|
52
52
|
type: "error",
|
|
53
53
|
duration: 5000,
|
|
54
54
|
});
|
|
@@ -60,12 +60,12 @@ const maxItemInCategoryPlugin = ({ sdk, onAfterComputeMenuState, onBeforeSubmitO
|
|
|
60
60
|
const totalItems = numberOfTotalItems.submitted + numberOfTotalItems.inCart;
|
|
61
61
|
if (totalItems > MAX_ITEMS) {
|
|
62
62
|
const extraItems = totalItems - MAX_ITEMS;
|
|
63
|
-
|
|
63
|
+
const extraLabel = extraItems === 1 ? "item" : "items";
|
|
64
|
+
toast(`You can only choose one ${targetCategory.name}. Please remove extra ${targetCategory.name} from cart to continue.`);
|
|
64
65
|
return false;
|
|
65
66
|
}
|
|
66
67
|
if (totalItems < MIN_ITEMS) {
|
|
67
|
-
|
|
68
|
-
toast(`Add at least ${remainingItems} more ${targetCategory.name} to cart to continue. `);
|
|
68
|
+
toast(`Please add one ${targetCategory.name} to cart to continue.`);
|
|
69
69
|
return false;
|
|
70
70
|
}
|
|
71
71
|
return true;
|