@evershop/evershop 1.1.0 → 1.2.1
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.
- package/bin/build/index.js +24 -0
- package/bin/extension/index.js +2 -2
- package/bin/lib/addDefaultMiddlewareFuncs.js +7 -2
- package/bin/lib/buildEntry.js +20 -2
- package/bin/lib/onListening.js +7 -4
- package/bin/lib/startUp.js +6 -0
- package/package.json +9 -1
- package/src/components/admin/catalog/productEdit/category/CategoryItem.jsx +2 -7
- package/src/components/admin/catalog/productEdit/category/CategoryTree.jsx +14 -7
- package/src/components/admin/catalog/productEdit/category/CategoryTree.scss +10 -0
- package/src/components/admin/catalog/productEdit/variants/CreateVariant.jsx +2 -2
- package/src/components/admin/catalog/productEdit/variants/CreateVariantGroup.jsx +1 -1
- package/src/components/admin/catalog/productEdit/variants/EditVariant.jsx +1 -1
- package/src/components/admin/catalog/productEdit/variants/New.jsx +2 -2
- package/src/components/admin/catalog/productEdit/variants/Search.jsx +1 -1
- package/src/components/admin/catalog/productEdit/variants/SearchModal.jsx +1 -1
- package/src/components/admin/catalog/productEdit/variants/VariantModal.jsx +6 -6
- package/src/components/admin/catalog/productGrid/rows/ThumbnailRow.jsx +1 -1
- package/src/components/admin/checkout/shippingSetting/Method.jsx +6 -6
- package/src/components/admin/checkout/shippingSetting/MethodForm.jsx +4 -4
- package/src/components/admin/checkout/shippingSetting/Methods.jsx +3 -3
- package/src/components/admin/checkout/shippingSetting/PriceBasedPrice.jsx +2 -2
- package/src/components/admin/checkout/shippingSetting/WeightBasedPrice.jsx +2 -2
- package/src/components/admin/checkout/shippingSetting/Zone.jsx +7 -7
- package/src/components/admin/checkout/shippingSetting/ZoneForm.jsx +1 -1
- package/src/components/admin/cms/Card.jsx +3 -3
- package/src/components/admin/cms/PageHeading.jsx +3 -3
- package/src/components/admin/cms/widget/WidgetTypes.jsx +28 -0
- package/src/components/admin/cms/widget/grid/WidgetTypeRow.jsx +29 -0
- package/src/components/admin/oms/orderEdit/items/ItemVariantOptions.jsx +1 -1
- package/src/components/admin/oms/orderEdit/items/Name.jsx +1 -1
- package/src/components/admin/oms/orderGrid/headers/OrderDateColumnHeader.jsx +1 -1
- package/src/components/admin/promotion/couponEdit/AttributeGroupSelector.jsx +3 -3
- package/src/components/admin/promotion/couponEdit/BuyXGetY.jsx +2 -2
- package/src/components/admin/promotion/couponEdit/CategorySelector.jsx +6 -6
- package/src/components/admin/promotion/couponEdit/CollectionSelector.jsx +3 -3
- package/src/components/admin/promotion/couponEdit/ProductSkuSelector.jsx +4 -4
- package/src/components/admin/promotion/couponEdit/RequireProducts.jsx +2 -2
- package/src/components/admin/promotion/couponEdit/Setting.jsx +1 -1
- package/src/components/admin/promotion/couponEdit/TargetProducts.jsx +4 -4
- package/src/components/admin/tax/taxSetting/Rate.jsx +6 -6
- package/src/components/admin/tax/taxSetting/RateForm.jsx +5 -5
- package/src/components/admin/tax/taxSetting/Rates.jsx +6 -6
- package/src/components/admin/tax/taxSetting/TaxClass.jsx +3 -3
- package/src/components/admin/tax/taxSetting/TaxClassForm.jsx +1 -1
- package/src/components/admin/widgets/BasicMenuSetting.jsx +614 -0
- package/src/components/admin/widgets/BasicMenuSetting.scss +19 -0
- package/src/components/admin/widgets/CollectionProductsSetting.jsx +203 -0
- package/src/components/admin/widgets/TextBlockSetting.jsx +70 -0
- package/src/components/common/Area.jsx +31 -8
- package/src/components/common/Badge.jsx +1 -1
- package/src/components/common/Editor.jsx +193 -0
- package/src/components/common/Notification.scss +1 -0
- package/src/components/common/SimplePagination.jsx +2 -2
- package/src/components/common/form/Form.jsx +1 -1
- package/src/components/common/form/fields/Checkbox.jsx +1 -1
- package/src/components/common/form/fields/Ckeditor.jsx +11 -11
- package/src/components/common/form/fields/Editor.jsx +326 -0
- package/src/components/common/form/fields/Editor.scss +33 -0
- package/src/components/common/form/fields/Radio.jsx +1 -1
- package/src/components/common/form/fields/editor/FileBrowser.jsx +419 -0
- package/src/components/common/form/fields/editor/FileBrowser.scss +37 -0
- package/src/components/common/form/fields/editor/GetColumnClasses.jsx +14 -0
- package/src/components/common/form/fields/editor/GetRowClasses.jsx +18 -0
- package/src/components/common/form/fields/editor/RowTemplates.jsx +154 -0
- package/src/components/common/grid/Pagination.jsx +4 -4
- package/src/components/common/grid/headers/FromTo.jsx +1 -1
- package/src/components/common/grid/headers/Sortable.jsx +1 -1
- package/src/components/common/grid/rows/ThumbnailRow.jsx +1 -1
- package/src/components/common/list/Filter.jsx +1 -1
- package/src/components/common/modal/Alert.jsx +1 -1
- package/src/components/common/modal/Modal.jsx +1 -1
- package/src/components/frontStore/catalog/categoryView/filter/AttributeFilter.jsx +2 -2
- package/src/components/frontStore/catalog/categoryView/filter/CategoryFilter.jsx +3 -2
- package/src/components/frontStore/catalog/categoryView/filter/CategoryFilter.scss +5 -0
- package/src/components/frontStore/catalog/product/list/List.jsx +4 -4
- package/src/components/frontStore/catalog/product/list/Pagination.jsx +1 -1
- package/src/components/frontStore/catalog/product/list/Sorting.jsx +2 -2
- package/src/components/frontStore/catalog/product/list/item/Name.jsx +1 -1
- package/src/components/frontStore/checkout/cart/Empty.jsx +3 -3
- package/src/components/frontStore/checkout/cart/items/ItemOptions.jsx +1 -1
- package/src/components/frontStore/checkout/cart/items/ItemVariantOptions.jsx +1 -1
- package/src/components/frontStore/checkout/cart/items/Items.jsx +20 -21
- package/src/components/frontStore/checkout/cart/items/Items.scss +47 -0
- package/src/components/frontStore/checkout/cart/items/Quantity.jsx +154 -0
- package/src/components/frontStore/checkout/checkout/StepTitle.jsx +1 -1
- package/src/components/frontStore/checkout/checkout/payment/paymentStep/StepContent.jsx +5 -5
- package/src/components/frontStore/checkout/checkout/shipment/StepContent.jsx +1 -1
- package/src/components/frontStore/checkout/checkout/summary/Cart.jsx +10 -12
- package/src/components/frontStore/checkout/checkout/summary/Items.jsx +9 -9
- package/src/components/frontStore/checkout/checkout/summary/cart/Total.jsx +6 -6
- package/src/components/frontStore/checkout/success/summary/items/ItemOptions.jsx +1 -1
- package/src/components/frontStore/checkout/success/summary/items/Items.jsx +9 -6
- package/src/components/frontStore/checkout/success/summary/order/OrderSummary.jsx +9 -13
- package/src/components/frontStore/checkout/success/summary/order/Total.jsx +5 -5
- package/src/components/frontStore/customer/address/addressForm/AddressFormLoadingSkeleton.jsx +2 -2
- package/src/components/frontStore/customer/address/addressForm/NameAndTelephone.jsx +1 -1
- package/src/components/frontStore/customer/address/addressForm/ProvinceAndPostcode.jsx +1 -1
- package/src/components/frontStore/customer/checkout/Edit.jsx +2 -2
- package/src/components/frontStore/customer/detail/Order.jsx +4 -4
- package/src/components/frontStore/stripe/checkout/CheckoutForm.jsx +2 -2
- package/src/components/frontStore/stripe/checkout/TestCards.jsx +1 -1
- package/src/components/frontStore/widgets/BasicMenu.jsx +129 -0
- package/src/{modules/catalog/pages/frontStore/homepage/FeaturedProducts.jsx → components/frontStore/widgets/CollectionProducts.jsx} +40 -32
- package/src/components/frontStore/widgets/TextBlock.jsx +46 -0
- package/src/lib/componee/getComponentsByRoute.js +15 -2
- package/src/lib/event/event-manager.js +1 -1
- package/src/lib/middleware/tests/app/modules/404page/pages/frontStore/product/route.json +2 -1
- package/src/lib/middlewares/static.js +3 -1
- package/src/lib/response/render.js +5 -6
- package/src/lib/router/Router.js +1 -1
- package/src/lib/router/loadModuleRoutes.js +3 -0
- package/src/lib/router/registerAdminRoute.js +9 -1
- package/src/lib/router/registerFrontStoreRoute.js +2 -0
- package/src/lib/router/scanForRoutes.js +1 -0
- package/src/lib/router/tests/unit/unit.validateRoute.test.js +7 -1
- package/src/lib/util/defaultPaginationFilters.js +19 -17
- package/src/lib/util/getEnabledWidgets.js +34 -0
- package/src/lib/util/merge.js +67 -14
- package/src/lib/util/tests/unit/util.merge.test.js +21 -4
- package/src/lib/util/validateConfiguration.js +83 -0
- package/src/lib/webpack/createBaseConfig.js +4 -1
- package/src/lib/webpack/dev/createConfigClient.js +10 -2
- package/src/lib/webpack/loaders/AreaLoader.js +16 -6
- package/src/lib/webpack/util/keyGenerator.js +9 -0
- package/src/lib/webpack/util/parseGraphql.js +30 -16
- package/src/lib/webpack/util/parseGraphqlByFile.js +16 -2
- package/src/modules/auth/pages/admin/adminLogin/LoginForm.jsx +54 -21
- package/src/modules/auth/pages/admin/all/AdminUser.jsx +3 -3
- package/src/modules/base/bootstrap.js +79 -0
- package/src/modules/base/graphql/types/Route/Route.admin.graphql +15 -0
- package/src/modules/base/graphql/types/Route/Route.admin.resolvers.js +10 -0
- package/src/modules/base/pages/global/response[errorHandler].js +25 -1
- package/src/modules/catalog/bootstrap.js +125 -5
- package/src/modules/catalog/graphql/types/Category/Category.graphql +4 -3
- package/src/modules/catalog/graphql/types/Category/Category.resolvers.js +34 -0
- package/src/modules/catalog/graphql/types/Collection/Collection.graphql +2 -2
- package/src/modules/catalog/graphql/types/Collection/Collection.resolvers.js +34 -0
- package/src/modules/catalog/graphql/types/Product/Attribute/ProductAttribute.resolvers.js +1 -0
- package/src/modules/catalog/graphql/types/Product/Product.graphql +1 -1
- package/src/modules/catalog/graphql/types/Product/Product.resolvers.js +34 -0
- package/src/modules/catalog/graphql/types/Widget/CollectionProductsWidget/CollectionProductsWidget.graphql +11 -0
- package/src/modules/catalog/graphql/types/Widget/CollectionProductsWidget/CollectionProductsWidget.resolvers.js +8 -0
- package/src/modules/catalog/migration/Version-1.0.0.js +1 -0
- package/src/modules/catalog/migration/Version-1.0.7.js +10 -0
- package/src/modules/catalog/pages/admin/attributeEdit+attributeNew/FormContent.jsx +4 -4
- package/src/modules/catalog/pages/admin/attributeEdit+attributeNew/General.jsx +5 -5
- package/src/modules/catalog/pages/admin/attributeGrid/Grid.jsx +2 -2
- package/src/modules/catalog/pages/admin/categoryEdit/Products.jsx +4 -4
- package/src/modules/catalog/pages/admin/categoryEdit+categoryNew/FormContent.jsx +4 -4
- package/src/modules/catalog/pages/admin/categoryEdit+categoryNew/General.jsx +16 -18
- package/src/modules/catalog/pages/admin/categoryEdit+categoryNew/Image.jsx +1 -2
- package/src/modules/catalog/pages/admin/categoryEdit+categoryNew/Status.jsx +16 -1
- package/src/modules/catalog/pages/admin/categoryGrid/Grid.jsx +3 -3
- package/src/modules/catalog/pages/admin/collectionEdit/Products.jsx +4 -4
- package/src/modules/catalog/pages/admin/collectionEdit+collectionNew/FormContent.jsx +2 -2
- package/src/modules/catalog/pages/admin/collectionEdit+collectionNew/General.jsx +2 -2
- package/src/modules/catalog/pages/admin/collectionGrid/Grid.jsx +3 -3
- package/src/modules/catalog/pages/admin/productEdit/Collection.jsx +7 -7
- package/src/modules/catalog/pages/admin/productEdit+productNew/Attributes.jsx +8 -3
- package/src/modules/catalog/pages/admin/productEdit+productNew/CustomOptions.jsss +4 -4
- package/src/modules/catalog/pages/admin/productEdit+productNew/FormContent.jsx +4 -4
- package/src/modules/catalog/pages/admin/productEdit+productNew/General.jsx +15 -17
- package/src/modules/catalog/pages/admin/productGrid/Grid.jsx +3 -3
- package/src/modules/catalog/pages/frontStore/catalogSearch/General.jsx +2 -2
- package/src/modules/catalog/pages/frontStore/catalogSearch/Products.jsx +1 -1
- package/src/modules/catalog/pages/frontStore/catalogSearch/route.json +2 -1
- package/src/modules/catalog/pages/frontStore/categoryView/CategoryView.jsx +19 -2
- package/src/modules/catalog/pages/frontStore/categoryView/Filter.scss +1 -0
- package/src/modules/catalog/pages/frontStore/categoryView/General.jsx +6 -8
- package/src/modules/catalog/pages/frontStore/categoryView/General.scss +0 -2
- package/src/modules/catalog/pages/frontStore/categoryView/Pagination.jsx +6 -0
- package/src/modules/catalog/pages/frontStore/categoryView/Products.jsx +8 -1
- package/src/modules/catalog/pages/frontStore/categoryView/route.json +2 -1
- package/src/modules/catalog/pages/frontStore/productView/Description.jsx +15 -4
- package/src/modules/catalog/pages/frontStore/productView/Form.jsx +4 -4
- package/src/modules/catalog/pages/frontStore/productView/Form.scss +1 -0
- package/src/modules/catalog/pages/frontStore/productView/GeneralInfo.jsx +1 -1
- package/src/modules/catalog/pages/frontStore/productView/Images.jsx +1 -1
- package/src/modules/catalog/pages/frontStore/productView/Layout.jsx +1 -1
- package/src/modules/catalog/pages/frontStore/productView/Options.jsx +7 -3
- package/src/modules/catalog/pages/frontStore/productView/Variants.jsx +6 -6
- package/src/modules/catalog/pages/frontStore/productView/route.json +2 -1
- package/src/modules/catalog/services/AttributeCollection.js +10 -10
- package/src/modules/catalog/services/AttributeGroupCollection.js +10 -10
- package/src/modules/catalog/services/CategoryCollection.js +10 -10
- package/src/modules/catalog/services/CollectionCollection.js +10 -10
- package/src/modules/catalog/services/registerCartItemProductUrlField.js +35 -0
- package/src/modules/catalog/services/registerCartItemVariantOptionsField.js +51 -0
- package/src/modules/catalog/services/registerDefaultCategoryCollectionFilters.js +16 -0
- package/src/modules/checkout/api/addShippingNote/[context]bodyParser[auth].js +5 -0
- package/src/modules/checkout/api/addShippingNote/payloadSchema.json +15 -0
- package/src/modules/checkout/api/addShippingNote/route.json +5 -0
- package/src/modules/checkout/api/addShippingNote/saveShippingNote.js +50 -0
- package/src/modules/checkout/api/createCart/createNewCart.js +28 -3
- package/src/modules/checkout/api/updateCartItemQty/[bodyParser]updateQty.js +49 -0
- package/src/modules/checkout/api/updateCartItemQty/[context]bodyParser[auth].js +5 -0
- package/src/modules/checkout/api/updateCartItemQty/payloadSchema.json +21 -0
- package/src/modules/checkout/api/updateCartItemQty/route.json +5 -0
- package/src/modules/checkout/api/updateMineCartItemQty/[context]bodyParser[auth].js +5 -0
- package/src/modules/checkout/api/updateMineCartItemQty/[detectCurrentCart]updateQty.js +51 -0
- package/src/modules/checkout/api/updateMineCartItemQty/[getCurrentCustomer]detectCurrentCart.js +32 -0
- package/src/modules/checkout/api/updateMineCartItemQty/payloadSchema.json +21 -0
- package/src/modules/checkout/api/updateMineCartItemQty/route.json +5 -0
- package/src/modules/checkout/bootstrap.js +27 -0
- package/src/modules/checkout/graphql/types/Cart/Cart.graphql +22 -3
- package/src/modules/checkout/graphql/types/Cart/Cart.resolvers.js +18 -2
- package/src/modules/checkout/graphql/types/CheckoutSetting/CheckoutSetting.graphql +3 -0
- package/src/modules/checkout/graphql/types/CheckoutSetting/CheckoutSetting.resolvers.js +7 -0
- package/src/modules/checkout/migration/Version-1.0.0.js +14 -0
- package/src/modules/checkout/migration/Version-1.0.6.js +201 -0
- package/src/modules/checkout/pages/admin/shippingSetting/ShippingSetting.jsx +2 -2
- package/src/modules/checkout/pages/frontStore/all/[context]detectCurrentCart[auth].js +5 -0
- package/src/modules/checkout/pages/frontStore/cart/ShoppingCart.jsx +20 -12
- package/src/modules/checkout/pages/frontStore/cart/Summary.jsx +34 -23
- package/src/modules/checkout/pages/frontStore/cart/route.json +2 -1
- package/src/modules/checkout/pages/frontStore/checkout/Checkout.jsx +5 -5
- package/src/modules/checkout/pages/frontStore/checkout/Checkout.scss +4 -0
- package/src/modules/checkout/pages/frontStore/checkout/ShippingMethods.jsx +2 -2
- package/src/modules/checkout/pages/frontStore/checkout/ShippingNote.jsx +105 -0
- package/src/modules/checkout/pages/frontStore/checkout/Summary.jsx +14 -14
- package/src/modules/checkout/pages/frontStore/checkout/SummaryMobile.jsx +12 -15
- package/src/modules/checkout/pages/frontStore/checkout/route.json +2 -1
- package/src/modules/checkout/pages/frontStore/checkoutSuccess/CheckoutSuccess.jsx +1 -1
- package/src/modules/checkout/pages/frontStore/checkoutSuccess/CheckoutSuccess.scss +4 -0
- package/src/modules/checkout/pages/frontStore/checkoutSuccess/CustomerInfo.jsx +30 -32
- package/src/modules/checkout/pages/frontStore/checkoutSuccess/ShippingNote.jsx +47 -0
- package/src/modules/checkout/pages/frontStore/checkoutSuccess/Summary.jsx +12 -15
- package/src/modules/checkout/pages/frontStore/checkoutSuccess/route.json +2 -1
- package/src/modules/checkout/services/cart/Cart.js +31 -27
- package/src/modules/checkout/services/cart/registerCartBaseFields.js +133 -41
- package/src/modules/checkout/services/cart/registerCartItemBaseFields.js +300 -374
- package/src/modules/checkout/services/toPrice.js +1 -1
- package/src/modules/checkout/tests/basicSetup.js +85 -0
- package/src/modules/checkout/tests/coupons.js +82 -0
- package/src/modules/checkout/tests/products.js +67 -0
- package/src/modules/checkout/tests/taxRates.js +3 -0
- package/src/modules/checkout/tests/unit/discountAmount.test.js +60 -0
- package/src/modules/checkout/tests/unit/grandTotal.test.js +83 -0
- package/src/modules/checkout/tests/unit/lineTotal.test.js +92 -0
- package/src/modules/checkout/tests/unit/lineTotalWithDiscount.test.js +103 -0
- package/src/modules/checkout/tests/unit/productPrice.test.js +69 -0
- package/src/modules/checkout/tests/unit/subTotal.test.js +85 -0
- package/src/modules/checkout/tests/unit/subTotalWithDiscount.test.js +117 -0
- package/src/modules/checkout/tests/unit/taxAmount.test.js +68 -0
- package/src/modules/checkout/tests/unit/taxAmountRounding.test.js +277 -0
- package/src/modules/cms/api/createWidget/[context]bodyParser[auth].js +5 -0
- package/src/modules/cms/api/createWidget/createWidget[finish].js +17 -0
- package/src/modules/cms/api/createWidget/finish[apiResponse].js +27 -0
- package/src/modules/cms/api/createWidget/payloadSchema.json +18 -0
- package/src/modules/cms/api/createWidget/route.json +5 -0
- package/src/modules/cms/api/deleteWidget/deleteWidget.js +27 -0
- package/src/modules/cms/api/deleteWidget/route.json +5 -0
- package/src/modules/cms/api/updateWidget/[context]bodyParser[auth].js +5 -0
- package/src/modules/cms/api/updateWidget/finish[apiResponse].js +27 -0
- package/src/modules/cms/api/updateWidget/payloadSchema.json +18 -0
- package/src/modules/cms/api/updateWidget/route.json +5 -0
- package/src/modules/cms/api/updateWidget/updateWidget[finish].js +17 -0
- package/src/modules/cms/bootstrap.js +223 -3
- package/src/modules/cms/graphql/types/CmsPage/CmsPage.graphql +1 -2
- package/src/modules/cms/graphql/types/CmsPage/CmsPage.resolvers.js +35 -1
- package/src/modules/cms/graphql/types/Widget/Widget.graphql +91 -0
- package/src/modules/cms/graphql/types/Widget/Widget.resolvers.js +142 -0
- package/src/modules/cms/migration/Version-1.1.0.js +22 -0
- package/src/modules/cms/migration/Version-1.1.1.js +103 -0
- package/src/modules/cms/pages/admin/adminNotFound/NotFound.jsx +4 -4
- package/src/modules/cms/pages/admin/all/CmsMenuGroup.jsx +12 -4
- package/src/modules/cms/pages/admin/all/Notification.scss +1 -1
- package/src/modules/cms/pages/admin/all/search/NoResult.jsx +2 -2
- package/src/modules/cms/pages/admin/all/search/Results.jsx +3 -3
- package/src/modules/cms/pages/admin/cmsPageEdit+cmsPageNew/FormContent.jsx +7 -9
- package/src/modules/cms/pages/admin/cmsPageEdit+cmsPageNew/General.jsx +3 -3
- package/src/modules/cms/pages/admin/cmsPageEdit+cmsPageNew/Seo.jsx +1 -1
- package/src/modules/cms/pages/admin/cmsPageEdit+cmsPageNew/Status.jsx +40 -0
- package/src/modules/cms/pages/admin/cmsPageGrid/Grid.jsx +3 -4
- package/src/modules/cms/pages/admin/dashboard/Layout.jsx +3 -3
- package/src/modules/cms/pages/admin/widgetEdit/WidgetForm.jsx +52 -0
- package/src/modules/cms/pages/admin/widgetEdit/index.js +36 -0
- package/src/modules/cms/pages/admin/widgetEdit/route.json +4 -0
- package/src/modules/cms/pages/admin/widgetEdit+widgetNew/FormContent.jsx +69 -0
- package/src/modules/cms/pages/admin/widgetEdit+widgetNew/FormContent.scss +7 -0
- package/src/modules/cms/pages/admin/widgetEdit+widgetNew/General.jsx +185 -0
- package/src/modules/cms/pages/admin/widgetEdit+widgetNew/PageHeading.jsx +37 -0
- package/src/modules/cms/pages/admin/widgetEdit+widgetNew/Setting.jsx +55 -0
- package/src/modules/cms/pages/admin/widgetGrid/Grid.jsx +415 -0
- package/src/modules/cms/pages/admin/widgetGrid/Heading.jsx +11 -0
- package/src/modules/cms/pages/admin/widgetGrid/NewWidgetButton.jsx +52 -0
- package/src/modules/cms/pages/admin/widgetGrid/index.js +15 -0
- package/src/modules/cms/pages/admin/widgetGrid/route.json +4 -0
- package/src/modules/cms/pages/admin/widgetNew/WidgetNewForm.jsx +60 -0
- package/src/modules/cms/pages/admin/widgetNew/index.js +11 -0
- package/src/modules/cms/pages/admin/widgetNew/route.json +4 -0
- package/src/modules/cms/pages/admin/widgetNew/typeValidate.js +21 -0
- package/src/modules/cms/pages/frontStore/all/Breadcrumb.jsx +1 -1
- package/src/modules/cms/pages/frontStore/all/Footer.jsx +2 -2
- package/src/modules/cms/pages/frontStore/all/Layout.jsx +3 -3
- package/src/modules/cms/pages/frontStore/all/Layout.scss +13 -0
- package/src/modules/cms/pages/frontStore/all/Logo.jsx +2 -2
- package/src/modules/cms/pages/frontStore/all/Logo.scss +2 -4
- package/src/modules/cms/pages/frontStore/all/Notification.scss +1 -1
- package/src/modules/cms/pages/frontStore/cmsPageView/Layout.jsx +2 -2
- package/src/modules/cms/pages/frontStore/cmsPageView/View.jsx +5 -3
- package/src/modules/cms/pages/frontStore/cmsPageView/index.js +6 -12
- package/src/modules/cms/pages/frontStore/cmsPageView/route.json +2 -1
- package/src/modules/cms/pages/frontStore/homepage/route.json +2 -1
- package/src/modules/cms/pages/frontStore/notFound/NotFound.jsx +4 -4
- package/src/modules/cms/pages/frontStore/notFound/route.json +2 -1
- package/src/modules/cms/pages/frontStore/staticAsset/[context]staticAssets[auth].js +1 -1
- package/src/modules/cms/services/CMSPageCollection.js +10 -10
- package/src/modules/cms/services/WidgetCollection.js +62 -0
- package/src/modules/cms/services/getWidgetsBaseQuery.js +7 -0
- package/src/modules/cms/services/page/createPage.js +1 -2
- package/src/modules/cms/services/page/pageDataSchema.json +0 -4
- package/src/modules/cms/services/registerDefaultWidgetCollectionFilters.js +62 -0
- package/src/modules/cms/services/tailwind.admin.config.js +22 -107
- package/src/modules/cms/services/tailwind.frontStore.config.js +23 -108
- package/src/modules/cms/services/widget/createWidget.js +73 -0
- package/src/modules/cms/services/widget/deleteWidget.js +49 -0
- package/src/modules/cms/services/widget/loadWidgetInstances.js +54 -0
- package/src/modules/cms/services/widget/updateWidget.js +86 -0
- package/src/modules/cms/services/widget/widgetDataSchema.json +29 -0
- package/src/modules/cod/pages/admin/paymentSetting/CODSetting.jsx +2 -2
- package/src/modules/cod/pages/frontStore/checkout/CashOnDelivery.jsx +1 -1
- package/src/modules/customer/bootstrap.js +21 -4
- package/src/modules/customer/pages/admin/customerEdit/CustomerEditForm.jsx +3 -3
- package/src/modules/customer/pages/admin/customerEdit+customerNew/OrderHistory.jsx +1 -1
- package/src/modules/customer/pages/admin/customerGrid/Grid.jsx +3 -3
- package/src/modules/customer/pages/frontStore/account/AccountDetails.jsx +3 -3
- package/src/modules/customer/pages/frontStore/account/Layout.jsx +3 -3
- package/src/modules/customer/pages/frontStore/account/OrderHistory.jsx +1 -1
- package/src/modules/customer/pages/frontStore/account/route.json +2 -1
- package/src/modules/customer/pages/frontStore/login/LoginForm.jsx +2 -2
- package/src/modules/customer/pages/frontStore/login/route.json +2 -1
- package/src/modules/customer/pages/frontStore/register/RegisterForm.jsx +2 -2
- package/src/modules/customer/pages/frontStore/register/route.json +2 -1
- package/src/modules/customer/pages/frontStore/resetPasswordPage/ResetPasswordForm.jsx +2 -2
- package/src/modules/customer/pages/frontStore/resetPasswordPage/route.json +2 -1
- package/src/modules/customer/pages/frontStore/updatePasswordPage/UpdatePasswordForm.jsx +3 -3
- package/src/modules/customer/pages/frontStore/updatePasswordPage/route.json +2 -1
- package/src/modules/customer/services/CustomerCollection.js +10 -10
- package/src/modules/customer/services/CustomerGroupCollection.js +10 -10
- package/src/modules/graphql/pages/global/[bodyParser]buildQuery[graphql].js +241 -6
- package/src/modules/graphql/pages/global/[buildQuery]graphql[notification].js +12 -8
- package/src/modules/oms/bootstrap.js +87 -3
- package/src/modules/oms/graphql/types/Order/Order.graphql +11 -2
- package/src/modules/oms/graphql/types/Order/Order.resolvers.js +7 -1
- package/src/modules/oms/pages/admin/dashboard/Bestsellers.jsx +2 -2
- package/src/modules/oms/pages/admin/dashboard/Lifetimesales.jsx +5 -5
- package/src/modules/oms/pages/admin/orderEdit/AddTrackingButton.jsx +1 -1
- package/src/modules/oms/pages/admin/orderEdit/Items.jsx +7 -7
- package/src/modules/oms/pages/admin/orderEdit/Layout.jsx +3 -3
- package/src/modules/oms/pages/admin/orderEdit/Payment.jsx +6 -6
- package/src/modules/oms/pages/admin/orderEdit/ShipButton.jsx +1 -1
- package/src/modules/oms/pages/admin/orderGrid/Grid.jsx +3 -3
- package/src/modules/oms/services/OrderCollection.js +10 -10
- package/src/modules/paypal/api/paypalCreateOrder/[bodyParser]createOrder.js +55 -24
- package/src/modules/paypal/pages/admin/paymentSetting/PaypalSetting.jsx +6 -6
- package/src/modules/paypal/pages/frontStore/checkout/Paypal.jsx +3 -4
- package/src/modules/promotion/bootstrap.js +19 -101
- package/src/modules/promotion/pages/admin/couponEdit+couponNew/DiscountType.jsx +1 -1
- package/src/modules/promotion/pages/admin/couponEdit+couponNew/FormContent.jsx +5 -5
- package/src/modules/promotion/pages/admin/couponGrid/Grid.jsx +3 -3
- package/src/modules/promotion/pages/frontStore/cart/Coupon.jsx +2 -2
- package/src/modules/promotion/services/CouponCollection.js +10 -10
- package/src/modules/promotion/services/couponValidator.js +4 -7
- package/src/modules/promotion/services/discountCalculator.js +2 -7
- package/src/modules/promotion/services/registerCartItemPromotionFields.js +80 -0
- package/src/modules/promotion/services/registerCartPromotionFields.js +128 -0
- package/src/modules/promotion/services/registerDefaultCalculators.js +48 -20
- package/src/modules/promotion/services/registerDefaultValidators.js +16 -4
- package/src/modules/setting/pages/admin/paymentSetting/PaymentSetting.jsx +2 -2
- package/src/modules/setting/pages/admin/storeSetting/StoreSetting.jsx +98 -35
- package/src/modules/stripe/pages/admin/paymentSetting/StripePayment.jsx +5 -5
- package/src/modules/stripe/pages/frontStore/checkout/Stripe.jsx +1 -1
- package/src/modules/tax/bootstrap.js +40 -5
- package/src/modules/tax/graphql/types/Product/Price/ProductPrice.resolvers.js +6 -39
- package/src/modules/tax/graphql/types/TaxSetting/TaxSetting.graphql +1 -2
- package/src/modules/tax/graphql/types/TaxSetting/TaxSetting.resolvers.js +1 -8
- package/src/modules/tax/pages/admin/taxSetting/TaxSetting.jsx +4 -4
- package/src/modules/tax/services/TaxClassCollection.js +10 -10
- package/src/modules/tax/services/calculateTaxAmount.js +12 -9
- package/src/modules/tax/services/registerCartItemTaxPercentField.js +76 -0
- package/src/modules/auth/services/adminSessionMiddleware.js +0 -0
- package/src/modules/catalog/pages/frontStore/homepage/FeaturedCategories.jsx +0 -58
- package/src/modules/cms/pages/admin/cmsPageEdit+cmsPageNew/StatusAndLayout.jsx +0 -61
- package/src/modules/cms/pages/frontStore/all/Menu.jsx +0 -46
- package/src/modules/cms/pages/frontStore/all/Menu.scss +0 -7
- package/src/modules/cms/pages/frontStore/all/MobileMenu.jsx +0 -73
- package/src/modules/cms/pages/frontStore/all/MobileMenu.scss +0 -35
- package/src/modules/cms/pages/frontStore/homepage/MainBanner.jsx +0 -31
- package/src/modules/cms/pages/frontStore/homepage/MainBanner.scss +0 -48
|
@@ -24,16 +24,16 @@ class CategoryCollection {
|
|
|
24
24
|
);
|
|
25
25
|
|
|
26
26
|
categoryCollectionFilters.forEach((filter) => {
|
|
27
|
-
const check = filters.find(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
const check = filters.find(
|
|
28
|
+
(f) => f.key === filter.key && filter.operation.includes(f.operation)
|
|
29
|
+
);
|
|
30
|
+
if (filter.key === '*' || check) {
|
|
31
|
+
filter.callback(
|
|
32
|
+
this.baseQuery,
|
|
33
|
+
check?.operation,
|
|
34
|
+
check?.value,
|
|
35
|
+
currentFilters
|
|
36
|
+
);
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
|
|
@@ -18,16 +18,16 @@ class CollectionCollection {
|
|
|
18
18
|
);
|
|
19
19
|
|
|
20
20
|
collectionCollectionFilters.forEach((filter) => {
|
|
21
|
-
const check = filters.find(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
const check = filters.find(
|
|
22
|
+
(f) => f.key === filter.key && filter.operation.includes(f.operation)
|
|
23
|
+
);
|
|
24
|
+
if (filter.key === '*' || check) {
|
|
25
|
+
filter.callback(
|
|
26
|
+
this.baseQuery,
|
|
27
|
+
check?.operation,
|
|
28
|
+
check?.value,
|
|
29
|
+
currentFilters
|
|
30
|
+
);
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
33
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const { pool } = require('@evershop/evershop/src/lib/postgres/connection');
|
|
2
|
+
const { buildUrl } = require('@evershop/evershop/src/lib/router/buildUrl');
|
|
3
|
+
const { select } = require('@evershop/postgres-query-builder');
|
|
4
|
+
|
|
5
|
+
module.exports = exports = {};
|
|
6
|
+
|
|
7
|
+
exports.registerCartItemProductUrlField = (fields) => {
|
|
8
|
+
const newFields = fields.concat([
|
|
9
|
+
{
|
|
10
|
+
key: 'productUrl',
|
|
11
|
+
resolvers: [
|
|
12
|
+
async function resolver() {
|
|
13
|
+
const product = await this.getProduct();
|
|
14
|
+
if (!this.getData('product_id')) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const urlRewrite = await select()
|
|
18
|
+
.from('url_rewrite')
|
|
19
|
+
.where('entity_uuid', '=', product.uuid)
|
|
20
|
+
.and('entity_type', '=', 'product')
|
|
21
|
+
.load(pool);
|
|
22
|
+
if (!urlRewrite) {
|
|
23
|
+
return buildUrl('productView', {
|
|
24
|
+
uuid: product.uuid
|
|
25
|
+
});
|
|
26
|
+
} else {
|
|
27
|
+
return urlRewrite.request_path;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
dependencies: ['product_id']
|
|
32
|
+
}
|
|
33
|
+
]);
|
|
34
|
+
return newFields;
|
|
35
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const { pool } = require('@evershop/evershop/src/lib/postgres/connection');
|
|
2
|
+
const { select } = require('@evershop/postgres-query-builder');
|
|
3
|
+
|
|
4
|
+
module.exports = exports = {};
|
|
5
|
+
|
|
6
|
+
exports.registerCartItemVariantOptionsField = (fields) => {
|
|
7
|
+
const newFields = fields.concat([
|
|
8
|
+
{
|
|
9
|
+
key: 'variant_options',
|
|
10
|
+
resolvers: [
|
|
11
|
+
async function resolver() {
|
|
12
|
+
const product = await this.getProduct();
|
|
13
|
+
if (product.variant_group_id) {
|
|
14
|
+
const group = await select('attribute_one')
|
|
15
|
+
.select('attribute_two')
|
|
16
|
+
.select('attribute_three')
|
|
17
|
+
.select('attribute_four')
|
|
18
|
+
.select('attribute_five')
|
|
19
|
+
.from('variant_group')
|
|
20
|
+
.where('variant_group_id', '=', product.variant_group_id)
|
|
21
|
+
.load(pool);
|
|
22
|
+
if (!group) {
|
|
23
|
+
return null;
|
|
24
|
+
} else {
|
|
25
|
+
const query = select('a.attribute_code')
|
|
26
|
+
.select('a.attribute_name')
|
|
27
|
+
.select('a.attribute_id')
|
|
28
|
+
.select('o.option_id')
|
|
29
|
+
.select('o.option_text')
|
|
30
|
+
.from('attribute', 'a');
|
|
31
|
+
query
|
|
32
|
+
.innerJoin('product_attribute_value_index', 'o')
|
|
33
|
+
.on('a.attribute_id', '=', 'o.attribute_id');
|
|
34
|
+
query.where('o.product_id', '=', product.product_id).and(
|
|
35
|
+
'a.attribute_id',
|
|
36
|
+
'IN',
|
|
37
|
+
Object.values(group).filter((v) => v != null)
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
return JSON.stringify(await query.execute(pool));
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
dependencies: ['variant_group_id']
|
|
48
|
+
}
|
|
49
|
+
]);
|
|
50
|
+
return newFields;
|
|
51
|
+
};
|
|
@@ -51,6 +51,22 @@ module.exports = async function registerDefaultCategoryCollectionFilters() {
|
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
|
+
{
|
|
55
|
+
key: 'parent',
|
|
56
|
+
operation: ['eq'],
|
|
57
|
+
callback: (query, operation, value, currentFilters) => {
|
|
58
|
+
if (value === null) {
|
|
59
|
+
query.andWhere('category.parent_id', 'IS NULL');
|
|
60
|
+
} else {
|
|
61
|
+
query.andWhere('category.parent_id', OPERATION_MAP[operation], value);
|
|
62
|
+
}
|
|
63
|
+
currentFilters.push({
|
|
64
|
+
key: 'parent',
|
|
65
|
+
operation,
|
|
66
|
+
value
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
},
|
|
54
70
|
{
|
|
55
71
|
key: 'ob',
|
|
56
72
|
operation: ['eq'],
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/* eslint-disable camelcase */
|
|
2
|
+
const {
|
|
3
|
+
OK,
|
|
4
|
+
INTERNAL_SERVER_ERROR,
|
|
5
|
+
INVALID_PAYLOAD
|
|
6
|
+
} = require('@evershop/evershop/src/lib/util/httpStatus');
|
|
7
|
+
const { error } = require('@evershop/evershop/src/lib/log/logger');
|
|
8
|
+
const {
|
|
9
|
+
translate
|
|
10
|
+
} = require('@evershop/evershop/src/lib/locale/translate/translate');
|
|
11
|
+
const { getCartByUUID } = require('../../services/getCartByUUID');
|
|
12
|
+
const { saveCart } = require('../../services/saveCart');
|
|
13
|
+
|
|
14
|
+
module.exports = async (request, response, delegate, next) => {
|
|
15
|
+
try {
|
|
16
|
+
const { cart_id } = request.params;
|
|
17
|
+
const { note } = request.body;
|
|
18
|
+
// Check if cart exists
|
|
19
|
+
const cart = await getCartByUUID(cart_id);
|
|
20
|
+
if (!cart) {
|
|
21
|
+
response.status(INVALID_PAYLOAD).json({
|
|
22
|
+
error: {
|
|
23
|
+
message: 'Invalid cart',
|
|
24
|
+
status: INVALID_PAYLOAD
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
} else {
|
|
28
|
+
// Save shipping note
|
|
29
|
+
await cart.setData('shipping_note', note);
|
|
30
|
+
// Save the cart
|
|
31
|
+
await saveCart(cart);
|
|
32
|
+
response.status(OK);
|
|
33
|
+
response.$body = {
|
|
34
|
+
data: {
|
|
35
|
+
note
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
next();
|
|
39
|
+
}
|
|
40
|
+
} catch (e) {
|
|
41
|
+
error(e);
|
|
42
|
+
response.status(INTERNAL_SERVER_ERROR);
|
|
43
|
+
response.json({
|
|
44
|
+
error: {
|
|
45
|
+
message: translate('Failed to set shipping note'),
|
|
46
|
+
status: INTERNAL_SERVER_ERROR
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
};
|
|
@@ -4,10 +4,11 @@ const {
|
|
|
4
4
|
OK
|
|
5
5
|
} = require('@evershop/evershop/src/lib/util/httpStatus');
|
|
6
6
|
const { getConfig } = require('@evershop/evershop/src/lib/util/getConfig');
|
|
7
|
-
const { error } = require('@evershop/evershop/src/lib/log/logger');
|
|
8
7
|
const {
|
|
9
8
|
translate
|
|
10
9
|
} = require('@evershop/evershop/src/lib/locale/translate/translate');
|
|
10
|
+
const { select } = require('@evershop/postgres-query-builder');
|
|
11
|
+
const { pool } = require('@evershop/evershop/src/lib/postgres/connection');
|
|
11
12
|
const { setContextValue } = require('../../../graphql/services/contextHelper');
|
|
12
13
|
const { saveCart } = require('../../services/saveCart');
|
|
13
14
|
const { Cart } = require('../../services/cart/Cart');
|
|
@@ -60,10 +61,35 @@ module.exports = async (request, response, delegate, next) => {
|
|
|
60
61
|
},
|
|
61
62
|
[{ sku: items[0].sku, qty: 0 }]
|
|
62
63
|
);
|
|
64
|
+
const products = await select()
|
|
65
|
+
.from('product')
|
|
66
|
+
.where(
|
|
67
|
+
'sku',
|
|
68
|
+
'IN',
|
|
69
|
+
groupedItems.map((item) => item.sku)
|
|
70
|
+
)
|
|
71
|
+
.and('status', '=', 1)
|
|
72
|
+
.execute(pool);
|
|
73
|
+
// Check if all products are available
|
|
74
|
+
if (products.length !== groupedItems.length) {
|
|
75
|
+
response.status(INVALID_PAYLOAD);
|
|
76
|
+
response.json({
|
|
77
|
+
error: {
|
|
78
|
+
status: INVALID_PAYLOAD,
|
|
79
|
+
message: translate('Some products are not available')
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
// Map the grouped items to include product_id
|
|
85
|
+
products.forEach((product) => {
|
|
86
|
+
const item = groupedItems.find((i) => i.sku === product.sku);
|
|
87
|
+
item.product_id = product.product_id;
|
|
88
|
+
});
|
|
63
89
|
// Loop through the grouped items and add them to the cart
|
|
64
90
|
const cartItems = await Promise.all(
|
|
65
91
|
groupedItems.map(async (item) => {
|
|
66
|
-
const cartItem = await cart.addItem(item.
|
|
92
|
+
const cartItem = await cart.addItem(item.product_id, item.qty);
|
|
67
93
|
return cartItem;
|
|
68
94
|
})
|
|
69
95
|
);
|
|
@@ -80,7 +106,6 @@ module.exports = async (request, response, delegate, next) => {
|
|
|
80
106
|
};
|
|
81
107
|
next();
|
|
82
108
|
} catch (e) {
|
|
83
|
-
error(e);
|
|
84
109
|
response.status(INTERNAL_SERVER_ERROR);
|
|
85
110
|
response.json({
|
|
86
111
|
error: {
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const {
|
|
2
|
+
INVALID_PAYLOAD,
|
|
3
|
+
INTERNAL_SERVER_ERROR,
|
|
4
|
+
OK
|
|
5
|
+
} = require('@evershop/evershop/src/lib/util/httpStatus');
|
|
6
|
+
const {
|
|
7
|
+
translate
|
|
8
|
+
} = require('@evershop/evershop/src/lib/locale/translate/translate');
|
|
9
|
+
const { error } = require('@evershop/evershop/src/lib/log/logger');
|
|
10
|
+
const { getCartByUUID } = require('../../services/getCartByUUID');
|
|
11
|
+
const { saveCart } = require('../../services/saveCart');
|
|
12
|
+
|
|
13
|
+
module.exports = async (request, response, delegate, next) => {
|
|
14
|
+
try {
|
|
15
|
+
const { cart_id, item_id } = request.params;
|
|
16
|
+
const cart = await getCartByUUID(cart_id);
|
|
17
|
+
if (!cart) {
|
|
18
|
+
response.status(INVALID_PAYLOAD);
|
|
19
|
+
response.json({
|
|
20
|
+
error: {
|
|
21
|
+
message: translate('Invalid cart'),
|
|
22
|
+
status: INVALID_PAYLOAD
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const { action, qty } = request.body;
|
|
28
|
+
const item = await cart.updateItemQty(item_id, qty, action);
|
|
29
|
+
await saveCart(cart);
|
|
30
|
+
response.status(OK);
|
|
31
|
+
response.$body = {
|
|
32
|
+
data: {
|
|
33
|
+
item: item.export(),
|
|
34
|
+
count: cart.getItems().length,
|
|
35
|
+
cartId: cart.getData('uuid')
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
next();
|
|
39
|
+
} catch (err) {
|
|
40
|
+
error(err);
|
|
41
|
+
response.status(INTERNAL_SERVER_ERROR);
|
|
42
|
+
response.json({
|
|
43
|
+
error: {
|
|
44
|
+
status: INTERNAL_SERVER_ERROR,
|
|
45
|
+
message: err.message
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "object",
|
|
3
|
+
"properties": {
|
|
4
|
+
"action": {
|
|
5
|
+
"type": "string",
|
|
6
|
+
"enum": ["increase", "decrease"]
|
|
7
|
+
},
|
|
8
|
+
"qty": {
|
|
9
|
+
"type": ["string", "integer"],
|
|
10
|
+
"pattern": "^[1-9][0-9]*$"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"required": ["action", "qty"],
|
|
14
|
+
"additionalProperties": true,
|
|
15
|
+
"errorMessage": {
|
|
16
|
+
"properties": {
|
|
17
|
+
"action": "Action is required. It must be either 'increase' or 'decrease'",
|
|
18
|
+
"qty": "Qty is invalid"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const {
|
|
2
|
+
INVALID_PAYLOAD,
|
|
3
|
+
INTERNAL_SERVER_ERROR,
|
|
4
|
+
OK
|
|
5
|
+
} = require('@evershop/evershop/src/lib/util/httpStatus');
|
|
6
|
+
const {
|
|
7
|
+
translate
|
|
8
|
+
} = require('@evershop/evershop/src/lib/locale/translate/translate');
|
|
9
|
+
const { error } = require('@evershop/evershop/src/lib/log/logger');
|
|
10
|
+
const { getCartByUUID } = require('../../services/getCartByUUID');
|
|
11
|
+
const { saveCart } = require('../../services/saveCart');
|
|
12
|
+
const { getContextValue } = require('../../../graphql/services/contextHelper');
|
|
13
|
+
|
|
14
|
+
module.exports = async (request, response, delegate, next) => {
|
|
15
|
+
try {
|
|
16
|
+
const { item_id } = request.params;
|
|
17
|
+
const cartId = getContextValue(request, 'cartId');
|
|
18
|
+
const cart = await getCartByUUID(cartId);
|
|
19
|
+
if (!cart) {
|
|
20
|
+
response.status(INVALID_PAYLOAD);
|
|
21
|
+
response.json({
|
|
22
|
+
error: {
|
|
23
|
+
message: translate('Invalid cart'),
|
|
24
|
+
status: INVALID_PAYLOAD
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const { action, qty } = request.body;
|
|
30
|
+
const item = await cart.updateItemQty(item_id, qty, action);
|
|
31
|
+
await saveCart(cart);
|
|
32
|
+
response.status(OK);
|
|
33
|
+
response.$body = {
|
|
34
|
+
data: {
|
|
35
|
+
item: item.export(),
|
|
36
|
+
count: cart.getItems().length,
|
|
37
|
+
cartId: cart.getData('uuid')
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
next();
|
|
41
|
+
} catch (err) {
|
|
42
|
+
error(err);
|
|
43
|
+
response.status(INTERNAL_SERVER_ERROR);
|
|
44
|
+
response.json({
|
|
45
|
+
error: {
|
|
46
|
+
status: INTERNAL_SERVER_ERROR,
|
|
47
|
+
message: err.message
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
};
|
package/src/modules/checkout/api/updateMineCartItemQty/[getCurrentCustomer]detectCurrentCart.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const { pool } = require('@evershop/evershop/src/lib/postgres/connection');
|
|
2
|
+
const { select } = require('@evershop/postgres-query-builder');
|
|
3
|
+
const { UNAUTHORIZED } = require('@evershop/evershop/src/lib/util/httpStatus');
|
|
4
|
+
const { setContextValue } = require('../../../graphql/services/contextHelper');
|
|
5
|
+
|
|
6
|
+
module.exports = async (request, response, delegate, next) => {
|
|
7
|
+
/**
|
|
8
|
+
* We firstly get the sessionID from the request.
|
|
9
|
+
* This API needs the client to send the session cookie in the request.
|
|
10
|
+
* Base on the sessionID, we can get the cart
|
|
11
|
+
*/
|
|
12
|
+
const { sessionID } = request.locals;
|
|
13
|
+
if (!sessionID) {
|
|
14
|
+
response.status(UNAUTHORIZED);
|
|
15
|
+
response.json({
|
|
16
|
+
error: {
|
|
17
|
+
status: UNAUTHORIZED,
|
|
18
|
+
message: 'Unauthorized'
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
} else {
|
|
22
|
+
const cart = await select()
|
|
23
|
+
.from('cart')
|
|
24
|
+
.where('sid', '=', sessionID)
|
|
25
|
+
.and('status', '=', 1)
|
|
26
|
+
.load(pool);
|
|
27
|
+
if (cart) {
|
|
28
|
+
setContextValue(request, 'cartId', cart.uuid);
|
|
29
|
+
}
|
|
30
|
+
next();
|
|
31
|
+
}
|
|
32
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "object",
|
|
3
|
+
"properties": {
|
|
4
|
+
"action": {
|
|
5
|
+
"type": "string",
|
|
6
|
+
"enum": ["increase", "decrease"]
|
|
7
|
+
},
|
|
8
|
+
"qty": {
|
|
9
|
+
"type": ["string", "integer"],
|
|
10
|
+
"pattern": "^[1-9][0-9]*$"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"required": ["action", "qty"],
|
|
14
|
+
"additionalProperties": true,
|
|
15
|
+
"errorMessage": {
|
|
16
|
+
"properties": {
|
|
17
|
+
"action": "Action is required. It must be either 'increase' or 'decrease'",
|
|
18
|
+
"qty": "Qty is invalid"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -8,6 +8,11 @@ const {
|
|
|
8
8
|
const {
|
|
9
9
|
registerCartItemBaseFields
|
|
10
10
|
} = require('./services/cart/registerCartItemBaseFields');
|
|
11
|
+
const {
|
|
12
|
+
getProductsBaseQuery
|
|
13
|
+
} = require('../catalog/services/getProductsBaseQuery');
|
|
14
|
+
const { pool } = require('../../lib/postgres/connection');
|
|
15
|
+
const { merge } = require('../../lib/util/merge');
|
|
11
16
|
|
|
12
17
|
module.exports = () => {
|
|
13
18
|
addProcessor('cartFields', registerCartBaseFields, 0);
|
|
@@ -33,4 +38,26 @@ module.exports = () => {
|
|
|
33
38
|
throw e;
|
|
34
39
|
}
|
|
35
40
|
});
|
|
41
|
+
|
|
42
|
+
addProcessor('cartItemProductLoaderFunction', () => async (id) => {
|
|
43
|
+
const productQuery = getProductsBaseQuery();
|
|
44
|
+
const product = await productQuery.where('product_id', '=', id).load(pool);
|
|
45
|
+
return product;
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
addProcessor('configuratonSchema', (schema) => {
|
|
49
|
+
merge(schema, {
|
|
50
|
+
properties: {
|
|
51
|
+
checkout: {
|
|
52
|
+
type: 'object',
|
|
53
|
+
properties: {
|
|
54
|
+
showShippingNote: {
|
|
55
|
+
type: 'boolean'
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return schema;
|
|
62
|
+
});
|
|
36
63
|
};
|
|
@@ -15,9 +15,12 @@ interface ShoppingCart {
|
|
|
15
15
|
shippingFeeInclTax: Price!
|
|
16
16
|
discountAmount: Price!
|
|
17
17
|
subTotal: Price!
|
|
18
|
+
subTotalWithDiscount: Price!
|
|
19
|
+
subTotalWithDiscountInclTax: Price!
|
|
18
20
|
totalQty: Int!
|
|
19
21
|
totalWeight: Weight!
|
|
20
22
|
taxAmount: Price!
|
|
23
|
+
taxAmountBeforeDiscount: Price!
|
|
21
24
|
grandTotal: Price!
|
|
22
25
|
shippingMethod: String
|
|
23
26
|
shippingMethodName: String
|
|
@@ -44,8 +47,12 @@ interface ShoppingCartItem {
|
|
|
44
47
|
finalPriceInclTax: Price!
|
|
45
48
|
taxPercent: Float!
|
|
46
49
|
taxAmount: Price!
|
|
50
|
+
taxAmountBeforeDiscount: Price!
|
|
47
51
|
discountAmount: Price!
|
|
48
|
-
|
|
52
|
+
lineTotal: Price!
|
|
53
|
+
lineTotalWithDiscount: Price!
|
|
54
|
+
lineTotalWithDiscountInclTax: Price!
|
|
55
|
+
lineTotalInclTax: Price!
|
|
49
56
|
variantGroupId: Int
|
|
50
57
|
variantOptions: String
|
|
51
58
|
productCustomOptions: String
|
|
@@ -90,6 +97,7 @@ type CartItem implements ShoppingCartItem {
|
|
|
90
97
|
uuid: String!
|
|
91
98
|
cartId: ID!
|
|
92
99
|
removeApi: String!
|
|
100
|
+
updateQtyApi: String!
|
|
93
101
|
productId: ID!
|
|
94
102
|
productSku: String!
|
|
95
103
|
productName: String
|
|
@@ -102,9 +110,14 @@ type CartItem implements ShoppingCartItem {
|
|
|
102
110
|
finalPriceInclTax: Price!
|
|
103
111
|
taxPercent: Float!
|
|
104
112
|
taxAmount: Price!
|
|
113
|
+
taxAmountBeforeDiscount: Price!
|
|
105
114
|
discountAmount: Price!
|
|
106
|
-
|
|
107
|
-
|
|
115
|
+
lineTotal: Price!
|
|
116
|
+
subTotal: Price! # Deprecated, this field is equivalent to lineTotal
|
|
117
|
+
lineTotalWithDiscount: Price!
|
|
118
|
+
lineTotalWithDiscountInclTax: Price!
|
|
119
|
+
lineTotalInclTax: Price!
|
|
120
|
+
total: Price! # Deprecated, this field is equivalent to lineTotalInclTax
|
|
108
121
|
variantGroupId: Int
|
|
109
122
|
variantOptions: String
|
|
110
123
|
productCustomOptions: String
|
|
@@ -132,12 +145,17 @@ type Cart implements ShoppingCart {
|
|
|
132
145
|
coupon: String
|
|
133
146
|
shippingFeeExclTax: Price!
|
|
134
147
|
shippingFeeInclTax: Price!
|
|
148
|
+
shippingTaxAmount: Price!
|
|
135
149
|
discountAmount: Price!
|
|
136
150
|
subTotal: Price!
|
|
137
151
|
subTotalInclTax: Price!
|
|
152
|
+
subTotalWithDiscount: Price!
|
|
153
|
+
subTotalWithDiscountInclTax: Price!
|
|
138
154
|
totalQty: Int!
|
|
139
155
|
totalWeight: Weight!
|
|
140
156
|
taxAmount: Price!
|
|
157
|
+
taxAmountBeforeDiscount: Price!
|
|
158
|
+
totalTaxAmount: Price!
|
|
141
159
|
grandTotal: Price!
|
|
142
160
|
shippingMethod: String
|
|
143
161
|
shippingMethodName: String
|
|
@@ -149,6 +167,7 @@ type Cart implements ShoppingCart {
|
|
|
149
167
|
addShippingMethodApi: String!
|
|
150
168
|
addContactInfoApi: String!
|
|
151
169
|
addAddressApi: String!
|
|
170
|
+
addNoteApi: String!
|
|
152
171
|
}
|
|
153
172
|
|
|
154
173
|
extend type Query {
|
|
@@ -19,7 +19,14 @@ module.exports = {
|
|
|
19
19
|
const items = cart.items || [];
|
|
20
20
|
return items.map((item) => ({
|
|
21
21
|
...camelCase(item),
|
|
22
|
-
removeApi: buildUrl('
|
|
22
|
+
removeApi: buildUrl('removeCartItem', {
|
|
23
|
+
item_id: item.uuid,
|
|
24
|
+
cart_id: cart.uuid
|
|
25
|
+
}),
|
|
26
|
+
updateQtyApi: buildUrl('updateCartItemQty', {
|
|
27
|
+
cart_id: cart.uuid,
|
|
28
|
+
item_id: item.uuid
|
|
29
|
+
})
|
|
23
30
|
}));
|
|
24
31
|
},
|
|
25
32
|
shippingAddress: async ({ shippingAddressId }, _, { pool }) => {
|
|
@@ -43,6 +50,15 @@ module.exports = {
|
|
|
43
50
|
buildUrl('addCartShippingMethod', { cart_id: cart.uuid }),
|
|
44
51
|
addContactInfoApi: (cart) =>
|
|
45
52
|
buildUrl('addCartContactInfo', { cart_id: cart.uuid }),
|
|
46
|
-
addAddressApi: (cart) => buildUrl('addCartAddress', { cart_id: cart.uuid })
|
|
53
|
+
addAddressApi: (cart) => buildUrl('addCartAddress', { cart_id: cart.uuid }),
|
|
54
|
+
addNoteApi: (cart) => buildUrl('addShippingNote', { cart_id: cart.uuid })
|
|
55
|
+
},
|
|
56
|
+
CartItem: {
|
|
57
|
+
total: ({ lineTotalInclTax }) =>
|
|
58
|
+
// This field is deprecated, use lineTotalInclTax instead
|
|
59
|
+
lineTotalInclTax,
|
|
60
|
+
subTotal: ({ lineTotal }) =>
|
|
61
|
+
// This field is deprecated, use lineTotal instead
|
|
62
|
+
lineTotal
|
|
47
63
|
}
|
|
48
64
|
};
|