@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.
Files changed (391) hide show
  1. package/bin/build/index.js +24 -0
  2. package/bin/extension/index.js +2 -2
  3. package/bin/lib/addDefaultMiddlewareFuncs.js +7 -2
  4. package/bin/lib/buildEntry.js +20 -2
  5. package/bin/lib/onListening.js +7 -4
  6. package/bin/lib/startUp.js +6 -0
  7. package/package.json +9 -1
  8. package/src/components/admin/catalog/productEdit/category/CategoryItem.jsx +2 -7
  9. package/src/components/admin/catalog/productEdit/category/CategoryTree.jsx +14 -7
  10. package/src/components/admin/catalog/productEdit/category/CategoryTree.scss +10 -0
  11. package/src/components/admin/catalog/productEdit/variants/CreateVariant.jsx +2 -2
  12. package/src/components/admin/catalog/productEdit/variants/CreateVariantGroup.jsx +1 -1
  13. package/src/components/admin/catalog/productEdit/variants/EditVariant.jsx +1 -1
  14. package/src/components/admin/catalog/productEdit/variants/New.jsx +2 -2
  15. package/src/components/admin/catalog/productEdit/variants/Search.jsx +1 -1
  16. package/src/components/admin/catalog/productEdit/variants/SearchModal.jsx +1 -1
  17. package/src/components/admin/catalog/productEdit/variants/VariantModal.jsx +6 -6
  18. package/src/components/admin/catalog/productGrid/rows/ThumbnailRow.jsx +1 -1
  19. package/src/components/admin/checkout/shippingSetting/Method.jsx +6 -6
  20. package/src/components/admin/checkout/shippingSetting/MethodForm.jsx +4 -4
  21. package/src/components/admin/checkout/shippingSetting/Methods.jsx +3 -3
  22. package/src/components/admin/checkout/shippingSetting/PriceBasedPrice.jsx +2 -2
  23. package/src/components/admin/checkout/shippingSetting/WeightBasedPrice.jsx +2 -2
  24. package/src/components/admin/checkout/shippingSetting/Zone.jsx +7 -7
  25. package/src/components/admin/checkout/shippingSetting/ZoneForm.jsx +1 -1
  26. package/src/components/admin/cms/Card.jsx +3 -3
  27. package/src/components/admin/cms/PageHeading.jsx +3 -3
  28. package/src/components/admin/cms/widget/WidgetTypes.jsx +28 -0
  29. package/src/components/admin/cms/widget/grid/WidgetTypeRow.jsx +29 -0
  30. package/src/components/admin/oms/orderEdit/items/ItemVariantOptions.jsx +1 -1
  31. package/src/components/admin/oms/orderEdit/items/Name.jsx +1 -1
  32. package/src/components/admin/oms/orderGrid/headers/OrderDateColumnHeader.jsx +1 -1
  33. package/src/components/admin/promotion/couponEdit/AttributeGroupSelector.jsx +3 -3
  34. package/src/components/admin/promotion/couponEdit/BuyXGetY.jsx +2 -2
  35. package/src/components/admin/promotion/couponEdit/CategorySelector.jsx +6 -6
  36. package/src/components/admin/promotion/couponEdit/CollectionSelector.jsx +3 -3
  37. package/src/components/admin/promotion/couponEdit/ProductSkuSelector.jsx +4 -4
  38. package/src/components/admin/promotion/couponEdit/RequireProducts.jsx +2 -2
  39. package/src/components/admin/promotion/couponEdit/Setting.jsx +1 -1
  40. package/src/components/admin/promotion/couponEdit/TargetProducts.jsx +4 -4
  41. package/src/components/admin/tax/taxSetting/Rate.jsx +6 -6
  42. package/src/components/admin/tax/taxSetting/RateForm.jsx +5 -5
  43. package/src/components/admin/tax/taxSetting/Rates.jsx +6 -6
  44. package/src/components/admin/tax/taxSetting/TaxClass.jsx +3 -3
  45. package/src/components/admin/tax/taxSetting/TaxClassForm.jsx +1 -1
  46. package/src/components/admin/widgets/BasicMenuSetting.jsx +614 -0
  47. package/src/components/admin/widgets/BasicMenuSetting.scss +19 -0
  48. package/src/components/admin/widgets/CollectionProductsSetting.jsx +203 -0
  49. package/src/components/admin/widgets/TextBlockSetting.jsx +70 -0
  50. package/src/components/common/Area.jsx +31 -8
  51. package/src/components/common/Badge.jsx +1 -1
  52. package/src/components/common/Editor.jsx +193 -0
  53. package/src/components/common/Notification.scss +1 -0
  54. package/src/components/common/SimplePagination.jsx +2 -2
  55. package/src/components/common/form/Form.jsx +1 -1
  56. package/src/components/common/form/fields/Checkbox.jsx +1 -1
  57. package/src/components/common/form/fields/Ckeditor.jsx +11 -11
  58. package/src/components/common/form/fields/Editor.jsx +326 -0
  59. package/src/components/common/form/fields/Editor.scss +33 -0
  60. package/src/components/common/form/fields/Radio.jsx +1 -1
  61. package/src/components/common/form/fields/editor/FileBrowser.jsx +419 -0
  62. package/src/components/common/form/fields/editor/FileBrowser.scss +37 -0
  63. package/src/components/common/form/fields/editor/GetColumnClasses.jsx +14 -0
  64. package/src/components/common/form/fields/editor/GetRowClasses.jsx +18 -0
  65. package/src/components/common/form/fields/editor/RowTemplates.jsx +154 -0
  66. package/src/components/common/grid/Pagination.jsx +4 -4
  67. package/src/components/common/grid/headers/FromTo.jsx +1 -1
  68. package/src/components/common/grid/headers/Sortable.jsx +1 -1
  69. package/src/components/common/grid/rows/ThumbnailRow.jsx +1 -1
  70. package/src/components/common/list/Filter.jsx +1 -1
  71. package/src/components/common/modal/Alert.jsx +1 -1
  72. package/src/components/common/modal/Modal.jsx +1 -1
  73. package/src/components/frontStore/catalog/categoryView/filter/AttributeFilter.jsx +2 -2
  74. package/src/components/frontStore/catalog/categoryView/filter/CategoryFilter.jsx +3 -2
  75. package/src/components/frontStore/catalog/categoryView/filter/CategoryFilter.scss +5 -0
  76. package/src/components/frontStore/catalog/product/list/List.jsx +4 -4
  77. package/src/components/frontStore/catalog/product/list/Pagination.jsx +1 -1
  78. package/src/components/frontStore/catalog/product/list/Sorting.jsx +2 -2
  79. package/src/components/frontStore/catalog/product/list/item/Name.jsx +1 -1
  80. package/src/components/frontStore/checkout/cart/Empty.jsx +3 -3
  81. package/src/components/frontStore/checkout/cart/items/ItemOptions.jsx +1 -1
  82. package/src/components/frontStore/checkout/cart/items/ItemVariantOptions.jsx +1 -1
  83. package/src/components/frontStore/checkout/cart/items/Items.jsx +20 -21
  84. package/src/components/frontStore/checkout/cart/items/Items.scss +47 -0
  85. package/src/components/frontStore/checkout/cart/items/Quantity.jsx +154 -0
  86. package/src/components/frontStore/checkout/checkout/StepTitle.jsx +1 -1
  87. package/src/components/frontStore/checkout/checkout/payment/paymentStep/StepContent.jsx +5 -5
  88. package/src/components/frontStore/checkout/checkout/shipment/StepContent.jsx +1 -1
  89. package/src/components/frontStore/checkout/checkout/summary/Cart.jsx +10 -12
  90. package/src/components/frontStore/checkout/checkout/summary/Items.jsx +9 -9
  91. package/src/components/frontStore/checkout/checkout/summary/cart/Total.jsx +6 -6
  92. package/src/components/frontStore/checkout/success/summary/items/ItemOptions.jsx +1 -1
  93. package/src/components/frontStore/checkout/success/summary/items/Items.jsx +9 -6
  94. package/src/components/frontStore/checkout/success/summary/order/OrderSummary.jsx +9 -13
  95. package/src/components/frontStore/checkout/success/summary/order/Total.jsx +5 -5
  96. package/src/components/frontStore/customer/address/addressForm/AddressFormLoadingSkeleton.jsx +2 -2
  97. package/src/components/frontStore/customer/address/addressForm/NameAndTelephone.jsx +1 -1
  98. package/src/components/frontStore/customer/address/addressForm/ProvinceAndPostcode.jsx +1 -1
  99. package/src/components/frontStore/customer/checkout/Edit.jsx +2 -2
  100. package/src/components/frontStore/customer/detail/Order.jsx +4 -4
  101. package/src/components/frontStore/stripe/checkout/CheckoutForm.jsx +2 -2
  102. package/src/components/frontStore/stripe/checkout/TestCards.jsx +1 -1
  103. package/src/components/frontStore/widgets/BasicMenu.jsx +129 -0
  104. package/src/{modules/catalog/pages/frontStore/homepage/FeaturedProducts.jsx → components/frontStore/widgets/CollectionProducts.jsx} +40 -32
  105. package/src/components/frontStore/widgets/TextBlock.jsx +46 -0
  106. package/src/lib/componee/getComponentsByRoute.js +15 -2
  107. package/src/lib/event/event-manager.js +1 -1
  108. package/src/lib/middleware/tests/app/modules/404page/pages/frontStore/product/route.json +2 -1
  109. package/src/lib/middlewares/static.js +3 -1
  110. package/src/lib/response/render.js +5 -6
  111. package/src/lib/router/Router.js +1 -1
  112. package/src/lib/router/loadModuleRoutes.js +3 -0
  113. package/src/lib/router/registerAdminRoute.js +9 -1
  114. package/src/lib/router/registerFrontStoreRoute.js +2 -0
  115. package/src/lib/router/scanForRoutes.js +1 -0
  116. package/src/lib/router/tests/unit/unit.validateRoute.test.js +7 -1
  117. package/src/lib/util/defaultPaginationFilters.js +19 -17
  118. package/src/lib/util/getEnabledWidgets.js +34 -0
  119. package/src/lib/util/merge.js +67 -14
  120. package/src/lib/util/tests/unit/util.merge.test.js +21 -4
  121. package/src/lib/util/validateConfiguration.js +83 -0
  122. package/src/lib/webpack/createBaseConfig.js +4 -1
  123. package/src/lib/webpack/dev/createConfigClient.js +10 -2
  124. package/src/lib/webpack/loaders/AreaLoader.js +16 -6
  125. package/src/lib/webpack/util/keyGenerator.js +9 -0
  126. package/src/lib/webpack/util/parseGraphql.js +30 -16
  127. package/src/lib/webpack/util/parseGraphqlByFile.js +16 -2
  128. package/src/modules/auth/pages/admin/adminLogin/LoginForm.jsx +54 -21
  129. package/src/modules/auth/pages/admin/all/AdminUser.jsx +3 -3
  130. package/src/modules/base/bootstrap.js +79 -0
  131. package/src/modules/base/graphql/types/Route/Route.admin.graphql +15 -0
  132. package/src/modules/base/graphql/types/Route/Route.admin.resolvers.js +10 -0
  133. package/src/modules/base/pages/global/response[errorHandler].js +25 -1
  134. package/src/modules/catalog/bootstrap.js +125 -5
  135. package/src/modules/catalog/graphql/types/Category/Category.graphql +4 -3
  136. package/src/modules/catalog/graphql/types/Category/Category.resolvers.js +34 -0
  137. package/src/modules/catalog/graphql/types/Collection/Collection.graphql +2 -2
  138. package/src/modules/catalog/graphql/types/Collection/Collection.resolvers.js +34 -0
  139. package/src/modules/catalog/graphql/types/Product/Attribute/ProductAttribute.resolvers.js +1 -0
  140. package/src/modules/catalog/graphql/types/Product/Product.graphql +1 -1
  141. package/src/modules/catalog/graphql/types/Product/Product.resolvers.js +34 -0
  142. package/src/modules/catalog/graphql/types/Widget/CollectionProductsWidget/CollectionProductsWidget.graphql +11 -0
  143. package/src/modules/catalog/graphql/types/Widget/CollectionProductsWidget/CollectionProductsWidget.resolvers.js +8 -0
  144. package/src/modules/catalog/migration/Version-1.0.0.js +1 -0
  145. package/src/modules/catalog/migration/Version-1.0.7.js +10 -0
  146. package/src/modules/catalog/pages/admin/attributeEdit+attributeNew/FormContent.jsx +4 -4
  147. package/src/modules/catalog/pages/admin/attributeEdit+attributeNew/General.jsx +5 -5
  148. package/src/modules/catalog/pages/admin/attributeGrid/Grid.jsx +2 -2
  149. package/src/modules/catalog/pages/admin/categoryEdit/Products.jsx +4 -4
  150. package/src/modules/catalog/pages/admin/categoryEdit+categoryNew/FormContent.jsx +4 -4
  151. package/src/modules/catalog/pages/admin/categoryEdit+categoryNew/General.jsx +16 -18
  152. package/src/modules/catalog/pages/admin/categoryEdit+categoryNew/Image.jsx +1 -2
  153. package/src/modules/catalog/pages/admin/categoryEdit+categoryNew/Status.jsx +16 -1
  154. package/src/modules/catalog/pages/admin/categoryGrid/Grid.jsx +3 -3
  155. package/src/modules/catalog/pages/admin/collectionEdit/Products.jsx +4 -4
  156. package/src/modules/catalog/pages/admin/collectionEdit+collectionNew/FormContent.jsx +2 -2
  157. package/src/modules/catalog/pages/admin/collectionEdit+collectionNew/General.jsx +2 -2
  158. package/src/modules/catalog/pages/admin/collectionGrid/Grid.jsx +3 -3
  159. package/src/modules/catalog/pages/admin/productEdit/Collection.jsx +7 -7
  160. package/src/modules/catalog/pages/admin/productEdit+productNew/Attributes.jsx +8 -3
  161. package/src/modules/catalog/pages/admin/productEdit+productNew/CustomOptions.jsss +4 -4
  162. package/src/modules/catalog/pages/admin/productEdit+productNew/FormContent.jsx +4 -4
  163. package/src/modules/catalog/pages/admin/productEdit+productNew/General.jsx +15 -17
  164. package/src/modules/catalog/pages/admin/productGrid/Grid.jsx +3 -3
  165. package/src/modules/catalog/pages/frontStore/catalogSearch/General.jsx +2 -2
  166. package/src/modules/catalog/pages/frontStore/catalogSearch/Products.jsx +1 -1
  167. package/src/modules/catalog/pages/frontStore/catalogSearch/route.json +2 -1
  168. package/src/modules/catalog/pages/frontStore/categoryView/CategoryView.jsx +19 -2
  169. package/src/modules/catalog/pages/frontStore/categoryView/Filter.scss +1 -0
  170. package/src/modules/catalog/pages/frontStore/categoryView/General.jsx +6 -8
  171. package/src/modules/catalog/pages/frontStore/categoryView/General.scss +0 -2
  172. package/src/modules/catalog/pages/frontStore/categoryView/Pagination.jsx +6 -0
  173. package/src/modules/catalog/pages/frontStore/categoryView/Products.jsx +8 -1
  174. package/src/modules/catalog/pages/frontStore/categoryView/route.json +2 -1
  175. package/src/modules/catalog/pages/frontStore/productView/Description.jsx +15 -4
  176. package/src/modules/catalog/pages/frontStore/productView/Form.jsx +4 -4
  177. package/src/modules/catalog/pages/frontStore/productView/Form.scss +1 -0
  178. package/src/modules/catalog/pages/frontStore/productView/GeneralInfo.jsx +1 -1
  179. package/src/modules/catalog/pages/frontStore/productView/Images.jsx +1 -1
  180. package/src/modules/catalog/pages/frontStore/productView/Layout.jsx +1 -1
  181. package/src/modules/catalog/pages/frontStore/productView/Options.jsx +7 -3
  182. package/src/modules/catalog/pages/frontStore/productView/Variants.jsx +6 -6
  183. package/src/modules/catalog/pages/frontStore/productView/route.json +2 -1
  184. package/src/modules/catalog/services/AttributeCollection.js +10 -10
  185. package/src/modules/catalog/services/AttributeGroupCollection.js +10 -10
  186. package/src/modules/catalog/services/CategoryCollection.js +10 -10
  187. package/src/modules/catalog/services/CollectionCollection.js +10 -10
  188. package/src/modules/catalog/services/registerCartItemProductUrlField.js +35 -0
  189. package/src/modules/catalog/services/registerCartItemVariantOptionsField.js +51 -0
  190. package/src/modules/catalog/services/registerDefaultCategoryCollectionFilters.js +16 -0
  191. package/src/modules/checkout/api/addShippingNote/[context]bodyParser[auth].js +5 -0
  192. package/src/modules/checkout/api/addShippingNote/payloadSchema.json +15 -0
  193. package/src/modules/checkout/api/addShippingNote/route.json +5 -0
  194. package/src/modules/checkout/api/addShippingNote/saveShippingNote.js +50 -0
  195. package/src/modules/checkout/api/createCart/createNewCart.js +28 -3
  196. package/src/modules/checkout/api/updateCartItemQty/[bodyParser]updateQty.js +49 -0
  197. package/src/modules/checkout/api/updateCartItemQty/[context]bodyParser[auth].js +5 -0
  198. package/src/modules/checkout/api/updateCartItemQty/payloadSchema.json +21 -0
  199. package/src/modules/checkout/api/updateCartItemQty/route.json +5 -0
  200. package/src/modules/checkout/api/updateMineCartItemQty/[context]bodyParser[auth].js +5 -0
  201. package/src/modules/checkout/api/updateMineCartItemQty/[detectCurrentCart]updateQty.js +51 -0
  202. package/src/modules/checkout/api/updateMineCartItemQty/[getCurrentCustomer]detectCurrentCart.js +32 -0
  203. package/src/modules/checkout/api/updateMineCartItemQty/payloadSchema.json +21 -0
  204. package/src/modules/checkout/api/updateMineCartItemQty/route.json +5 -0
  205. package/src/modules/checkout/bootstrap.js +27 -0
  206. package/src/modules/checkout/graphql/types/Cart/Cart.graphql +22 -3
  207. package/src/modules/checkout/graphql/types/Cart/Cart.resolvers.js +18 -2
  208. package/src/modules/checkout/graphql/types/CheckoutSetting/CheckoutSetting.graphql +3 -0
  209. package/src/modules/checkout/graphql/types/CheckoutSetting/CheckoutSetting.resolvers.js +7 -0
  210. package/src/modules/checkout/migration/Version-1.0.0.js +14 -0
  211. package/src/modules/checkout/migration/Version-1.0.6.js +201 -0
  212. package/src/modules/checkout/pages/admin/shippingSetting/ShippingSetting.jsx +2 -2
  213. package/src/modules/checkout/pages/frontStore/all/[context]detectCurrentCart[auth].js +5 -0
  214. package/src/modules/checkout/pages/frontStore/cart/ShoppingCart.jsx +20 -12
  215. package/src/modules/checkout/pages/frontStore/cart/Summary.jsx +34 -23
  216. package/src/modules/checkout/pages/frontStore/cart/route.json +2 -1
  217. package/src/modules/checkout/pages/frontStore/checkout/Checkout.jsx +5 -5
  218. package/src/modules/checkout/pages/frontStore/checkout/Checkout.scss +4 -0
  219. package/src/modules/checkout/pages/frontStore/checkout/ShippingMethods.jsx +2 -2
  220. package/src/modules/checkout/pages/frontStore/checkout/ShippingNote.jsx +105 -0
  221. package/src/modules/checkout/pages/frontStore/checkout/Summary.jsx +14 -14
  222. package/src/modules/checkout/pages/frontStore/checkout/SummaryMobile.jsx +12 -15
  223. package/src/modules/checkout/pages/frontStore/checkout/route.json +2 -1
  224. package/src/modules/checkout/pages/frontStore/checkoutSuccess/CheckoutSuccess.jsx +1 -1
  225. package/src/modules/checkout/pages/frontStore/checkoutSuccess/CheckoutSuccess.scss +4 -0
  226. package/src/modules/checkout/pages/frontStore/checkoutSuccess/CustomerInfo.jsx +30 -32
  227. package/src/modules/checkout/pages/frontStore/checkoutSuccess/ShippingNote.jsx +47 -0
  228. package/src/modules/checkout/pages/frontStore/checkoutSuccess/Summary.jsx +12 -15
  229. package/src/modules/checkout/pages/frontStore/checkoutSuccess/route.json +2 -1
  230. package/src/modules/checkout/services/cart/Cart.js +31 -27
  231. package/src/modules/checkout/services/cart/registerCartBaseFields.js +133 -41
  232. package/src/modules/checkout/services/cart/registerCartItemBaseFields.js +300 -374
  233. package/src/modules/checkout/services/toPrice.js +1 -1
  234. package/src/modules/checkout/tests/basicSetup.js +85 -0
  235. package/src/modules/checkout/tests/coupons.js +82 -0
  236. package/src/modules/checkout/tests/products.js +67 -0
  237. package/src/modules/checkout/tests/taxRates.js +3 -0
  238. package/src/modules/checkout/tests/unit/discountAmount.test.js +60 -0
  239. package/src/modules/checkout/tests/unit/grandTotal.test.js +83 -0
  240. package/src/modules/checkout/tests/unit/lineTotal.test.js +92 -0
  241. package/src/modules/checkout/tests/unit/lineTotalWithDiscount.test.js +103 -0
  242. package/src/modules/checkout/tests/unit/productPrice.test.js +69 -0
  243. package/src/modules/checkout/tests/unit/subTotal.test.js +85 -0
  244. package/src/modules/checkout/tests/unit/subTotalWithDiscount.test.js +117 -0
  245. package/src/modules/checkout/tests/unit/taxAmount.test.js +68 -0
  246. package/src/modules/checkout/tests/unit/taxAmountRounding.test.js +277 -0
  247. package/src/modules/cms/api/createWidget/[context]bodyParser[auth].js +5 -0
  248. package/src/modules/cms/api/createWidget/createWidget[finish].js +17 -0
  249. package/src/modules/cms/api/createWidget/finish[apiResponse].js +27 -0
  250. package/src/modules/cms/api/createWidget/payloadSchema.json +18 -0
  251. package/src/modules/cms/api/createWidget/route.json +5 -0
  252. package/src/modules/cms/api/deleteWidget/deleteWidget.js +27 -0
  253. package/src/modules/cms/api/deleteWidget/route.json +5 -0
  254. package/src/modules/cms/api/updateWidget/[context]bodyParser[auth].js +5 -0
  255. package/src/modules/cms/api/updateWidget/finish[apiResponse].js +27 -0
  256. package/src/modules/cms/api/updateWidget/payloadSchema.json +18 -0
  257. package/src/modules/cms/api/updateWidget/route.json +5 -0
  258. package/src/modules/cms/api/updateWidget/updateWidget[finish].js +17 -0
  259. package/src/modules/cms/bootstrap.js +223 -3
  260. package/src/modules/cms/graphql/types/CmsPage/CmsPage.graphql +1 -2
  261. package/src/modules/cms/graphql/types/CmsPage/CmsPage.resolvers.js +35 -1
  262. package/src/modules/cms/graphql/types/Widget/Widget.graphql +91 -0
  263. package/src/modules/cms/graphql/types/Widget/Widget.resolvers.js +142 -0
  264. package/src/modules/cms/migration/Version-1.1.0.js +22 -0
  265. package/src/modules/cms/migration/Version-1.1.1.js +103 -0
  266. package/src/modules/cms/pages/admin/adminNotFound/NotFound.jsx +4 -4
  267. package/src/modules/cms/pages/admin/all/CmsMenuGroup.jsx +12 -4
  268. package/src/modules/cms/pages/admin/all/Notification.scss +1 -1
  269. package/src/modules/cms/pages/admin/all/search/NoResult.jsx +2 -2
  270. package/src/modules/cms/pages/admin/all/search/Results.jsx +3 -3
  271. package/src/modules/cms/pages/admin/cmsPageEdit+cmsPageNew/FormContent.jsx +7 -9
  272. package/src/modules/cms/pages/admin/cmsPageEdit+cmsPageNew/General.jsx +3 -3
  273. package/src/modules/cms/pages/admin/cmsPageEdit+cmsPageNew/Seo.jsx +1 -1
  274. package/src/modules/cms/pages/admin/cmsPageEdit+cmsPageNew/Status.jsx +40 -0
  275. package/src/modules/cms/pages/admin/cmsPageGrid/Grid.jsx +3 -4
  276. package/src/modules/cms/pages/admin/dashboard/Layout.jsx +3 -3
  277. package/src/modules/cms/pages/admin/widgetEdit/WidgetForm.jsx +52 -0
  278. package/src/modules/cms/pages/admin/widgetEdit/index.js +36 -0
  279. package/src/modules/cms/pages/admin/widgetEdit/route.json +4 -0
  280. package/src/modules/cms/pages/admin/widgetEdit+widgetNew/FormContent.jsx +69 -0
  281. package/src/modules/cms/pages/admin/widgetEdit+widgetNew/FormContent.scss +7 -0
  282. package/src/modules/cms/pages/admin/widgetEdit+widgetNew/General.jsx +185 -0
  283. package/src/modules/cms/pages/admin/widgetEdit+widgetNew/PageHeading.jsx +37 -0
  284. package/src/modules/cms/pages/admin/widgetEdit+widgetNew/Setting.jsx +55 -0
  285. package/src/modules/cms/pages/admin/widgetGrid/Grid.jsx +415 -0
  286. package/src/modules/cms/pages/admin/widgetGrid/Heading.jsx +11 -0
  287. package/src/modules/cms/pages/admin/widgetGrid/NewWidgetButton.jsx +52 -0
  288. package/src/modules/cms/pages/admin/widgetGrid/index.js +15 -0
  289. package/src/modules/cms/pages/admin/widgetGrid/route.json +4 -0
  290. package/src/modules/cms/pages/admin/widgetNew/WidgetNewForm.jsx +60 -0
  291. package/src/modules/cms/pages/admin/widgetNew/index.js +11 -0
  292. package/src/modules/cms/pages/admin/widgetNew/route.json +4 -0
  293. package/src/modules/cms/pages/admin/widgetNew/typeValidate.js +21 -0
  294. package/src/modules/cms/pages/frontStore/all/Breadcrumb.jsx +1 -1
  295. package/src/modules/cms/pages/frontStore/all/Footer.jsx +2 -2
  296. package/src/modules/cms/pages/frontStore/all/Layout.jsx +3 -3
  297. package/src/modules/cms/pages/frontStore/all/Layout.scss +13 -0
  298. package/src/modules/cms/pages/frontStore/all/Logo.jsx +2 -2
  299. package/src/modules/cms/pages/frontStore/all/Logo.scss +2 -4
  300. package/src/modules/cms/pages/frontStore/all/Notification.scss +1 -1
  301. package/src/modules/cms/pages/frontStore/cmsPageView/Layout.jsx +2 -2
  302. package/src/modules/cms/pages/frontStore/cmsPageView/View.jsx +5 -3
  303. package/src/modules/cms/pages/frontStore/cmsPageView/index.js +6 -12
  304. package/src/modules/cms/pages/frontStore/cmsPageView/route.json +2 -1
  305. package/src/modules/cms/pages/frontStore/homepage/route.json +2 -1
  306. package/src/modules/cms/pages/frontStore/notFound/NotFound.jsx +4 -4
  307. package/src/modules/cms/pages/frontStore/notFound/route.json +2 -1
  308. package/src/modules/cms/pages/frontStore/staticAsset/[context]staticAssets[auth].js +1 -1
  309. package/src/modules/cms/services/CMSPageCollection.js +10 -10
  310. package/src/modules/cms/services/WidgetCollection.js +62 -0
  311. package/src/modules/cms/services/getWidgetsBaseQuery.js +7 -0
  312. package/src/modules/cms/services/page/createPage.js +1 -2
  313. package/src/modules/cms/services/page/pageDataSchema.json +0 -4
  314. package/src/modules/cms/services/registerDefaultWidgetCollectionFilters.js +62 -0
  315. package/src/modules/cms/services/tailwind.admin.config.js +22 -107
  316. package/src/modules/cms/services/tailwind.frontStore.config.js +23 -108
  317. package/src/modules/cms/services/widget/createWidget.js +73 -0
  318. package/src/modules/cms/services/widget/deleteWidget.js +49 -0
  319. package/src/modules/cms/services/widget/loadWidgetInstances.js +54 -0
  320. package/src/modules/cms/services/widget/updateWidget.js +86 -0
  321. package/src/modules/cms/services/widget/widgetDataSchema.json +29 -0
  322. package/src/modules/cod/pages/admin/paymentSetting/CODSetting.jsx +2 -2
  323. package/src/modules/cod/pages/frontStore/checkout/CashOnDelivery.jsx +1 -1
  324. package/src/modules/customer/bootstrap.js +21 -4
  325. package/src/modules/customer/pages/admin/customerEdit/CustomerEditForm.jsx +3 -3
  326. package/src/modules/customer/pages/admin/customerEdit+customerNew/OrderHistory.jsx +1 -1
  327. package/src/modules/customer/pages/admin/customerGrid/Grid.jsx +3 -3
  328. package/src/modules/customer/pages/frontStore/account/AccountDetails.jsx +3 -3
  329. package/src/modules/customer/pages/frontStore/account/Layout.jsx +3 -3
  330. package/src/modules/customer/pages/frontStore/account/OrderHistory.jsx +1 -1
  331. package/src/modules/customer/pages/frontStore/account/route.json +2 -1
  332. package/src/modules/customer/pages/frontStore/login/LoginForm.jsx +2 -2
  333. package/src/modules/customer/pages/frontStore/login/route.json +2 -1
  334. package/src/modules/customer/pages/frontStore/register/RegisterForm.jsx +2 -2
  335. package/src/modules/customer/pages/frontStore/register/route.json +2 -1
  336. package/src/modules/customer/pages/frontStore/resetPasswordPage/ResetPasswordForm.jsx +2 -2
  337. package/src/modules/customer/pages/frontStore/resetPasswordPage/route.json +2 -1
  338. package/src/modules/customer/pages/frontStore/updatePasswordPage/UpdatePasswordForm.jsx +3 -3
  339. package/src/modules/customer/pages/frontStore/updatePasswordPage/route.json +2 -1
  340. package/src/modules/customer/services/CustomerCollection.js +10 -10
  341. package/src/modules/customer/services/CustomerGroupCollection.js +10 -10
  342. package/src/modules/graphql/pages/global/[bodyParser]buildQuery[graphql].js +241 -6
  343. package/src/modules/graphql/pages/global/[buildQuery]graphql[notification].js +12 -8
  344. package/src/modules/oms/bootstrap.js +87 -3
  345. package/src/modules/oms/graphql/types/Order/Order.graphql +11 -2
  346. package/src/modules/oms/graphql/types/Order/Order.resolvers.js +7 -1
  347. package/src/modules/oms/pages/admin/dashboard/Bestsellers.jsx +2 -2
  348. package/src/modules/oms/pages/admin/dashboard/Lifetimesales.jsx +5 -5
  349. package/src/modules/oms/pages/admin/orderEdit/AddTrackingButton.jsx +1 -1
  350. package/src/modules/oms/pages/admin/orderEdit/Items.jsx +7 -7
  351. package/src/modules/oms/pages/admin/orderEdit/Layout.jsx +3 -3
  352. package/src/modules/oms/pages/admin/orderEdit/Payment.jsx +6 -6
  353. package/src/modules/oms/pages/admin/orderEdit/ShipButton.jsx +1 -1
  354. package/src/modules/oms/pages/admin/orderGrid/Grid.jsx +3 -3
  355. package/src/modules/oms/services/OrderCollection.js +10 -10
  356. package/src/modules/paypal/api/paypalCreateOrder/[bodyParser]createOrder.js +55 -24
  357. package/src/modules/paypal/pages/admin/paymentSetting/PaypalSetting.jsx +6 -6
  358. package/src/modules/paypal/pages/frontStore/checkout/Paypal.jsx +3 -4
  359. package/src/modules/promotion/bootstrap.js +19 -101
  360. package/src/modules/promotion/pages/admin/couponEdit+couponNew/DiscountType.jsx +1 -1
  361. package/src/modules/promotion/pages/admin/couponEdit+couponNew/FormContent.jsx +5 -5
  362. package/src/modules/promotion/pages/admin/couponGrid/Grid.jsx +3 -3
  363. package/src/modules/promotion/pages/frontStore/cart/Coupon.jsx +2 -2
  364. package/src/modules/promotion/services/CouponCollection.js +10 -10
  365. package/src/modules/promotion/services/couponValidator.js +4 -7
  366. package/src/modules/promotion/services/discountCalculator.js +2 -7
  367. package/src/modules/promotion/services/registerCartItemPromotionFields.js +80 -0
  368. package/src/modules/promotion/services/registerCartPromotionFields.js +128 -0
  369. package/src/modules/promotion/services/registerDefaultCalculators.js +48 -20
  370. package/src/modules/promotion/services/registerDefaultValidators.js +16 -4
  371. package/src/modules/setting/pages/admin/paymentSetting/PaymentSetting.jsx +2 -2
  372. package/src/modules/setting/pages/admin/storeSetting/StoreSetting.jsx +98 -35
  373. package/src/modules/stripe/pages/admin/paymentSetting/StripePayment.jsx +5 -5
  374. package/src/modules/stripe/pages/frontStore/checkout/Stripe.jsx +1 -1
  375. package/src/modules/tax/bootstrap.js +40 -5
  376. package/src/modules/tax/graphql/types/Product/Price/ProductPrice.resolvers.js +6 -39
  377. package/src/modules/tax/graphql/types/TaxSetting/TaxSetting.graphql +1 -2
  378. package/src/modules/tax/graphql/types/TaxSetting/TaxSetting.resolvers.js +1 -8
  379. package/src/modules/tax/pages/admin/taxSetting/TaxSetting.jsx +4 -4
  380. package/src/modules/tax/services/TaxClassCollection.js +10 -10
  381. package/src/modules/tax/services/calculateTaxAmount.js +12 -9
  382. package/src/modules/tax/services/registerCartItemTaxPercentField.js +76 -0
  383. package/src/modules/auth/services/adminSessionMiddleware.js +0 -0
  384. package/src/modules/catalog/pages/frontStore/homepage/FeaturedCategories.jsx +0 -58
  385. package/src/modules/cms/pages/admin/cmsPageEdit+cmsPageNew/StatusAndLayout.jsx +0 -61
  386. package/src/modules/cms/pages/frontStore/all/Menu.jsx +0 -46
  387. package/src/modules/cms/pages/frontStore/all/Menu.scss +0 -7
  388. package/src/modules/cms/pages/frontStore/all/MobileMenu.jsx +0 -73
  389. package/src/modules/cms/pages/frontStore/all/MobileMenu.scss +0 -35
  390. package/src/modules/cms/pages/frontStore/homepage/MainBanner.jsx +0 -31
  391. 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((f) => f.key === filter.key);
