@mframework/layer-commerce 0.0.3
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/README.md +101 -0
- package/app/cart/useCart.ts +1 -0
- package/app/components/ChevronIcon/ChevronIcon.config.ts +17 -0
- package/app/components/DateSelect/DateSelect.config.ts +15 -0
- package/app/components/Field/Field.config.ts +14 -0
- package/app/components/FieldDate/FieldDate.config.ts +16 -0
- package/app/components/Form/Form.type.ts +8 -0
- package/app/components/Product/Product.config.ts +19 -0
- package/app/components/Product/Stock.config.ts +15 -0
- package/app/components/ProductCustomizableOption/ProductCustomizableOption.config.ts +5 -0
- package/app/components/ProductGallery/ProductGallery.config.ts +15 -0
- package/app/components/ProductReviews/ProductReviews.config.ts +8 -0
- package/app/composables/_types.ts +18 -0
- package/app/composables/adapters/abstract/cartAdapter.ts +0 -0
- package/app/composables/adapters/abstract/categoryAdapter.ts +0 -0
- package/app/composables/adapters/abstract/customerAdapter.ts +0 -0
- package/app/composables/adapters/abstract/inventoryAdapter.ts +0 -0
- package/app/composables/adapters/abstract/orderAdapter.ts +0 -0
- package/app/composables/adapters/abstract/productAdapter.ts +7 -0
- package/app/composables/cart/registry.ts +20 -0
- package/app/composables/cart/types.ts +18 -0
- package/app/composables/cart/useCart.ts +15 -0
- package/app/composables/config.ts +19 -0
- package/app/composables/defs/apiDefinitions.ts +55 -0
- package/app/composables/defs/extension.feature +40 -0
- package/app/composables/defs/extension.mocks.ts +39 -0
- package/app/composables/defs/extension.test.ts +280 -0
- package/app/composables/defs/extension.ts +236 -0
- package/app/composables/defs/index.ts +3 -0
- package/app/composables/defs/typeHelpers.ts +8 -0
- package/app/composables/defs/types.ts +136 -0
- package/app/composables/domain/product.ts +12 -0
- package/app/composables/featured-products.ts +20 -0
- package/app/composables/helpers/contextualizedNormalizers.feature +14 -0
- package/app/composables/helpers/contextualizedNormalizers.test.ts +85 -0
- package/app/composables/helpers/contextualizedNormalizers.ts +20 -0
- package/app/composables/helpers/index.ts +1 -0
- package/app/composables/index.ts +9 -0
- package/app/composables/methods/auth.ts +83 -0
- package/app/composables/methods/cart.ts +119 -0
- package/app/composables/methods/category.ts +27 -0
- package/app/composables/methods/checkout.ts +54 -0
- package/app/composables/methods/customer.ts +52 -0
- package/app/composables/methods/helpers.ts +5 -0
- package/app/composables/methods/index.ts +75 -0
- package/app/composables/methods/order.ts +39 -0
- package/app/composables/methods/product.ts +95 -0
- package/app/composables/methods/settings.ts +16 -0
- package/app/composables/models/cart.ts +95 -0
- package/app/composables/models/category.ts +13 -0
- package/app/composables/models/checkout.ts +17 -0
- package/app/composables/models/customer.ts +16 -0
- package/app/composables/models/facets.ts +25 -0
- package/app/composables/models/index.ts +94 -0
- package/app/composables/models/order.ts +43 -0
- package/app/composables/models/product.ts +73 -0
- package/app/composables/models/shared.ts +75 -0
- package/app/composables/orders.ts +69 -0
- package/app/composables/products/registry.ts +86 -0
- package/app/composables/products/types.ts +8 -0
- package/app/composables/products/useEvents.ts +26 -0
- package/app/composables/products/useGiftCards.ts +29 -0
- package/app/composables/products/useProducts.ts +12 -0
- package/app/composables/products/useSubscriptions.ts +29 -0
- package/app/composables/products.ts +30 -0
- package/app/composables/registry.ts +24 -0
- package/app/composables/useAuth.ts +43 -0
- package/app/composables/useBreakpoints/index.ts +1 -0
- package/app/composables/useBreakpoints/useBreakpoints.ts +28 -0
- package/app/composables/useCache.ts +38 -0
- package/app/composables/useCart/__tests__/useCart.spec.ts +11 -0
- package/app/composables/useCart/index.ts +1 -0
- package/app/composables/useCart/types.ts +17 -0
- package/app/composables/useCart/useCart.ts +46 -0
- package/app/composables/useCartShippingMethods/__tests__/useCartShippingMethods.spec.ts +11 -0
- package/app/composables/useCartShippingMethods/index.ts +1 -0
- package/app/composables/useCartShippingMethods/types.ts +17 -0
- package/app/composables/useCartShippingMethods/useCartShippingMethods.ts +47 -0
- package/app/composables/useCatalog.ts +26 -0
- package/app/composables/useContent.ts +26 -0
- package/app/composables/useCustomer/__tests__/useCustomer.spec.ts +25 -0
- package/app/composables/useCustomer/index.ts +2 -0
- package/app/composables/useCustomer/types.ts +17 -0
- package/app/composables/useCustomer/useCustomer.ts +40 -0
- package/app/composables/useCustomerAddress/__tests__/useCustomerAddress.spec.ts +11 -0
- package/app/composables/useCustomerAddress/index.ts +2 -0
- package/app/composables/useCustomerAddress/types.ts +17 -0
- package/app/composables/useCustomerAddress/useCustomerAddress.ts +55 -0
- package/app/composables/useCustomerOrder/__tests__/useCustomerOrder.spec.ts +11 -0
- package/app/composables/useCustomerOrder/adress.ts +10 -0
- package/app/composables/useCustomerOrder/index.ts +2 -0
- package/app/composables/useCustomerOrder/product.ts +37 -0
- package/app/composables/useCustomerOrder/types.ts +40 -0
- package/app/composables/useCustomerOrder/useCustomerOrder.ts +63 -0
- package/app/composables/useCustomerOrders/__tests__/useCustomerOrders.spec.ts +11 -0
- package/app/composables/useCustomerOrders/index.ts +2 -0
- package/app/composables/useCustomerOrders/types.ts +20 -0
- package/app/composables/useCustomerOrders/useCustomerOrders.ts +56 -0
- package/app/composables/useCustomerReturns/__tests__/useCustomerReturns.spec.ts +11 -0
- package/app/composables/useCustomerReturns/index.ts +2 -0
- package/app/composables/useCustomerReturns/types.ts +17 -0
- package/app/composables/useCustomerReturns/useCustomerReturns.ts +41 -0
- package/app/composables/useHandleError/index.ts +1 -0
- package/app/composables/useHandleError/types.ts +11 -0
- package/app/composables/useHandleError/useHandleError.ts +27 -0
- package/app/composables/useInventory.ts +29 -0
- package/app/composables/useLoading.ts +21 -0
- package/app/composables/useNotification.ts +21 -0
- package/app/composables/usePageTitle.ts +20 -0
- package/app/composables/useProduct/index.ts +2 -0
- package/app/composables/useProduct/types.ts +17 -0
- package/app/composables/useProduct/useProduct.ts +42 -0
- package/app/composables/useProductAttribute/__tests__/useProduct.mock.ts +31 -0
- package/app/composables/useProductAttribute/__tests__/useProductAttribute.spec.ts +14 -0
- package/app/composables/useProductAttribute/index.ts +1 -0
- package/app/composables/useProductAttribute/useProductAttribute.ts +37 -0
- package/app/composables/useProductRecommended/__tests__/useProductRecommended.spec.ts +12 -0
- package/app/composables/useProductRecommended/index.ts +1 -0
- package/app/composables/useProductRecommended/types.ts +17 -0
- package/app/composables/useProductRecommended/useProductRecommended.ts +43 -0
- package/app/composables/useProductReviews/__tests__/productReviews.mock.ts +20 -0
- package/app/composables/useProductReviews/__tests__/useProductReviews.spec.ts +22 -0
- package/app/composables/useProductReviews/index.ts +2 -0
- package/app/composables/useProductReviews/types.ts +17 -0
- package/app/composables/useProductReviews/useProductReviews.ts +46 -0
- package/app/composables/useProducts/__tests__/useProducts.spec.ts +11 -0
- package/app/composables/useProducts/types.ts +22 -0
- package/app/composables/useProducts/useProducts.ts +41 -0
- package/app/composables/useTax.ts +27 -0
- package/app/composables/validationRules/index.ts +1 -0
- package/app/composables/validationRules/password.feature +67 -0
- package/app/composables/validationRules/password.test.ts +89 -0
- package/app/composables/validationRules/password.ts +25 -0
- package/app/normalizers/Cart.query.ts +729 -0
- package/app/normalizers/Cart.type.ts +285 -0
- package/app/normalizers/Category.query.ts +146 -0
- package/app/normalizers/Category.type.ts +55 -0
- package/app/normalizers/CheckEmail.query.ts +28 -0
- package/app/normalizers/Checkout.query.ts +253 -0
- package/app/normalizers/Checkout.type.ts +77 -0
- package/app/normalizers/CmsBlock.query.ts +57 -0
- package/app/normalizers/CmsBlock.type.ts +25 -0
- package/app/normalizers/CmsPage.query.ts +59 -0
- package/app/normalizers/CmsPage.type.ts +26 -0
- package/app/normalizers/Config.query.ts +224 -0
- package/app/normalizers/Config.type.ts +196 -0
- package/app/normalizers/ContactForm.query.ts +49 -0
- package/app/normalizers/CreditMemo.type.ts +49 -0
- package/app/normalizers/GiftCard.type.ts +24 -0
- package/app/normalizers/Invoice.type.ts +58 -0
- package/app/normalizers/Menu.query.ts +54 -0
- package/app/normalizers/Menu.type.ts +22 -0
- package/app/normalizers/MyAccount.query.ts +268 -0
- package/app/normalizers/MyAccount.type.ts +129 -0
- package/app/normalizers/NewsletterSubscription.query.ts +38 -0
- package/app/normalizers/Order.query.ts +741 -0
- package/app/normalizers/Order.type.ts +268 -0
- package/app/normalizers/Payment.type.ts +28 -0
- package/app/normalizers/ProductAlerts.query.ts +23 -0
- package/app/normalizers/ProductCompare.query.ts +226 -0
- package/app/normalizers/ProductCompare.type.ts +90 -0
- package/app/normalizers/ProductList.query.ts +1620 -0
- package/app/normalizers/ProductList.type.ts +726 -0
- package/app/normalizers/Region.query.ts +58 -0
- package/app/normalizers/Region.type.ts +23 -0
- package/app/normalizers/Return.type.ts +50 -0
- package/app/normalizers/Review.query.ts +81 -0
- package/app/normalizers/Review.type.ts +42 -0
- package/app/normalizers/Slider.query.ts +72 -0
- package/app/normalizers/Slider.type.ts +26 -0
- package/app/normalizers/StoreInPickUp.query.ts +54 -0
- package/app/normalizers/StoreInPickUp.type.ts +59 -0
- package/app/normalizers/Subscription.type.ts +25 -0
- package/app/normalizers/Transaction.type.ts +20 -0
- package/app/normalizers/UrlRewrites.query.ts +55 -0
- package/app/normalizers/UrlRewrites.type.ts +25 -0
- package/app/normalizers/Wishlist.query.ts +202 -0
- package/app/normalizers/Wishlist.type.ts +42 -0
- package/app/pages/brand/[...slug].vue +76 -0
- package/app/pages/brands.vue +67 -0
- package/app/pages/cart.vue +142 -0
- package/app/pages/compare.vue +166 -0
- package/app/pages/departments/[...slug].vue +353 -0
- package/app/pages/departments/category/[...slug].vue +114 -0
- package/app/pages/incentive/[...id].vue +66 -0
- package/app/pages/invoice/[id].vue +309 -0
- package/app/pages/order/[id].vue +327 -0
- package/app/pages/product/[...id].vue +309 -0
- package/app/pages/product/showcases/index.vue +86 -0
- package/app/pages/shipment/[...id].vue +176 -0
- package/app/pages/shop/[...slug].vue +158 -0
- package/app/pages/shops.vue +76 -0
- package/app/pages/subscription/[...id].vue +147 -0
- package/app/pages/transaction/[...id].vue +74 -0
- package/app/routes/CategoryPage/CategoryPage.config.ts +28 -0
- package/app/routes/CategoryPage/CategoryPage.type.ts +8 -0
- package/app/routes/Checkout/Checkout.config.ts +3 -0
- package/app/routes/Checkout/Checkout.type.ts +14 -0
- package/app/routes/MyAccount/MyAccount.config.ts +1 -0
- package/app/routes/SearchPage/SearchPage.config.ts +1 -0
- package/app/routes/UrlRewrites/UrlRewrites.config.ts +5 -0
- package/app/stores/Cart/Cart.type.ts +26 -0
- package/app/stores/MyAccount/MyAccount.action.ts +7 -0
- package/app/stores/Notification/Notification.action.ts +40 -0
- package/app/stores/Notification/Notification.type.ts +16 -0
- package/app/stores/Popup/Popup.action.ts +30 -0
- package/app/stores/Product/Product.dispatcher.ts +53 -0
- package/app/stores/Product/Product.reducer.ts +12 -0
- package/app/stores/ProductList/ProductList.dispatcher.ts +35 -0
- package/app/stores/ProductList/ProductList.reducer.ts +13 -0
- package/app/stores/Store.type.ts +31 -0
- package/app/stores/Wishlist/Wishlist.type.ts +12 -0
- package/app/stores/cart.ts +218 -0
- package/app/stores/cartStore.ts +224 -0
- package/app/stores/checkout.ts +18 -0
- package/app/stores/compare.ts +65 -0
- package/app/stores/currency.js +29 -0
- package/app/stores/digital-products.js +11 -0
- package/app/stores/orders.ts +172 -0
- package/app/stores/product.ts +34 -0
- package/app/stores/productList.ts +35 -0
- package/app/stores/productListInfo.ts +0 -0
- package/app/stores/products.ts +118 -0
- package/app/stores/recentlyViewedProducts.ts +56 -0
- package/app/stores/review.ts +33 -0
- package/app/stores/storeInPickUp.ts +21 -0
- package/app/stores/user.ts +20 -0
- package/app/stores/wishlist.ts +46 -0
- package/app/types/Account.type.ts +141 -0
- package/app/types/Breadcrumbs.type.ts +23 -0
- package/app/types/CMS.type.ts +33 -0
- package/app/types/Category.type.ts +67 -0
- package/app/types/Checkout.type.ts +58 -0
- package/app/types/Common.type.ts +77 -0
- package/app/types/Config.type.ts +47 -0
- package/app/types/Device.type.ts +37 -0
- package/app/types/Direction.type.ts +23 -0
- package/app/types/Downloadable.type.ts +24 -0
- package/app/types/Error.type.ts +22 -0
- package/app/types/Field.type.ts +151 -0
- package/app/types/Global.type.ts +156 -0
- package/app/types/Graphql.type.ts +4497 -0
- package/app/types/Layout.type.ts +18 -0
- package/app/types/Menu.type.ts +39 -0
- package/app/types/MiniCart.type.ts +61 -0
- package/app/types/NotificationList.type.ts +34 -0
- package/app/types/Order.type.ts +174 -0
- package/app/types/Price.type.ts +72 -0
- package/app/types/ProductCompare.type.ts +24 -0
- package/app/types/ProductList.type.ts +351 -0
- package/app/types/Rating.type.ts +42 -0
- package/app/types/Router.type.ts +67 -0
- package/app/types/Slider.type.ts +25 -0
- package/app/types/StockStatus.type.ts +21 -0
- package/app/types/domain/index.ts +94 -0
- package/app/types/index.ts +33 -0
- package/app/types/shims.d.ts +52 -0
- package/app/types/tilework-opus.d.ts +48 -0
- package/app/utils/Address/Address.type.ts +28 -0
- package/app/utils/Address/index.ts +325 -0
- package/app/utils/Auth/IsSignedIn.ts +4 -0
- package/app/utils/Auth/Token.ts +9 -0
- package/app/utils/Base64/Base64.ts +16 -0
- package/app/utils/Base64/index.ts +12 -0
- package/app/utils/Browser/Browser.ts +29 -0
- package/app/utils/Browser/index.ts +12 -0
- package/app/utils/BrowserDatabase/BrowserDatabase.ts +70 -0
- package/app/utils/BrowserDatabase/index.ts +12 -0
- package/app/utils/CSS/CSS.ts +65 -0
- package/app/utils/CSS/index.ts +12 -0
- package/app/utils/Cache/Cache.ts +99 -0
- package/app/utils/Cart/Cart.ts +300 -0
- package/app/utils/Cart/Cart.type.ts +76 -0
- package/app/utils/Cart/Token.ts +59 -0
- package/app/utils/Cart/index.ts +13 -0
- package/app/utils/Category/Filters.ts +39 -0
- package/app/utils/Category/index.ts +12 -0
- package/app/utils/Common/index.ts +32 -0
- package/app/utils/Compare/Compare.ts +89 -0
- package/app/utils/Compare/index.ts +12 -0
- package/app/utils/Currency/Currency.ts +84 -0
- package/app/utils/Currency/index.ts +12 -0
- package/app/utils/DynamicReducer/DynamicReducer.type.ts +14 -0
- package/app/utils/DynamicReducer/Helper.ts +30 -0
- package/app/utils/DynamicReducer/index.tsx +35 -0
- package/app/utils/ElementTransition/ElementTransition.ts +100 -0
- package/app/utils/Form/Extract.ts +316 -0
- package/app/utils/Form/Form.ts +46 -0
- package/app/utils/Form/Form.type.ts +60 -0
- package/app/utils/Form/Transform.ts +33 -0
- package/app/utils/FormPortalCollector/index.ts +45 -0
- package/app/utils/History/History.type.ts +31 -0
- package/app/utils/History/index.ts +17 -0
- package/app/utils/Manipulations/Array.ts +18 -0
- package/app/utils/Manipulations/Date.ts +36 -0
- package/app/utils/Manipulations/index.ts +14 -0
- package/app/utils/Media/Media.ts +27 -0
- package/app/utils/Media/index.ts +13 -0
- package/app/utils/Menu/Menu.ts +116 -0
- package/app/utils/Menu/Menu.type.ts +37 -0
- package/app/utils/Menu/index.ts +12 -0
- package/app/utils/Mobile/index.ts +13 -0
- package/app/utils/Mobile/isMobile.ts +34 -0
- package/app/utils/Orders/Orders.ts +71 -0
- package/app/utils/Orders/Orders.type.ts +19 -0
- package/app/utils/Orders/index.ts +13 -0
- package/app/utils/Polyfill/index.ts +336 -0
- package/app/utils/Preload/CategoryPreload.ts +74 -0
- package/app/utils/Preload/ProductPreload.ts +28 -0
- package/app/utils/Preload/index.ts +75 -0
- package/app/utils/Price/Price.config.ts +189 -0
- package/app/utils/Price/Price.ts +63 -0
- package/app/utils/Price/index.ts +12 -0
- package/app/utils/Product/Extract.ts +652 -0
- package/app/utils/Product/Product.ts +575 -0
- package/app/utils/Product/Product.type.ts +260 -0
- package/app/utils/Product/Transform.ts +382 -0
- package/app/utils/Product/index.ts +12 -0
- package/app/utils/Promise/MakeCancelable.ts +44 -0
- package/app/utils/Promise/Promise.type.ts +15 -0
- package/app/utils/Promise/index.ts +13 -0
- package/app/utils/Query/Field.ts +71 -0
- package/app/utils/Query/Fragment.ts +22 -0
- package/app/utils/Query/PrepareDocument.ts +119 -0
- package/app/utils/Query/Query.type.ts +26 -0
- package/app/utils/Query/index.ts +15 -0
- package/app/utils/Request/Config.ts +21 -0
- package/app/utils/Request/DataContainer.ts +102 -0
- package/app/utils/Request/Debounce.ts +48 -0
- package/app/utils/Request/Error.ts +31 -0
- package/app/utils/Request/Hash.ts +88 -0
- package/app/utils/Request/LowPriorityLoad.ts +32 -0
- package/app/utils/Request/LowPriorityRender.ts +55 -0
- package/app/utils/Request/Mutation.ts +25 -0
- package/app/utils/Request/Query.ts +25 -0
- package/app/utils/Request/QueryDispatcher.ts +135 -0
- package/app/utils/Request/Request.ts +310 -0
- package/app/utils/Store/Store.type.ts +26 -0
- package/app/utils/Store/index.ts +71 -0
- package/app/utils/Url/Url.ts +297 -0
- package/app/utils/Url/index.ts +12 -0
- package/app/utils/Validator/Config.ts +96 -0
- package/app/utils/Validator/Validator.ts +268 -0
- package/app/utils/Validator/Validator.type.ts +47 -0
- package/app/utils/Validator/index.ts +12 -0
- package/app/utils/Wishlist/Wishlist.ts +65 -0
- package/app/utils/Wishlist/index.ts +12 -0
- package/app/utils/client.ts +280 -0
- package/app/utils/index.ts +53 -0
- package/app/utils/normalizer.ts +23 -0
- package/app/utils/normalizers/magento.ts +29 -0
- package/app/utils/normalizers/shopify.ts +29 -0
- package/nuxt.config.ts +11 -0
- package/package.json +43 -0
- package/tsconfig.json +45 -0
|
@@ -0,0 +1,729 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ScandiPWA - Progressive Web App for Magento
|
|
3
|
+
*
|
|
4
|
+
* Copyright © Scandiweb, Inc. All rights reserved.
|
|
5
|
+
* See LICENSE for license details.
|
|
6
|
+
*
|
|
7
|
+
* @license OSL-3.0 (Open Software License ("OSL") v. 3.0)
|
|
8
|
+
* @package scandipwa/scandipwa
|
|
9
|
+
* @link https://github.com/scandipwa/scandipwa
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
Field, InlineFragment, Mutation, Query,
|
|
14
|
+
} from '@tilework/opus';
|
|
15
|
+
|
|
16
|
+
import ProductListQuery from './ProductList.query';
|
|
17
|
+
import { CheckoutStepUrl } from '../routes/Checkout/Checkout.config';
|
|
18
|
+
import {
|
|
19
|
+
GQLCartItemInput, GQLCurrencyEnum, GQLUpdateCartItemsInput,
|
|
20
|
+
} from '../types/Graphql.type';
|
|
21
|
+
|
|
22
|
+
import {
|
|
23
|
+
AppliedTax,
|
|
24
|
+
AvailableShippingMethod,
|
|
25
|
+
CartAddress,
|
|
26
|
+
CartBundleItem,
|
|
27
|
+
CartBundleOption,
|
|
28
|
+
CartBundleOptionValue,
|
|
29
|
+
CartConfigurableItem,
|
|
30
|
+
CartConfigurableOption,
|
|
31
|
+
CartCustomizableOption,
|
|
32
|
+
CartCustomizableOptionValue,
|
|
33
|
+
CartDisplayConfig,
|
|
34
|
+
CartDownloadableItem,
|
|
35
|
+
CartDownloadableProductLink,
|
|
36
|
+
CartDownloadableProductSample,
|
|
37
|
+
CartItem,
|
|
38
|
+
CartItemPrices,
|
|
39
|
+
CartItemProduct,
|
|
40
|
+
CartPrices,
|
|
41
|
+
CartShippingAddress,
|
|
42
|
+
CartSimpleItem,
|
|
43
|
+
CartTotals,
|
|
44
|
+
CartVirtualItem,
|
|
45
|
+
Discount,
|
|
46
|
+
MinimumOrderAmount,
|
|
47
|
+
Money,
|
|
48
|
+
Region,
|
|
49
|
+
SelectedShippingMethod,
|
|
50
|
+
UserErrors,
|
|
51
|
+
} from './Cart.type';
|
|
52
|
+
|
|
53
|
+
/** @namespace ../../normalizers/Cart/Query */
|
|
54
|
+
export class CartQuery {
|
|
55
|
+
// #region MUTATIONS
|
|
56
|
+
getAddProductToCartMutation(cartId: string, cartItems: GQLCartItemInput[]): Mutation<
|
|
57
|
+
'addProductsToCart',
|
|
58
|
+
{ user_errors: UserErrors }
|
|
59
|
+
> {
|
|
60
|
+
return new Mutation<'addProductsToCart', { user_errors: UserErrors }>('addProductsToCart')
|
|
61
|
+
.addArgument('cartId', 'String!', cartId)
|
|
62
|
+
.addArgument('cartItems', '[CartItemInput!]!', cartItems)
|
|
63
|
+
.addField(this._getUserErrorsField());
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
getUpdateCartItemsMutation(input: GQLUpdateCartItemsInput): Mutation<'updateCartItems', { cart: { id: string } }> {
|
|
67
|
+
return new Mutation<'updateCartItems', { cart: { id: string } }>('updateCartItems')
|
|
68
|
+
.addArgument('input', 'UpdateCartItemsInput', input)
|
|
69
|
+
.addField(this._getCartUpdateField());
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
getCreateEmptyCartMutation(): Mutation<'createEmptyCart', { createEmptyCart: string }> {
|
|
73
|
+
return new Mutation<'createEmptyCart', { createEmptyCart: string }>('createEmptyCart');
|
|
74
|
+
}
|
|
75
|
+
// #endregion
|
|
76
|
+
|
|
77
|
+
// #region ERROR
|
|
78
|
+
_getUserErrorsFields(): Array<
|
|
79
|
+
Field<'message', string>
|
|
80
|
+
| Field<'code', string>
|
|
81
|
+
> {
|
|
82
|
+
return [
|
|
83
|
+
new Field<'message', string>('message'),
|
|
84
|
+
new Field<'code', string>('code'),
|
|
85
|
+
];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
_getUserErrorsField(): Field<'user_errors', UserErrors> {
|
|
89
|
+
return new Field<'user_errors', UserErrors>('user_errors')
|
|
90
|
+
.addFieldList(this._getUserErrorsFields());
|
|
91
|
+
}
|
|
92
|
+
// #endregion
|
|
93
|
+
|
|
94
|
+
_getCartUpdateField(): Field<'cart', { id: string }> {
|
|
95
|
+
return new Field<'cart', { id: string }>('cart')
|
|
96
|
+
.addField(new Field<'id', string>('id'));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
getRemoveCartItemMutation(
|
|
100
|
+
item_id: number,
|
|
101
|
+
quoteId: string,
|
|
102
|
+
): Mutation<'removeItemFromCart', { cartData: CartTotals }> {
|
|
103
|
+
const input = {
|
|
104
|
+
cart_id: quoteId,
|
|
105
|
+
cart_item_id: item_id,
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
return new Mutation<'removeItemFromCart', { cartData: CartTotals }>('removeItemFromCart')
|
|
109
|
+
.addArgument('input', 'RemoveItemFromCartInput', input)
|
|
110
|
+
.addField(this._getCart());
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
getMergeCartQuery(sourceCartId: string, destinationCartId: string): Mutation<'mergeCarts', { id: string }> {
|
|
114
|
+
return new Mutation<'mergeCarts', { id: string }>('mergeCarts')
|
|
115
|
+
.addArgument('source_cart_id', 'String!', sourceCartId)
|
|
116
|
+
.addArgument('destination_cart_id', 'String!', destinationCartId)
|
|
117
|
+
.addField(new Field<'id', string>('id'));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/* Cart config */
|
|
121
|
+
|
|
122
|
+
getCartDisplayConfig(): Query<'cartDisplayConfig', CartDisplayConfig> {
|
|
123
|
+
return new Query<'getCartDisplayConfig', CartDisplayConfig>('getCartDisplayConfig')
|
|
124
|
+
.setAlias('cartDisplayConfig')
|
|
125
|
+
.addFieldList(this._getCartDisplayConfigFields());
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
_getCartDisplayConfigFields(): Array<
|
|
129
|
+
Field<'display_tax_in_price', string>
|
|
130
|
+
| Field<'display_tax_in_subtotal', string>
|
|
131
|
+
| Field<'display_tax_in_shipping_amount', string>
|
|
132
|
+
| Field<'include_tax_in_order_total', boolean>
|
|
133
|
+
| Field<'display_full_tax_summary', boolean>
|
|
134
|
+
| Field<'display_zero_tax_subtotal', boolean>
|
|
135
|
+
> {
|
|
136
|
+
return [
|
|
137
|
+
new Field<'display_tax_in_price', string>('display_tax_in_price'),
|
|
138
|
+
new Field<'display_tax_in_subtotal', string>('display_tax_in_subtotal'),
|
|
139
|
+
new Field<'display_tax_in_shipping_amount', string>('display_tax_in_shipping_amount'),
|
|
140
|
+
new Field<'include_tax_in_order_total', boolean>('include_tax_in_order_total'),
|
|
141
|
+
new Field<'display_full_tax_summary', boolean>('display_full_tax_summary'),
|
|
142
|
+
new Field<'display_zero_tax_subtotal', boolean>('display_zero_tax_subtotal'),
|
|
143
|
+
];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/* Data for new cart */
|
|
147
|
+
|
|
148
|
+
getCartQuery(cartId: string): Query<'cartData', CartTotals> {
|
|
149
|
+
return new Query<'cart', CartTotals>('cart')
|
|
150
|
+
.setAlias('cartData')
|
|
151
|
+
.addArgument('cart_id', 'String!', cartId)
|
|
152
|
+
.addFieldList(this._getCartTotalsFields());
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
_getCartTotalsFields(): Array<
|
|
156
|
+
Field<'id', string>
|
|
157
|
+
| Field<'email', string>
|
|
158
|
+
| Field<'prices', CartPrices>
|
|
159
|
+
| Field<'shipping_addresses', CartShippingAddress, true>
|
|
160
|
+
| Field<'minimum_order_amount', MinimumOrderAmount>
|
|
161
|
+
| Field<'items', CartItem, true>
|
|
162
|
+
| Field<'total_quantity', number>
|
|
163
|
+
| Field<'is_virtual', boolean>
|
|
164
|
+
| Field<'is_in_store_pickup_available', boolean>
|
|
165
|
+
> {
|
|
166
|
+
return [
|
|
167
|
+
new Field<'id', string>('id'),
|
|
168
|
+
new Field<'email', string>('email'),
|
|
169
|
+
this._getPricesField(),
|
|
170
|
+
this._getShippingAddressesField(),
|
|
171
|
+
this._getMinimumOrderAmount(),
|
|
172
|
+
this._getCartItemsField(),
|
|
173
|
+
new Field<'total_quantity', number>('total_quantity'),
|
|
174
|
+
new Field<'is_virtual', boolean>('is_virtual'),
|
|
175
|
+
new Field<'is_in_store_pickup_available', boolean>('is_in_store_pickup_available'),
|
|
176
|
+
];
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
_getPriceField(): Array<
|
|
180
|
+
Field<'value', number>
|
|
181
|
+
| Field<'currency', GQLCurrencyEnum>
|
|
182
|
+
> {
|
|
183
|
+
return [
|
|
184
|
+
new Field<'value', number>('value'),
|
|
185
|
+
new Field<'currency', GQLCurrencyEnum>('currency'),
|
|
186
|
+
];
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
_getAmountField(): Field<'amount', Money> {
|
|
190
|
+
return new Field<'amount', Money>('amount')
|
|
191
|
+
.addFieldList(this._getPriceField());
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
_getBaseAmountField(): Field<'base_amount', Money> {
|
|
195
|
+
return new Field<'base_amount', Money>('base_amount')
|
|
196
|
+
.addFieldList(this._getPriceField());
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
_getCartItemsField(): Field<'items', CartItem, true> {
|
|
200
|
+
return new Field<'items', CartItem, true>('items', true)
|
|
201
|
+
.addFieldList(this._getCartItemsFields());
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
_getCartItemsFields(): Array<
|
|
205
|
+
Field<'id', number>
|
|
206
|
+
| Field<'uid', string>
|
|
207
|
+
| Field<'sku', string>
|
|
208
|
+
| Field<'quantity', number>
|
|
209
|
+
| Field<'product', CartItemProduct>
|
|
210
|
+
| Field<'prices', CartItemPrices>
|
|
211
|
+
| InlineFragment<'DownloadableCartItem', CartDownloadableItem>
|
|
212
|
+
| InlineFragment<'BundleCartItem', CartBundleItem>
|
|
213
|
+
| InlineFragment<'ConfigurableCartItem', CartConfigurableItem>
|
|
214
|
+
| InlineFragment<'VirtualCartItem', CartVirtualItem>
|
|
215
|
+
| InlineFragment<'SimpleCartItem', CartSimpleItem>
|
|
216
|
+
> {
|
|
217
|
+
return [
|
|
218
|
+
new Field<'id', number>('id'),
|
|
219
|
+
new Field<'uid', string>('uid'),
|
|
220
|
+
new Field<'sku', string>('sku'),
|
|
221
|
+
new Field<'quantity', number>('quantity'),
|
|
222
|
+
this._getCartItemProduct(),
|
|
223
|
+
this._getCartItemPricesField(),
|
|
224
|
+
this._getCartDownloadableProductLinkField(),
|
|
225
|
+
this._getCartBundleProductFragment(),
|
|
226
|
+
this._getCartConfigurableProductFragment(),
|
|
227
|
+
this._getCartVirtualProductFragments(),
|
|
228
|
+
this._getCartSimpleProductFragments(),
|
|
229
|
+
];
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
_getCartItemProduct(): Field<'product', CartItemProduct> {
|
|
233
|
+
return new Field<'product', CartItemProduct>('product')
|
|
234
|
+
.addFieldList(ProductListQuery._getCartProductInterfaceFields());
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
_getCartDownloadableProductLinkField(): InlineFragment<
|
|
238
|
+
'DownloadableCartItem',
|
|
239
|
+
CartDownloadableItem
|
|
240
|
+
> {
|
|
241
|
+
return new InlineFragment<
|
|
242
|
+
'DownloadableCartItem',
|
|
243
|
+
CartDownloadableItem
|
|
244
|
+
>('DownloadableCartItem')
|
|
245
|
+
.addFieldList([
|
|
246
|
+
this._getDownloadableLinkField(),
|
|
247
|
+
this._getDownloadableSamplesField(),
|
|
248
|
+
this._getCustomizableOptionsField('downloadable_customizable_options'),
|
|
249
|
+
]);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
_getDownloadableLinkField(): Field<'links', CartDownloadableProductLink, true> {
|
|
253
|
+
return new Field<'links', CartDownloadableProductLink, true>('links', true)
|
|
254
|
+
.addFieldList(this._getDownloadableLinkFields());
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
_getDownloadableLinkFields(): Array<
|
|
258
|
+
Field<'id', number>
|
|
259
|
+
| Field<'title', string>
|
|
260
|
+
| Field<'sort_order', number>
|
|
261
|
+
| Field<'price', number>
|
|
262
|
+
> {
|
|
263
|
+
return [
|
|
264
|
+
new Field<'id', number>('id'),
|
|
265
|
+
new Field<'title', string>('title'),
|
|
266
|
+
new Field<'sort_order', number>('sort_order'),
|
|
267
|
+
new Field<'price', number>('price'),
|
|
268
|
+
];
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
_getDownloadableSamplesField(): Field<'samples', CartDownloadableProductSample, true> {
|
|
272
|
+
return new Field<'samples', CartDownloadableProductSample, true>('samples', true)
|
|
273
|
+
.addFieldList(this._getDownloadableSamplesFields());
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
_getDownloadableSamplesFields(): Array<
|
|
277
|
+
Field<'id', number>
|
|
278
|
+
| Field<'title', string>
|
|
279
|
+
> {
|
|
280
|
+
return [
|
|
281
|
+
new Field<'id', number>('id'),
|
|
282
|
+
new Field<'title', string>('title'),
|
|
283
|
+
];
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
_getCartBundleProductFragment(): InlineFragment<'BundleCartItem', CartBundleItem> {
|
|
287
|
+
return new InlineFragment<'BundleCartItem', CartBundleItem>('BundleCartItem')
|
|
288
|
+
.addFieldList([
|
|
289
|
+
this._getBundleOptionsField(),
|
|
290
|
+
this._getCustomizableOptionsField('bundle_customizable_options'),
|
|
291
|
+
]);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
_getBundleOptionsField(): Field<'bundle_options', CartBundleOption, true> {
|
|
295
|
+
return new Field<'bundle_options', CartBundleOption, true>('bundle_options')
|
|
296
|
+
.addFieldList(this._getBundleOptionsFields());
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
_getBundleOptionsFields(): Array<
|
|
300
|
+
Field<'id', number>
|
|
301
|
+
| Field<'label', string>
|
|
302
|
+
| Field<'type', string>
|
|
303
|
+
| Field<'values', CartBundleOptionValue, true>
|
|
304
|
+
> {
|
|
305
|
+
return [
|
|
306
|
+
new Field<'id', number>('id'),
|
|
307
|
+
new Field<'label', string>('label'),
|
|
308
|
+
new Field<'type', string>('type'),
|
|
309
|
+
this._getBundleOptionValuesField(),
|
|
310
|
+
];
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
_getBundleOptionValuesField(): Field<'values', CartBundleOptionValue, true> {
|
|
314
|
+
return new Field<'values', CartBundleOptionValue, true>('values', true)
|
|
315
|
+
.addFieldList(this._getBundleOptionValuesFields());
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
_getBundleOptionValuesFields(): Array<
|
|
319
|
+
Field<'id', number>
|
|
320
|
+
| Field<'label', string>
|
|
321
|
+
| Field<'quantity', number>
|
|
322
|
+
| Field<'price', number>
|
|
323
|
+
> {
|
|
324
|
+
return [
|
|
325
|
+
new Field<'id', number>('id'),
|
|
326
|
+
new Field<'label', string>('label'),
|
|
327
|
+
new Field<'quantity', number>('quantity'),
|
|
328
|
+
new Field<'price', number>('price'),
|
|
329
|
+
];
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
_getCartConfigurableProductFragment(): InlineFragment<'ConfigurableCartItem', CartConfigurableItem> {
|
|
333
|
+
return new InlineFragment<'ConfigurableCartItem', CartConfigurableItem>('ConfigurableCartItem')
|
|
334
|
+
.addFieldList([
|
|
335
|
+
this._getConfigurableOptionsField(),
|
|
336
|
+
this._getCustomizableOptionsField('configurable_customizable_options'),
|
|
337
|
+
]);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
_getConfigurableOptionsField(): Field<'configurable_options', CartConfigurableOption> {
|
|
341
|
+
return new Field<'configurable_options', CartConfigurableOption>('configurable_options')
|
|
342
|
+
.addFieldList(this._getConfigurableOptionsFields());
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
_getConfigurableOptionsFields(): Array<
|
|
346
|
+
Field<'id', number>
|
|
347
|
+
| Field<'option_label', string>
|
|
348
|
+
| Field<'value_label', string>
|
|
349
|
+
> {
|
|
350
|
+
return [
|
|
351
|
+
new Field<'id', number>('id'),
|
|
352
|
+
new Field<'option_label', string>('option_label'),
|
|
353
|
+
new Field<'value_label', string>('value_label'),
|
|
354
|
+
];
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
_getCartSimpleProductFragments(): InlineFragment<
|
|
358
|
+
'SimpleCartItem',
|
|
359
|
+
CartSimpleItem
|
|
360
|
+
> {
|
|
361
|
+
return new InlineFragment<
|
|
362
|
+
'SimpleCartItem',
|
|
363
|
+
CartSimpleItem
|
|
364
|
+
>('SimpleCartItem')
|
|
365
|
+
.addFieldList([
|
|
366
|
+
this._getCustomizableOptionsField('simple_customizable_options'),
|
|
367
|
+
]);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
_getCartVirtualProductFragments(): InlineFragment<
|
|
371
|
+
'VirtualCartItem',
|
|
372
|
+
CartVirtualItem
|
|
373
|
+
> {
|
|
374
|
+
return new InlineFragment<
|
|
375
|
+
'VirtualCartItem',
|
|
376
|
+
CartVirtualItem
|
|
377
|
+
>('VirtualCartItem')
|
|
378
|
+
.addFieldList([
|
|
379
|
+
this._getCustomizableOptionsField('virtual_customizable_options'),
|
|
380
|
+
]);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
_getCustomizableOptionsField<A extends string>(
|
|
384
|
+
alias: A,
|
|
385
|
+
): Field<A, CartCustomizableOption, true> {
|
|
386
|
+
return new Field<'customizable_options', CartCustomizableOption, true>('customizable_options', true)
|
|
387
|
+
.setAlias(alias)
|
|
388
|
+
.addFieldList(this._getCustomizableOptionsFields());
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
_getCustomizableOptionsFields(): Array<
|
|
392
|
+
Field<'id', number>
|
|
393
|
+
| Field<'label', string>
|
|
394
|
+
| Field<'type', string>
|
|
395
|
+
| Field<'sort_order', number>
|
|
396
|
+
| Field<'is_required', boolean>
|
|
397
|
+
| Field<'values', CartCustomizableOptionValue, true>
|
|
398
|
+
> {
|
|
399
|
+
return [
|
|
400
|
+
new Field<'id', number>('id'),
|
|
401
|
+
new Field<'label', string>('label'),
|
|
402
|
+
new Field<'type', string>('type'),
|
|
403
|
+
new Field<'sort_order', number>('sort_order'),
|
|
404
|
+
new Field<'is_required', boolean>('is_required'),
|
|
405
|
+
this._getCustomizableOptionValueField(),
|
|
406
|
+
];
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
_getCustomizableOptionValueField(): Field<'values', CartCustomizableOptionValue, true> {
|
|
410
|
+
return new Field<'values', CartCustomizableOptionValue, true>('values', true)
|
|
411
|
+
.addFieldList(this._getCustomizableOptionValueFields());
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
_getCustomizableOptionValueFields(): Array<
|
|
415
|
+
Field<'id', number>
|
|
416
|
+
| Field<'label', string>
|
|
417
|
+
| Field<'value', string>
|
|
418
|
+
> {
|
|
419
|
+
return [
|
|
420
|
+
new Field<'id', number>('id'),
|
|
421
|
+
new Field<'label', string>('label'),
|
|
422
|
+
new Field<'value', string>('value'),
|
|
423
|
+
];
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
_getCartItemPricesField(): Field<'prices', CartItemPrices> {
|
|
427
|
+
return new Field<'prices', CartItemPrices>('prices')
|
|
428
|
+
.addFieldList(this._getCartItemPricesFields());
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
_getCartItemPricesFields(): Array<
|
|
432
|
+
Field<'price', Money>
|
|
433
|
+
| Field<'row_total', Money>
|
|
434
|
+
| Field<'row_total_including_tax', Money>
|
|
435
|
+
| Field<'discounts', Money>
|
|
436
|
+
| Field<'total_item_discount', Money>
|
|
437
|
+
> {
|
|
438
|
+
return [
|
|
439
|
+
this._getCartItemPriceField(),
|
|
440
|
+
this._getCartItemRowTotalField(),
|
|
441
|
+
this._getCartItemRowTotalInclTaxField(),
|
|
442
|
+
this._getCartItemTotalDiscountField(),
|
|
443
|
+
];
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
_getCartItemPriceField(): Field<'price', Money> {
|
|
447
|
+
return new Field<'price', Money>('price')
|
|
448
|
+
.addFieldList(this._getPriceField());
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
_getCartItemRowTotalField(): Field<'row_total', Money> {
|
|
452
|
+
return new Field<'row_total', Money>('row_total')
|
|
453
|
+
.addFieldList(this._getPriceField());
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
_getCartItemRowTotalInclTaxField(): Field<'row_total_including_tax', Money> {
|
|
457
|
+
return new Field<'row_total_including_tax', Money>('row_total_including_tax')
|
|
458
|
+
.addFieldList(this._getPriceField());
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
_getCartItemDiscountsField(): Field<'discounts', Money, true> {
|
|
462
|
+
return new Field<'discounts', Money, true>('discounts', true)
|
|
463
|
+
.addFieldList(this._getPriceField());
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
_getCartItemTotalDiscountField(): Field<'total_item_discount', Money> {
|
|
467
|
+
return new Field<'total_item_discount', Money>('total_item_discount')
|
|
468
|
+
.addFieldList(this._getPriceField());
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
_getPricesField(): Field<'prices', CartPrices> {
|
|
472
|
+
return new Field<'prices', CartPrices>('prices')
|
|
473
|
+
.addFieldList(this._getPricesFields());
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
_getPricesFields(): Array<
|
|
477
|
+
Field<'applied_rule_ids', string>
|
|
478
|
+
| Field<'coupon_code', string>
|
|
479
|
+
| Field<'quote_currency_code', string>
|
|
480
|
+
| Field<'grand_total', Money>
|
|
481
|
+
| Field<'subtotal_including_tax', Money>
|
|
482
|
+
| Field<'subtotal_excluding_tax', Money>
|
|
483
|
+
| Field<'subtotal_with_discount_excluding_tax', Money>
|
|
484
|
+
| Field<'discount', Discount>
|
|
485
|
+
| Field<'applied_taxes', AppliedTax>
|
|
486
|
+
> {
|
|
487
|
+
return [
|
|
488
|
+
new Field<'applied_rule_ids', string>('applied_rule_ids'),
|
|
489
|
+
new Field<'coupon_code', string>('coupon_code'),
|
|
490
|
+
new Field<'quote_currency_code', string>('quote_currency_code'),
|
|
491
|
+
this._getGrandTotalField(),
|
|
492
|
+
this._getSubtotalInclTaxField(),
|
|
493
|
+
this._getSubtotalExclTaxField(),
|
|
494
|
+
this._getSubtotalWithDiscountExclTaxField(),
|
|
495
|
+
this._getDiscountField(),
|
|
496
|
+
this._getAppliedTaxesField(),
|
|
497
|
+
];
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
_getGrandTotalField(): Field<'grand_total', Money> {
|
|
501
|
+
return new Field<'grand_total', Money>('grand_total')
|
|
502
|
+
.addFieldList(this._getPriceField());
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
_getSubtotalInclTaxField(): Field<'subtotal_including_tax', Money> {
|
|
506
|
+
return new Field<'subtotal_including_tax', Money>('subtotal_including_tax')
|
|
507
|
+
.addFieldList(this._getPriceField());
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
_getSubtotalExclTaxField(): Field<'subtotal_excluding_tax', Money> {
|
|
511
|
+
return new Field<'subtotal_excluding_tax', Money>('subtotal_excluding_tax')
|
|
512
|
+
.addFieldList(this._getPriceField());
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
_getSubtotalWithDiscountExclTaxField(): Field<'subtotal_with_discount_excluding_tax', Money> {
|
|
516
|
+
return new Field<'subtotal_with_discount_excluding_tax', Money>('subtotal_with_discount_excluding_tax')
|
|
517
|
+
.addFieldList(this._getPriceField());
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
_getDiscountField(): Field<'discount', Discount> {
|
|
521
|
+
return new Field<'discount', Discount>('discount')
|
|
522
|
+
.addFieldList(this._getDiscountFields());
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
_getDiscountFields(): Array<
|
|
526
|
+
Field<'label', string>
|
|
527
|
+
| Field<'amount', Money>
|
|
528
|
+
> {
|
|
529
|
+
return [
|
|
530
|
+
new Field<'label', string>('label'),
|
|
531
|
+
this._getAmountField(),
|
|
532
|
+
];
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
_getAppliedTaxesField(): Field<'applied_taxes', AppliedTax> {
|
|
536
|
+
return new Field<'applied_taxes', AppliedTax>('applied_taxes')
|
|
537
|
+
.addFieldList(this._getAppliedTaxesFields());
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
_getAppliedTaxesFields(): Array<
|
|
541
|
+
Field<'label', string>
|
|
542
|
+
| Field<'percent', number>
|
|
543
|
+
| Field<'amount', Money>
|
|
544
|
+
> {
|
|
545
|
+
return [
|
|
546
|
+
new Field<'label', string>('label'),
|
|
547
|
+
new Field<'percent', number>('percent'),
|
|
548
|
+
this._getAmountField(),
|
|
549
|
+
];
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
_getShippingAddressesField(): Field<'shipping_addresses', CartShippingAddress, true> {
|
|
553
|
+
return new Field<'shipping_addresses', CartShippingAddress, true>('shipping_addresses', true)
|
|
554
|
+
.addFieldList(this._getShippingAddressesFields());
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
_getShippingAddressesFields(): Array<
|
|
558
|
+
Field<'available_shipping_methods', AvailableShippingMethod, true>
|
|
559
|
+
| Field<'selected_shipping_method', SelectedShippingMethod>
|
|
560
|
+
| Field<'customer_notes', string>
|
|
561
|
+
> {
|
|
562
|
+
return [
|
|
563
|
+
this._getAvailableShippingMethodField(),
|
|
564
|
+
this._getSelectedShippingMethodField(),
|
|
565
|
+
new Field<'customer_notes', string>('customer_notes'),
|
|
566
|
+
];
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
_getAvailableShippingMethodField(): Field<'available_shipping_methods', AvailableShippingMethod, true> {
|
|
570
|
+
return new Field<
|
|
571
|
+
'available_shipping_methods',
|
|
572
|
+
AvailableShippingMethod,
|
|
573
|
+
true
|
|
574
|
+
>('available_shipping_methods', true)
|
|
575
|
+
.addFieldList(this._getAvailableShippingMethodFields());
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
_getAvailableShippingMethodFields(): Array<
|
|
579
|
+
Field<'available', boolean>
|
|
580
|
+
| Field<'method_code', string>
|
|
581
|
+
| Field<'carrier_code', string>
|
|
582
|
+
| Field<'carrier_title', string>
|
|
583
|
+
| Field<'error_message', string>
|
|
584
|
+
> {
|
|
585
|
+
return [
|
|
586
|
+
new Field<'available', boolean>('available'),
|
|
587
|
+
new Field<'method_code', string>('method_code'),
|
|
588
|
+
new Field<'carrier_code', string>('carrier_code'),
|
|
589
|
+
new Field<'carrier_title', string>('carrier_title'),
|
|
590
|
+
new Field<'error_message', string>('error_message'),
|
|
591
|
+
];
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
_getSelectedShippingMethodField(): Field<'selected_shipping_method', SelectedShippingMethod> {
|
|
595
|
+
return new Field<'selected_shipping_method', SelectedShippingMethod>('selected_shipping_method')
|
|
596
|
+
.addFieldList(this._getSelectedShippingMethodFields());
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
_getSelectedShippingMethodFields(): Array<
|
|
600
|
+
Field<'amount_incl_tax', number>
|
|
601
|
+
| Field<'carrier_code', string>
|
|
602
|
+
| Field<'carrier_title', string>
|
|
603
|
+
| Field<'method_code', string>
|
|
604
|
+
| Field<'method_title', string>
|
|
605
|
+
| Field<'tax_amount', number>
|
|
606
|
+
| Field<'amount', Money>
|
|
607
|
+
| Field<'address', CartAddress>
|
|
608
|
+
> {
|
|
609
|
+
const { pathname = '' } = location;
|
|
610
|
+
const checkoutData = (
|
|
611
|
+
pathname.includes(CheckoutStepUrl.CHECKOUT_URL)
|
|
612
|
+
? [this._getOrderShippingAddressField()]
|
|
613
|
+
: []
|
|
614
|
+
);
|
|
615
|
+
|
|
616
|
+
return [
|
|
617
|
+
new Field<'amount_incl_tax', number>('amount_incl_tax'),
|
|
618
|
+
new Field<'carrier_code', string>('carrier_code'),
|
|
619
|
+
new Field<'carrier_title', string>('carrier_title'),
|
|
620
|
+
new Field<'method_code', string>('method_code'),
|
|
621
|
+
new Field<'method_title', string>('method_title'),
|
|
622
|
+
new Field<'tax_amount', number>('tax_amount'),
|
|
623
|
+
this._getAmountField(),
|
|
624
|
+
...checkoutData,
|
|
625
|
+
];
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
_getOrderShippingAddressField(): Field<'address', CartAddress> {
|
|
629
|
+
return new Field<'address', CartAddress>('address')
|
|
630
|
+
.addFieldList(this._getOrderAddressFields());
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
_getOrderAddressFields(): Array<
|
|
634
|
+
Field<'city', string>
|
|
635
|
+
| Field<'country', { code: string }>
|
|
636
|
+
| Field<'firstname', string>
|
|
637
|
+
| Field<'lastname', string>
|
|
638
|
+
| Field<'postcode', string>
|
|
639
|
+
| Field<'region', Region>
|
|
640
|
+
| Field<'telephone', string>
|
|
641
|
+
| Field<'vat_id', string>
|
|
642
|
+
| Field<'email', string>
|
|
643
|
+
| Field<'street', string>
|
|
644
|
+
> {
|
|
645
|
+
return [
|
|
646
|
+
new Field<'city', string>('city'),
|
|
647
|
+
this._getCountryField(),
|
|
648
|
+
new Field<'firstname', string>('firstname'),
|
|
649
|
+
new Field<'lastname', string>('lastname'),
|
|
650
|
+
new Field<'postcode', string>('postcode'),
|
|
651
|
+
this._getRegionField(),
|
|
652
|
+
new Field<'telephone', string>('telephone'),
|
|
653
|
+
new Field<'vat_id', string>('vat_id'),
|
|
654
|
+
new Field<'email', string>('email'),
|
|
655
|
+
new Field<'street', string>('street'),
|
|
656
|
+
];
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
_getCountryField(): Field<'country', { code: string }> {
|
|
660
|
+
return new Field<'country', { code: string }>('country')
|
|
661
|
+
.addFieldList(this._getCountryFields());
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
_getCountryFields(): Array<Field<'code', string>> {
|
|
665
|
+
return [
|
|
666
|
+
new Field<'code', string>('code'),
|
|
667
|
+
];
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
_getRegionField(): Field<'region', Region> {
|
|
671
|
+
return new Field<'region', Region>('region')
|
|
672
|
+
.addFieldList(this._getRegionFields());
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
_getRegionFields(): Array<
|
|
676
|
+
Field<'label', string>
|
|
677
|
+
| Field<'region_id', number>
|
|
678
|
+
> {
|
|
679
|
+
return [
|
|
680
|
+
new Field<'label', string>('label'),
|
|
681
|
+
new Field<'region_id', number>('region_id'),
|
|
682
|
+
];
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
_getMinimumOrderAmount(): Field<'minimum_order_amount', MinimumOrderAmount> {
|
|
686
|
+
return new Field<'minimum_order_amount', MinimumOrderAmount>('minimum_order_amount')
|
|
687
|
+
.addFieldList(this._getMinimumOrderAmountFields());
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
_getMinimumOrderAmountFields(): Array<
|
|
691
|
+
Field<'minimum_order_amount_reached', boolean>
|
|
692
|
+
| Field<'minimum_order_description', string>
|
|
693
|
+
> {
|
|
694
|
+
return [
|
|
695
|
+
new Field<'minimum_order_amount_reached', boolean>('minimum_order_amount_reached'),
|
|
696
|
+
new Field<'minimum_order_description', string>('minimum_order_description'),
|
|
697
|
+
];
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
/* Cart coupon */
|
|
701
|
+
|
|
702
|
+
_getCart(): Field<'cartData', CartTotals> {
|
|
703
|
+
return new Field<'cart', CartTotals>('cart')
|
|
704
|
+
.setAlias('cartData')
|
|
705
|
+
.addFieldList(this._getCartTotalsFields());
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
getApplyCouponMutation(
|
|
709
|
+
couponCode: string,
|
|
710
|
+
quoteId: string,
|
|
711
|
+
): Mutation<'applyCouponToCart', { cartData: CartTotals }> {
|
|
712
|
+
const input = {
|
|
713
|
+
cart_id: quoteId,
|
|
714
|
+
coupon_code: couponCode,
|
|
715
|
+
};
|
|
716
|
+
|
|
717
|
+
return new Mutation<'applyCouponToCart', { cartData: CartTotals }>('applyCouponToCart')
|
|
718
|
+
.addArgument('input', 'ApplyCouponToCartInput', input)
|
|
719
|
+
.addField(this._getCart());
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
getRemoveCouponMutation(quoteId: string): Mutation<'removeCouponFromCart', { cartData: CartTotals }> {
|
|
723
|
+
return new Mutation<'removeCouponFromCart', { cartData: CartTotals }>('removeCouponFromCart')
|
|
724
|
+
.addArgument('input', 'RemoveCouponFromCartInput', { cart_id: quoteId })
|
|
725
|
+
.addField(this._getCart());
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
export default new CartQuery();
|