28
- if (check) {
29
- if (filter.operation.includes(check.operation)) {
30
- filter.callback(
31
- this.baseQuery,
32
- check.operation,
33
- check.value,
34
- currentFilters
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((f) => f.key === filter.key);
22
- if (check) {
23
- if (filter.operation.includes(check.operation)) {
24
- filter.callback(
25
- this.baseQuery,
26
- check.operation,
27
- check.value,
28
- currentFilters
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,5 @@
1
+ const bodyParser = require('body-parser');
2
+
3
+ module.exports = (request, response, delegate, next) => {
4
+ bodyParser.json({ inflate: false })(request, response, next);
5
+ };
@@ -0,0 +1,15 @@
1
+ {
2
+ "type": "object",
3
+ "properties": {
4
+ "note": {
5
+ "type": "string"
6
+ }
7
+ },
8
+ "required": ["note"],
9
+ "additionalProperties": false,
10
+ "errorMessage": {
11
+ "properties": {
12
+ "note": "Note is required"
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "methods": ["POST"],
3
+ "path": "/carts/:cart_id/shippingNotes",
4
+ "access": "public"
5
+ }
@@ -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.sku, item.qty);
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,5 @@
1
+ const bodyParser = require('body-parser');
2
+
3
+ module.exports = (request, response, delegate, next) => {
4
+ bodyParser.json({ inflate: false })(request, response, next);
5
+ };
@@ -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,5 @@
1
+ {
2
+ "methods": ["PATCH"],
3
+ "path": "/cart/:cart_id/items/:item_id",
4
+ "access": "public"
5
+ }
@@ -0,0 +1,5 @@
1
+ const bodyParser = require('body-parser');
2
+
3
+ module.exports = (request, response, delegate, next) => {
4
+ bodyParser.json({ inflate: false })(request, response, next);
5
+ };
@@ -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
+ };
@@ -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
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "methods": ["PATCH"],
3
+ "path": "/cart/mine/items/:item_id",
4
+ "access": "public"
5
+ }
@@ -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
- total: Price!
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
- subTotal: Price!
107
- total: Price!
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('removeMineCartItem', { item_id: item.uuid })
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
  };
@@ -0,0 +1,3 @@
1
+ extend type Setting {
2
+ showShippingNote: Boolean
3
+ }
@@ -0,0 +1,7 @@
1
+ const { getConfig } = require('@evershop/evershop/src/lib/util/getConfig');
2
+
3
+ module.exports = {
4
+ Setting: {
5
+ showShippingNote: () => getConfig('checkout.showShippingNote', true)
6
+ }
7
+ };