@meeovi/layer-commerce 1.0.3 → 1.0.5
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/app/components/catalog/product/ProductAccordion/types.ts +3 -3
- package/app/components/catalog/product/ProductProperties/types.ts +3 -3
- package/app/components/catalog/product/ProductSlider/types.ts +5 -5
- package/app/components/catalog/product/RecommendedProducts/types.ts +3 -3
- package/app/components/catalog/product/bestsellers.vue +8 -20
- package/app/components/catalog/product/deals.vue +7 -22
- package/app/components/catalog/product/exclusives.vue +8 -10
- package/app/components/catalog/product/featuredproducts.vue +8 -20
- package/app/components/catalog/product/latestproducts.vue +8 -20
- package/app/components/catalog/product/productCard.vue +55 -21
- package/app/components/catalog/product/productDetails.vue +20 -14
- package/app/components/catalog/product/relatedproducts.vue +5 -20
- package/app/components/catalog/product/sizeOptions.vue +3 -8
- package/app/components/catalog/shops/relatedstores.vue +6 -21
- package/app/components/categories/chart/[id].vue +200 -0
- package/app/components/categories/chart/add-chart.vue +142 -0
- package/app/components/categories/chart/chart.vue +82 -0
- package/app/components/categories/chart/monthlyChart.vue +46 -0
- package/app/components/categories/chart/weeklyChart.vue +46 -0
- package/app/components/categories/chart/yearlyChart.vue +46 -0
- package/app/components/categories/charts.vue +118 -0
- package/app/components/categories/deals.vue +101 -0
- package/app/components/categories/eats.vue +49 -0
- package/app/components/categories/restaurants.vue +26 -0
- package/app/components/categories/station/[id].vue +72 -0
- package/app/components/categories/stations.vue +124 -0
- package/app/components/categories/time/time.vue +63 -0
- package/app/components/categories/travel.vue +75 -0
- package/app/components/categories/weather/weather.vue +44 -0
- package/app/components/content/pages/showcases.vue +1 -1
- package/app/components/marketing/promotions/giftcards.vue +20 -45
- package/app/components/marketing/promotions/subscriptions.vue +8 -21
- package/app/components/placeholders/Comments.vue +15 -0
- package/app/components/placeholders/CreateListBtn.vue +7 -0
- package/app/components/placeholders/Event.vue +9 -0
- package/app/components/placeholders/ListShowcases.vue +9 -0
- package/app/components/placeholders/Short.vue +9 -0
- package/app/components/placeholders/Space.vue +9 -0
- package/app/components/placeholders/Tag.vue +7 -0
- package/app/components/sales/CheckoutAddress/types.ts +12 -11
- package/app/components/sales/OrderSummary/types.ts +3 -3
- package/app/components/sales/incentives.vue +13 -37
- package/app/composables/_types.ts +6 -5
- package/app/composables/cart/registry.ts +7 -0
- package/app/composables/index.ts +1 -0
- package/app/composables/products/registry.ts +7 -0
- package/app/composables/registry.ts +21 -0
- package/app/composables/stores/cart.ts +2 -2
- package/app/composables/useCatalog.ts +64 -0
- package/app/composables/useContent.ts +57 -0
- package/app/composables/useProductReviews/useProductReviews.ts +1 -1
- package/app/composables/useProducts/types.ts +15 -10
- package/app/modules/vue-head/composables/useHead.ts +3 -0
- package/app/pages/brand/[...slug].vue +1 -1
- package/app/pages/departments/[...slug].vue +385 -0
- package/app/pages/departments/category/[...slug].vue +135 -0
- package/app/pages/product/[...id].vue +3 -3
- package/app/pages/shop/[...slug].vue +12 -18
- package/app/pages/shops.vue +18 -25
- package/dist/components/catalog/product/ProductAccordion/types.d.ts +4 -0
- package/dist/components/catalog/product/ProductAccordion/types.js +1 -0
- package/dist/components/catalog/product/ProductProperties/types.d.ts +4 -0
- package/dist/components/catalog/product/ProductProperties/types.js +1 -0
- package/dist/components/catalog/product/ProductSlider/types.d.ts +6 -0
- package/dist/components/catalog/product/ProductSlider/types.js +1 -0
- package/dist/components/catalog/product/RecommendedProducts/types.d.ts +4 -0
- package/dist/components/catalog/product/RecommendedProducts/types.js +1 -0
- package/dist/components/sales/CheckoutAddress/types.d.ts +14 -0
- package/dist/components/sales/CheckoutAddress/types.js +1 -0
- package/dist/components/sales/CheckoutPayment/types.d.ts +10 -0
- package/dist/components/sales/CheckoutPayment/types.js +7 -0
- package/dist/components/sales/OrderSummary/types.d.ts +4 -0
- package/dist/components/sales/OrderSummary/types.js +1 -0
- package/dist/composables/_types.d.ts +11 -0
- package/dist/composables/_types.js +1 -0
- package/dist/composables/adapters/abstract/cartAdapter.d.ts +0 -0
- package/dist/composables/adapters/abstract/cartAdapter.js +0 -0
- package/dist/composables/adapters/abstract/categoryAdapter.d.ts +0 -0
- package/dist/composables/adapters/abstract/categoryAdapter.js +0 -0
- package/dist/composables/adapters/abstract/customerAdapter.d.ts +0 -0
- package/dist/composables/adapters/abstract/customerAdapter.js +0 -0
- package/dist/composables/adapters/abstract/inventoryAdapter.d.ts +0 -0
- package/dist/composables/adapters/abstract/inventoryAdapter.js +0 -0
- package/dist/composables/adapters/abstract/orderAdapter.d.ts +0 -0
- package/dist/composables/adapters/abstract/orderAdapter.js +0 -0
- package/dist/composables/adapters/abstract/productAdapter.d.ts +6 -0
- package/dist/composables/adapters/abstract/productAdapter.js +1 -0
- package/dist/composables/cart/registry.d.ts +4 -0
- package/dist/composables/cart/registry.js +16 -0
- package/dist/composables/cart/types.d.ts +16 -0
- package/dist/composables/cart/types.js +1 -0
- package/dist/composables/cart/useCart.d.ts +6 -0
- package/dist/composables/cart/useCart.js +13 -0
- package/dist/composables/config.d.ts +7 -0
- package/dist/composables/config.js +11 -0
- package/dist/composables/defs/apiDefinitions.d.ts +7 -0
- package/dist/composables/defs/apiDefinitions.js +39 -0
- package/dist/composables/defs/extension.d.ts +91 -0
- package/dist/composables/defs/extension.js +154 -0
- package/dist/composables/defs/extension.mocks.d.ts +30 -0
- package/dist/composables/defs/extension.mocks.js +23 -0
- package/dist/composables/defs/extension.test.d.ts +1 -0
- package/dist/composables/defs/extension.test.js +233 -0
- package/dist/composables/defs/index.d.ts +3 -0
- package/dist/composables/defs/index.js +3 -0
- package/dist/composables/defs/types.d.ts +81 -0
- package/dist/composables/defs/types.js +1 -0
- package/dist/composables/domain/cart.d.ts +0 -0
- package/dist/composables/domain/cart.js +0 -0
- package/dist/composables/domain/category.d.ts +0 -0
- package/dist/composables/domain/category.js +0 -0
- package/dist/composables/domain/order.d.ts +0 -0
- package/dist/composables/domain/order.js +0 -0
- package/dist/composables/domain/price.d.ts +0 -0
- package/dist/composables/domain/price.js +0 -0
- package/dist/composables/domain/product.d.ts +8 -0
- package/dist/composables/domain/product.js +1 -0
- package/dist/composables/domain/reward.d.ts +0 -0
- package/dist/composables/domain/reward.js +0 -0
- package/dist/composables/domain/transactions.d.ts +0 -0
- package/dist/composables/domain/transactions.js +0 -0
- package/dist/composables/helpers/contextualizedNormalizers.d.ts +5 -0
- package/dist/composables/helpers/contextualizedNormalizers.js +6 -0
- package/dist/composables/helpers/contextualizedNormalizers.test.d.ts +1 -0
- package/dist/composables/helpers/contextualizedNormalizers.test.js +62 -0
- package/dist/composables/helpers/index.d.ts +1 -0
- package/dist/composables/helpers/index.js +1 -0
- package/dist/composables/index.d.ts +6 -0
- package/dist/composables/index.js +6 -0
- package/dist/composables/methods/auth.d.ts +62 -0
- package/dist/composables/methods/auth.js +1 -0
- package/dist/composables/methods/cart.d.ts +101 -0
- package/dist/composables/methods/cart.js +1 -0
- package/dist/composables/methods/category.d.ts +22 -0
- package/dist/composables/methods/category.js +1 -0
- package/dist/composables/methods/checkout.d.ts +42 -0
- package/dist/composables/methods/checkout.js +1 -0
- package/dist/composables/methods/customer.d.ts +39 -0
- package/dist/composables/methods/customer.js +1 -0
- package/dist/composables/methods/helpers.d.ts +2 -0
- package/dist/composables/methods/helpers.js +3 -0
- package/dist/composables/methods/index.d.ts +49 -0
- package/dist/composables/methods/index.js +9 -0
- package/dist/composables/methods/order.d.ts +29 -0
- package/dist/composables/methods/order.js +1 -0
- package/dist/composables/methods/product.d.ts +71 -0
- package/dist/composables/methods/product.js +1 -0
- package/dist/composables/methods/settings.d.ts +12 -0
- package/dist/composables/methods/settings.js +1 -0
- package/dist/composables/models/cart.d.ts +84 -0
- package/dist/composables/models/cart.js +1 -0
- package/dist/composables/models/category.d.ts +12 -0
- package/dist/composables/models/category.js +1 -0
- package/dist/composables/models/checkout.d.ts +15 -0
- package/dist/composables/models/checkout.js +1 -0
- package/dist/composables/models/customer.d.ts +14 -0
- package/dist/composables/models/customer.js +1 -0
- package/dist/composables/models/facets.d.ts +21 -0
- package/dist/composables/models/facets.js +5 -0
- package/dist/composables/models/index.d.ts +62 -0
- package/dist/composables/models/index.js +8 -0
- package/dist/composables/models/order.d.ts +39 -0
- package/dist/composables/models/order.js +1 -0
- package/dist/composables/models/product.d.ts +55 -0
- package/dist/composables/models/product.js +1 -0
- package/dist/composables/models/shared.d.ts +66 -0
- package/dist/composables/models/shared.js +1 -0
- package/dist/composables/products/registry.d.ts +4 -0
- package/dist/composables/products/registry.js +16 -0
- package/dist/composables/products/types.d.ts +12 -0
- package/dist/composables/products/types.js +1 -0
- package/dist/composables/products/useEvents.d.ts +0 -0
- package/dist/composables/products/useEvents.js +0 -0
- package/dist/composables/products/useGiftCards.d.ts +0 -0
- package/dist/composables/products/useGiftCards.js +0 -0
- package/dist/composables/products/useProducts.d.ts +4 -0
- package/dist/composables/products/useProducts.js +10 -0
- package/dist/composables/products/useSubscriptions.d.ts +0 -0
- package/dist/composables/products/useSubscriptions.js +0 -0
- package/dist/composables/registry.d.ts +9 -0
- package/dist/composables/registry.js +13 -0
- package/dist/composables/stores/cart.d.ts +1 -0
- package/dist/composables/stores/cart.js +203 -0
- package/dist/composables/stores/cartStore.d.ts +1 -0
- package/dist/composables/stores/cartStore.js +246 -0
- package/dist/composables/stores/checkout.d.ts +1 -0
- package/dist/composables/stores/checkout.js +17 -0
- package/dist/composables/stores/compare.d.ts +1 -0
- package/dist/composables/stores/compare.js +50 -0
- package/dist/composables/stores/orders.d.ts +1 -0
- package/dist/composables/stores/orders.js +156 -0
- package/dist/composables/stores/product.d.ts +1 -0
- package/dist/composables/stores/product.js +26 -0
- package/dist/composables/stores/productList.d.ts +0 -0
- package/dist/composables/stores/productList.js +0 -0
- package/dist/composables/stores/productListInfo.d.ts +0 -0
- package/dist/composables/stores/productListInfo.js +0 -0
- package/dist/composables/stores/products.d.ts +1 -0
- package/dist/composables/stores/products.js +106 -0
- package/dist/composables/stores/recentlyViewedProducts.d.ts +0 -0
- package/dist/composables/stores/recentlyViewedProducts.js +0 -0
- package/dist/composables/stores/review.d.ts +1 -0
- package/dist/composables/stores/review.js +25 -0
- package/dist/composables/stores/storeInPickUp.d.ts +1 -0
- package/dist/composables/stores/storeInPickUp.js +21 -0
- package/dist/composables/stores/user.d.ts +1 -0
- package/dist/composables/stores/user.js +16 -0
- package/dist/composables/stores/wishlist.d.ts +1 -0
- package/dist/composables/stores/wishlist.js +17 -0
- package/dist/composables/types/Order.type.d.ts +141 -0
- package/dist/composables/types/Order.type.js +1 -0
- package/dist/composables/types/index.d.ts +265 -0
- package/dist/composables/types/index.js +3 -0
- package/dist/composables/types/product.d.ts +13 -0
- package/dist/composables/types/product.js +1 -0
- package/dist/composables/useBreakpoints/index.d.ts +1 -0
- package/dist/composables/useBreakpoints/index.js +1 -0
- package/dist/composables/useBreakpoints/useBreakpoints.d.ts +10 -0
- package/dist/composables/useBreakpoints/useBreakpoints.js +24 -0
- package/dist/composables/useCart/index.d.ts +1 -0
- package/dist/composables/useCart/index.js +1 -0
- package/dist/composables/useCart/types.d.ts +13 -0
- package/dist/composables/useCart/types.js +1 -0
- package/dist/composables/useCart/useCart.d.ts +8 -0
- package/dist/composables/useCart/useCart.js +43 -0
- package/dist/composables/useCartShippingMethods/index.d.ts +1 -0
- package/dist/composables/useCartShippingMethods/index.js +1 -0
- package/dist/composables/useCartShippingMethods/types.d.ts +13 -0
- package/dist/composables/useCartShippingMethods/types.js +1 -0
- package/dist/composables/useCartShippingMethods/useCartShippingMethods.d.ts +7 -0
- package/dist/composables/useCartShippingMethods/useCartShippingMethods.js +35 -0
- package/dist/composables/useCatalog.d.ts +13 -0
- package/dist/composables/useCatalog.js +61 -0
- package/dist/composables/useContent/index.d.ts +1 -0
- package/dist/composables/useContent/index.js +1 -0
- package/dist/composables/useContent/types.d.ts +32 -0
- package/dist/composables/useContent/types.js +1 -0
- package/dist/composables/useContent/useContent.d.ts +9 -0
- package/dist/composables/useContent/useContent.js +43 -0
- package/dist/composables/useContent.d.ts +14 -0
- package/dist/composables/useContent.js +55 -0
- package/dist/composables/useCustomer/index.d.ts +2 -0
- package/dist/composables/useCustomer/index.js +2 -0
- package/dist/composables/useCustomer/types.d.ts +13 -0
- package/dist/composables/useCustomer/types.js +1 -0
- package/dist/composables/useCustomer/useCustomer.d.ts +8 -0
- package/dist/composables/useCustomer/useCustomer.js +34 -0
- package/dist/composables/useCustomerAddress/index.d.ts +2 -0
- package/dist/composables/useCustomerAddress/index.js +2 -0
- package/dist/composables/useCustomerAddress/types.d.ts +13 -0
- package/dist/composables/useCustomerAddress/types.js +1 -0
- package/dist/composables/useCustomerAddress/useCustomerAddress.d.ts +8 -0
- package/dist/composables/useCustomerAddress/useCustomerAddress.js +43 -0
- package/dist/composables/useCustomerOrder/adress.d.ts +11 -0
- package/dist/composables/useCustomerOrder/adress.js +10 -0
- package/dist/composables/useCustomerOrder/index.d.ts +2 -0
- package/dist/composables/useCustomerOrder/index.js +2 -0
- package/dist/composables/useCustomerOrder/product.d.ts +28 -0
- package/dist/composables/useCustomerOrder/product.js +37 -0
- package/dist/composables/useCustomerOrder/types.d.ts +32 -0
- package/dist/composables/useCustomerOrder/types.js +1 -0
- package/dist/composables/useCustomerOrder/useCustomerOrder.d.ts +8 -0
- package/dist/composables/useCustomerOrder/useCustomerOrder.js +52 -0
- package/dist/composables/useCustomerOrders/index.d.ts +2 -0
- package/dist/composables/useCustomerOrders/index.js +2 -0
- package/dist/composables/useCustomerOrders/types.d.ts +15 -0
- package/dist/composables/useCustomerOrders/types.js +1 -0
- package/dist/composables/useCustomerOrders/useCustomerOrders.d.ts +8 -0
- package/dist/composables/useCustomerOrders/useCustomerOrders.js +42 -0
- package/dist/composables/useCustomerReturns/index.d.ts +2 -0
- package/dist/composables/useCustomerReturns/index.js +2 -0
- package/dist/composables/useCustomerReturns/types.d.ts +13 -0
- package/dist/composables/useCustomerReturns/types.js +1 -0
- package/dist/composables/useCustomerReturns/useCustomerReturns.d.ts +8 -0
- package/dist/composables/useCustomerReturns/useCustomerReturns.js +32 -0
- package/dist/composables/useHandleError/index.d.ts +1 -0
- package/dist/composables/useHandleError/index.js +1 -0
- package/dist/composables/useHandleError/types.d.ts +7 -0
- package/dist/composables/useHandleError/types.js +1 -0
- package/dist/composables/useHandleError/useHandleError.d.ts +10 -0
- package/dist/composables/useHandleError/useHandleError.js +24 -0
- package/dist/composables/usePageTitle.d.ts +5 -0
- package/dist/composables/usePageTitle.js +14 -0
- package/dist/composables/useProduct/index.d.ts +2 -0
- package/dist/composables/useProduct/index.js +2 -0
- package/dist/composables/useProduct/types.d.ts +13 -0
- package/dist/composables/useProduct/types.js +1 -0
- package/dist/composables/useProduct/useProduct.d.ts +9 -0
- package/dist/composables/useProduct/useProduct.js +36 -0
- package/dist/composables/useProductAttribute/index.d.ts +1 -0
- package/dist/composables/useProductAttribute/index.js +1 -0
- package/dist/composables/useProductAttribute/useProductAttribute.d.ts +11 -0
- package/dist/composables/useProductAttribute/useProductAttribute.js +25 -0
- package/dist/composables/useProductRecommended/index.d.ts +1 -0
- package/dist/composables/useProductRecommended/index.js +1 -0
- package/dist/composables/useProductRecommended/types.d.ts +13 -0
- package/dist/composables/useProductRecommended/types.js +1 -0
- package/dist/composables/useProductRecommended/useProductRecommended.d.ts +6 -0
- package/dist/composables/useProductRecommended/useProductRecommended.js +33 -0
- package/dist/composables/useProductReviews/index.d.ts +2 -0
- package/dist/composables/useProductReviews/index.js +2 -0
- package/dist/composables/useProductReviews/types.d.ts +13 -0
- package/dist/composables/useProductReviews/types.js +1 -0
- package/dist/composables/useProductReviews/useProductReviews.d.ts +9 -0
- package/dist/composables/useProductReviews/useProductReviews.js +36 -0
- package/dist/composables/useProducts/types.d.ts +18 -0
- package/dist/composables/useProducts/types.js +1 -0
- package/dist/composables/useProducts/useProducts.d.ts +8 -0
- package/dist/composables/useProducts/useProducts.js +35 -0
- package/dist/composables/utils/countryList.d.ts +5 -0
- package/dist/composables/utils/countryList.js +14 -0
- package/dist/composables/utils/glossary.d.ts +0 -0
- package/dist/composables/utils/glossary.js +0 -0
- package/dist/composables/utils/importExport.d.ts +0 -0
- package/dist/composables/utils/importExport.js +0 -0
- package/dist/composables/utils/print.d.ts +0 -0
- package/dist/composables/utils/print.js +0 -0
- package/dist/composables/utils/shopThemes.d.ts +0 -0
- package/dist/composables/utils/shopThemes.js +0 -0
- package/dist/composables/utils/statistics.d.ts +0 -0
- package/dist/composables/utils/statistics.js +0 -0
- package/dist/composables/utils/stock.d.ts +0 -0
- package/dist/composables/utils/stock.js +0 -0
- package/dist/composables/utils/stripe.d.ts +7 -0
- package/dist/composables/utils/stripe.js +14 -0
- package/dist/composables/utils/taxation.d.ts +0 -0
- package/dist/composables/utils/taxation.js +0 -0
- package/dist/composables/utils/tellFriends.d.ts +0 -0
- package/dist/composables/utils/tellFriends.js +0 -0
- package/dist/composables/validationRules/index.d.ts +1 -0
- package/dist/composables/validationRules/index.js +1 -0
- package/dist/composables/validationRules/password.d.ts +1 -0
- package/dist/composables/validationRules/password.js +20 -0
- package/dist/composables/validationRules/password.test.d.ts +1 -0
- package/dist/composables/validationRules/password.test.js +68 -0
- package/dist/composables/vendors/index.d.ts +0 -0
- package/dist/composables/vendors/index.js +0 -0
- package/dist/composables/vendors/registry.d.ts +0 -0
- package/dist/composables/vendors/registry.js +0 -0
- package/dist/composables/vendors/useAffiliates.d.ts +0 -0
- package/dist/composables/vendors/useAffiliates.js +0 -0
- package/dist/composables/vendors/useCommission.d.ts +0 -0
- package/dist/composables/vendors/useCommission.js +0 -0
- package/dist/modules/vue-head/composables/useHead.d.ts +1 -0
- package/dist/modules/vue-head/composables/useHead.js +3 -0
- package/dist/utils/client.d.ts +6 -0
- package/dist/utils/client.js +23 -0
- package/dist/utils/index.d.ts +15 -0
- package/dist/utils/index.js +38 -0
- package/dist/utils/normalizer.d.ts +12 -0
- package/dist/utils/normalizer.js +13 -0
- package/dist/utils/normalizers/magento.d.ts +3 -0
- package/dist/utils/normalizers/magento.js +23 -0
- package/dist/utils/normalizers/shopify.d.ts +3 -0
- package/dist/utils/normalizers/shopify.js +24 -0
- package/global.d.ts +149 -0
- package/package.json +2 -1
- package/tsconfig.json +19 -3
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { InferCustom } from "../defs";
|
|
2
|
+
export type Maybe<TType> = TType | null;
|
|
3
|
+
export type SfId = string;
|
|
4
|
+
export interface SfMoneyCustom extends InferCustom<"normalizeMoney"> {
|
|
5
|
+
}
|
|
6
|
+
export interface SfMoney {
|
|
7
|
+
currency: string;
|
|
8
|
+
amount: number;
|
|
9
|
+
precisionAmount: string;
|
|
10
|
+
$custom?: SfMoneyCustom;
|
|
11
|
+
}
|
|
12
|
+
export interface SfDiscountablePriceCustom extends InferCustom<"normalizeDiscountablePrice"> {
|
|
13
|
+
}
|
|
14
|
+
export interface SfDiscountablePrice {
|
|
15
|
+
isDiscounted: boolean;
|
|
16
|
+
regularPrice: SfMoney;
|
|
17
|
+
/**
|
|
18
|
+
* Price with discounts. If there is no discount, it will be the same as regularPrice
|
|
19
|
+
*/
|
|
20
|
+
value: SfMoney;
|
|
21
|
+
$custom?: SfDiscountablePriceCustom;
|
|
22
|
+
}
|
|
23
|
+
export interface SfImageCustom extends InferCustom<"normalizeImage"> {
|
|
24
|
+
}
|
|
25
|
+
export interface SfImage {
|
|
26
|
+
alt: Maybe<string>;
|
|
27
|
+
url: string;
|
|
28
|
+
$custom?: SfImageCustom;
|
|
29
|
+
}
|
|
30
|
+
export interface SfAttributeCustom extends InferCustom<"normalizeAttribute"> {
|
|
31
|
+
}
|
|
32
|
+
export interface SfAttribute {
|
|
33
|
+
label: string;
|
|
34
|
+
name: string;
|
|
35
|
+
value: string;
|
|
36
|
+
valueLabel: string;
|
|
37
|
+
$custom?: SfAttributeCustom;
|
|
38
|
+
}
|
|
39
|
+
export interface SfCreateAddressBody {
|
|
40
|
+
address1: string;
|
|
41
|
+
address2?: Maybe<string>;
|
|
42
|
+
city: string;
|
|
43
|
+
country: string;
|
|
44
|
+
firstName: string;
|
|
45
|
+
lastName: string;
|
|
46
|
+
phoneNumber: string;
|
|
47
|
+
postalCode: string;
|
|
48
|
+
state: string;
|
|
49
|
+
titleCode: string;
|
|
50
|
+
}
|
|
51
|
+
export interface SfAddressCustom extends InferCustom<"normalizeAddress"> {
|
|
52
|
+
}
|
|
53
|
+
export interface SfAddress {
|
|
54
|
+
address1: Maybe<string>;
|
|
55
|
+
address2?: Maybe<string>;
|
|
56
|
+
city: Maybe<string>;
|
|
57
|
+
country: Maybe<string>;
|
|
58
|
+
firstName: Maybe<string>;
|
|
59
|
+
lastName: Maybe<string>;
|
|
60
|
+
phoneNumber: Maybe<string>;
|
|
61
|
+
postalCode: Maybe<string>;
|
|
62
|
+
state: Maybe<string>;
|
|
63
|
+
titleCode: Maybe<string>;
|
|
64
|
+
$custom?: SfAddressCustom;
|
|
65
|
+
}
|
|
66
|
+
export type SfCurrency = string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ProductProvider } from "./types";
|
|
2
|
+
export declare function registerProductProvider(name: string, provider: ProductProvider): void;
|
|
3
|
+
export declare function getProductProvider(name: string): ProductProvider;
|
|
4
|
+
export declare function registerProductProviderRuntime(name: string, provider: ProductProvider): void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const providers = {};
|
|
2
|
+
export function registerProductProvider(name, provider) {
|
|
3
|
+
providers[name] = provider;
|
|
4
|
+
}
|
|
5
|
+
export function getProductProvider(name) {
|
|
6
|
+
const provider = providers[name];
|
|
7
|
+
if (!provider)
|
|
8
|
+
throw new Error(`Product provider "${name}" not found`);
|
|
9
|
+
return provider;
|
|
10
|
+
}
|
|
11
|
+
// Runtime helper for adapter packages to register themselves when the
|
|
12
|
+
// app boots. Adapter packages can import this and call it from their
|
|
13
|
+
// plugin entry to wire into the commerce product provider registry.
|
|
14
|
+
export function registerProductProviderRuntime(name, provider) {
|
|
15
|
+
registerProductProvider(name, provider);
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface Product {
|
|
2
|
+
id: string;
|
|
3
|
+
title: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
price: number;
|
|
6
|
+
images: string[];
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}
|
|
9
|
+
export interface ProductProvider {
|
|
10
|
+
getProduct(id: string): Promise<Product>;
|
|
11
|
+
listProducts(params?: Record<string, any>): Promise<Product[]>;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getCommerceConfig } from '../config';
|
|
2
|
+
import { getProductProvider } from './registry';
|
|
3
|
+
export function useProducts() {
|
|
4
|
+
const { productProvider } = getCommerceConfig();
|
|
5
|
+
const provider = getProductProvider(productProvider);
|
|
6
|
+
return {
|
|
7
|
+
getProduct: provider.getProduct,
|
|
8
|
+
listProducts: provider.listProducts
|
|
9
|
+
};
|
|
10
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ProductProvider } from './products/types';
|
|
2
|
+
import type { CartProvider } from './cart/types';
|
|
3
|
+
export interface CommerceProviderBundle {
|
|
4
|
+
product?: ProductProvider;
|
|
5
|
+
cart?: CartProvider;
|
|
6
|
+
}
|
|
7
|
+
export declare function registerCommerceProviderRuntime(name: string, bundle: CommerceProviderBundle): void;
|
|
8
|
+
export { registerProductProviderRuntime } from './products/registry';
|
|
9
|
+
export { registerCartProviderRuntime } from './cart/registry';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { registerProductProvider } from './products/registry';
|
|
2
|
+
import { registerCartProvider } from './cart/registry';
|
|
3
|
+
// Register multiple domain providers at once from an adapter package.
|
|
4
|
+
// Example adapter entrypoint can call this during app boot.
|
|
5
|
+
export function registerCommerceProviderRuntime(name, bundle) {
|
|
6
|
+
if (bundle.product)
|
|
7
|
+
registerProductProvider(name, bundle.product);
|
|
8
|
+
if (bundle.cart)
|
|
9
|
+
registerCartProvider(name, bundle.cart);
|
|
10
|
+
}
|
|
11
|
+
// Also re-export individual runtime helpers for convenience
|
|
12
|
+
export { registerProductProviderRuntime } from './products/registry';
|
|
13
|
+
export { registerCartProviderRuntime } from './cart/registry';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useCartStore: any;
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { ref, computed, readonly } from 'vue';
|
|
2
|
+
import { useCart } from '../cart/useCart';
|
|
3
|
+
import { defineStore } from 'pinia';
|
|
4
|
+
export const useCartStore = defineStore('cart', () => {
|
|
5
|
+
const cart = ref(null);
|
|
6
|
+
const loading = ref(false);
|
|
7
|
+
const error = ref(null);
|
|
8
|
+
// Import cart composable
|
|
9
|
+
const { fetchCart, addToCart, removeFromCart, updateCartItem, applyCoupon, removeCoupon, clearCart, setShippingOption: setShippingOptionFn, createCheckoutSession: createCheckoutSessionFn } = useCart();
|
|
10
|
+
const initializeCart = async () => {
|
|
11
|
+
loading.value = true;
|
|
12
|
+
error.value = null;
|
|
13
|
+
try {
|
|
14
|
+
await fetchCart();
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
error.value = err.message;
|
|
18
|
+
console.error('Error initializing cart:', err);
|
|
19
|
+
}
|
|
20
|
+
finally {
|
|
21
|
+
loading.value = false;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const addProductToCart = async (productId, quantity = 1, variantId) => {
|
|
25
|
+
loading.value = true;
|
|
26
|
+
error.value = null;
|
|
27
|
+
try {
|
|
28
|
+
await addToCart(productId, quantity, variantId);
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
error.value = err.message;
|
|
32
|
+
console.error('Error adding product to cart:', err);
|
|
33
|
+
throw err;
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
loading.value = false;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const removeProductFromCart = async (itemId) => {
|
|
40
|
+
loading.value = true;
|
|
41
|
+
error.value = null;
|
|
42
|
+
try {
|
|
43
|
+
await removeFromCart(itemId);
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
error.value = err.message;
|
|
47
|
+
console.error('Error removing product from cart:', err);
|
|
48
|
+
throw err;
|
|
49
|
+
}
|
|
50
|
+
finally {
|
|
51
|
+
loading.value = false;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const updateProductQuantity = async (itemId, quantity) => {
|
|
55
|
+
loading.value = true;
|
|
56
|
+
error.value = null;
|
|
57
|
+
try {
|
|
58
|
+
await updateCartItem(itemId, quantity);
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
error.value = err.message;
|
|
62
|
+
console.error('Error updating cart item:', err);
|
|
63
|
+
throw err;
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
loading.value = false;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const applyCartCoupon = async (couponCode) => {
|
|
70
|
+
loading.value = true;
|
|
71
|
+
error.value = null;
|
|
72
|
+
try {
|
|
73
|
+
const success = await applyCoupon(couponCode);
|
|
74
|
+
if (!success) {
|
|
75
|
+
throw new Error('Failed to apply coupon');
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
error.value = err.message;
|
|
80
|
+
console.error('Error applying coupon:', err);
|
|
81
|
+
throw err;
|
|
82
|
+
}
|
|
83
|
+
finally {
|
|
84
|
+
loading.value = false;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const removeCartCoupon = async () => {
|
|
88
|
+
loading.value = true;
|
|
89
|
+
error.value = null;
|
|
90
|
+
try {
|
|
91
|
+
await removeCoupon();
|
|
92
|
+
}
|
|
93
|
+
catch (err) {
|
|
94
|
+
error.value = err.message;
|
|
95
|
+
console.error('Error removing coupon:', err);
|
|
96
|
+
throw err;
|
|
97
|
+
}
|
|
98
|
+
finally {
|
|
99
|
+
loading.value = false;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
const emptyCart = async () => {
|
|
103
|
+
loading.value = true;
|
|
104
|
+
error.value = null;
|
|
105
|
+
try {
|
|
106
|
+
await clearCart();
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
error.value = err.message;
|
|
110
|
+
console.error('Error clearing cart:', err);
|
|
111
|
+
throw err;
|
|
112
|
+
}
|
|
113
|
+
finally {
|
|
114
|
+
loading.value = false;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
const setShippingOption = async (option) => {
|
|
118
|
+
loading.value = true;
|
|
119
|
+
error.value = null;
|
|
120
|
+
try {
|
|
121
|
+
if (!setShippingOptionFn)
|
|
122
|
+
throw new Error('Shipping setter unavailable');
|
|
123
|
+
await setShippingOptionFn(option);
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
error.value = err.message;
|
|
127
|
+
console.error('Error setting shipping option:', err);
|
|
128
|
+
throw err;
|
|
129
|
+
}
|
|
130
|
+
finally {
|
|
131
|
+
loading.value = false;
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
const createCheckoutSession = async (cartId) => {
|
|
135
|
+
loading.value = true;
|
|
136
|
+
error.value = null;
|
|
137
|
+
try {
|
|
138
|
+
const data = await createCheckoutSessionFn(cartId);
|
|
139
|
+
return data;
|
|
140
|
+
}
|
|
141
|
+
catch (err) {
|
|
142
|
+
error.value = err.message;
|
|
143
|
+
throw err;
|
|
144
|
+
}
|
|
145
|
+
finally {
|
|
146
|
+
loading.value = false;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
// Computed properties
|
|
150
|
+
const itemCount = computed(() => {
|
|
151
|
+
return cart.value?.items?.reduce((count, item) => count + item.quantity, 0) || 0;
|
|
152
|
+
});
|
|
153
|
+
const isEmpty = computed(() => {
|
|
154
|
+
return !cart.value?.items?.length;
|
|
155
|
+
});
|
|
156
|
+
const hasItems = computed(() => {
|
|
157
|
+
return !isEmpty.value;
|
|
158
|
+
});
|
|
159
|
+
const subtotal = computed(() => {
|
|
160
|
+
return cart.value?.subtotal || 0;
|
|
161
|
+
});
|
|
162
|
+
const total = computed(() => {
|
|
163
|
+
return cart.value?.total || 0;
|
|
164
|
+
});
|
|
165
|
+
const taxAmount = computed(() => {
|
|
166
|
+
return cart.value?.tax_amount || 0;
|
|
167
|
+
});
|
|
168
|
+
const shippingAmount = computed(() => {
|
|
169
|
+
return cart.value?.shipping_amount || 0;
|
|
170
|
+
});
|
|
171
|
+
const discountAmount = computed(() => {
|
|
172
|
+
return cart.value?.discount_amount || 0;
|
|
173
|
+
});
|
|
174
|
+
const hasCoupon = computed(() => {
|
|
175
|
+
return !!cart.value?.coupon_code;
|
|
176
|
+
});
|
|
177
|
+
return {
|
|
178
|
+
// State
|
|
179
|
+
cart: readonly(cart),
|
|
180
|
+
loading: readonly(loading),
|
|
181
|
+
error: readonly(error),
|
|
182
|
+
// Computed
|
|
183
|
+
itemCount,
|
|
184
|
+
isEmpty,
|
|
185
|
+
hasItems,
|
|
186
|
+
subtotal,
|
|
187
|
+
total,
|
|
188
|
+
taxAmount,
|
|
189
|
+
shippingAmount,
|
|
190
|
+
discountAmount,
|
|
191
|
+
hasCoupon,
|
|
192
|
+
// Actions
|
|
193
|
+
initializeCart,
|
|
194
|
+
addProductToCart,
|
|
195
|
+
removeProductFromCart,
|
|
196
|
+
updateProductQuantity,
|
|
197
|
+
applyCartCoupon,
|
|
198
|
+
removeCartCoupon,
|
|
199
|
+
emptyCart,
|
|
200
|
+
setShippingOption,
|
|
201
|
+
createCheckoutSession
|
|
202
|
+
};
|
|
203
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useCartStore: any;
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
// stores/cartStore.ts
|
|
2
|
+
import { defineStore } from 'pinia';
|
|
3
|
+
import { MagentoService } from '~/services/magento';
|
|
4
|
+
export const useCartStore = defineStore('cart', {
|
|
5
|
+
state: () => ({
|
|
6
|
+
isGuest: true,
|
|
7
|
+
items: [],
|
|
8
|
+
total: 0,
|
|
9
|
+
quoteId: null,
|
|
10
|
+
magentoService: new MagentoService()
|
|
11
|
+
}),
|
|
12
|
+
actions: {
|
|
13
|
+
async initializeCart() {
|
|
14
|
+
const auth = useAuth();
|
|
15
|
+
this.isGuest = !auth.token.value;
|
|
16
|
+
try {
|
|
17
|
+
if (this.isGuest) {
|
|
18
|
+
await this.createGuestCart();
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
await this.createCustomerCart();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
errorHandler.handle(error);
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
async createGuestCart() {
|
|
29
|
+
const response = await fetch(`${process.env.MAGENTO_API_URL}/guest-carts`, {
|
|
30
|
+
method: 'POST'
|
|
31
|
+
});
|
|
32
|
+
const quoteId = await response.json();
|
|
33
|
+
this.quoteId = quoteId;
|
|
34
|
+
},
|
|
35
|
+
async createCustomerCart() {
|
|
36
|
+
const auth = useAuth();
|
|
37
|
+
const response = await fetch(`${process.env.MAGENTO_API_URL}/carts/mine`, {
|
|
38
|
+
method: 'POST',
|
|
39
|
+
headers: {
|
|
40
|
+
'Authorization': `Bearer ${auth.token.value}`
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
this.quoteId = await response.json();
|
|
44
|
+
},
|
|
45
|
+
async addItem(product) {
|
|
46
|
+
const loading = useLoading();
|
|
47
|
+
loading.startLoading('Adding to cart...');
|
|
48
|
+
try {
|
|
49
|
+
// Check authentication
|
|
50
|
+
const auth = useAuth();
|
|
51
|
+
if (auth.isTokenExpired()) {
|
|
52
|
+
await auth.refreshAccessToken();
|
|
53
|
+
}
|
|
54
|
+
// Check inventory
|
|
55
|
+
const inventory = useInventory();
|
|
56
|
+
await inventory.checkInventory(product.sku, product.qty);
|
|
57
|
+
// If no quote ID, create cart
|
|
58
|
+
if (!this.quoteId) {
|
|
59
|
+
await this.initializeCart();
|
|
60
|
+
}
|
|
61
|
+
// Ensure quoteId exists before proceeding
|
|
62
|
+
if (!this.quoteId) {
|
|
63
|
+
throw new CartError('Failed to create cart', 'CART_ERROR');
|
|
64
|
+
}
|
|
65
|
+
// Add to Magento cart
|
|
66
|
+
const response = await fetch(`${process.env.MAGENTO_API_URL}/carts/mine/items`, {
|
|
67
|
+
method: 'POST',
|
|
68
|
+
headers: {
|
|
69
|
+
'Authorization': `Bearer ${auth.token.value}`,
|
|
70
|
+
'Content-Type': 'application/json'
|
|
71
|
+
},
|
|
72
|
+
body: JSON.stringify({
|
|
73
|
+
cartItem: {
|
|
74
|
+
sku: product.sku,
|
|
75
|
+
qty: product.qty,
|
|
76
|
+
quote_id: this.quoteId
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
});
|
|
80
|
+
if (!response.ok) {
|
|
81
|
+
throw new CartError('Failed to add item to cart', 'CART_ERROR');
|
|
82
|
+
}
|
|
83
|
+
const cartItem = await response.json();
|
|
84
|
+
// Update local cart state
|
|
85
|
+
const existingItem = this.items.find(item => item.sku === product.sku);
|
|
86
|
+
if (existingItem) {
|
|
87
|
+
existingItem.qty += product.qty;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
this.items.push({
|
|
91
|
+
...product,
|
|
92
|
+
item_id: cartItem.item_id
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
// Calculate taxes
|
|
96
|
+
const tax = useTax();
|
|
97
|
+
if (this.quoteId) {
|
|
98
|
+
await tax.calculateTax(this.quoteId);
|
|
99
|
+
}
|
|
100
|
+
// Cache product data
|
|
101
|
+
const cache = useCache();
|
|
102
|
+
cache.setCacheItem(`cart_product_${product.sku}`, product);
|
|
103
|
+
await this.calculateTotal();
|
|
104
|
+
loading.stopLoading();
|
|
105
|
+
const { show } = useNotification();
|
|
106
|
+
show({
|
|
107
|
+
type: 'success',
|
|
108
|
+
message: 'Product added to cart'
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
loading.stopLoading();
|
|
113
|
+
errorHandler.handle(error);
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
async removeItem(itemId) {
|
|
117
|
+
const loading = useLoading();
|
|
118
|
+
loading.startLoading('Removing item...');
|
|
119
|
+
try {
|
|
120
|
+
const auth = useAuth();
|
|
121
|
+
if (auth.isTokenExpired()) {
|
|
122
|
+
await auth.refreshAccessToken();
|
|
123
|
+
}
|
|
124
|
+
// Remove from Magento cart
|
|
125
|
+
const response = await fetch(`${process.env.MAGENTO_API_URL}/carts/mine/items/${itemId}`, {
|
|
126
|
+
method: 'DELETE',
|
|
127
|
+
headers: {
|
|
128
|
+
'Authorization': `Bearer ${auth.token.value}`
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
if (!response.ok) {
|
|
132
|
+
throw new CartError('Failed to remove item from cart', 'CART_ERROR');
|
|
133
|
+
}
|
|
134
|
+
// Update local cart state
|
|
135
|
+
this.items = this.items.filter(item => item.item_id !== itemId);
|
|
136
|
+
await this.calculateTotal();
|
|
137
|
+
loading.stopLoading();
|
|
138
|
+
useNotification().show({
|
|
139
|
+
type: 'success',
|
|
140
|
+
message: 'Item removed from cart'
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
loading.stopLoading();
|
|
145
|
+
errorHandler.handle(error);
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
async calculateTotal() {
|
|
149
|
+
try {
|
|
150
|
+
const auth = useAuth();
|
|
151
|
+
if (!this.quoteId)
|
|
152
|
+
return;
|
|
153
|
+
// Get cart totals from Magento
|
|
154
|
+
const response = await fetch(`${process.env.MAGENTO_API_URL}/carts/mine/totals`, {
|
|
155
|
+
headers: {
|
|
156
|
+
'Authorization': `Bearer ${auth.token.value}`
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
if (!response.ok) {
|
|
160
|
+
throw new CartError('Failed to get cart totals', 'CART_ERROR');
|
|
161
|
+
}
|
|
162
|
+
const totals = await response.json();
|
|
163
|
+
this.total = totals.grand_total;
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
console.error('Error calculating totals:', error);
|
|
167
|
+
errorHandler.handle(error);
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
// Update other methods to use the notification composable
|
|
171
|
+
async clearCart() {
|
|
172
|
+
const loading = useLoading();
|
|
173
|
+
loading.startLoading('Clearing cart...');
|
|
174
|
+
try {
|
|
175
|
+
const auth = useAuth();
|
|
176
|
+
if (this.quoteId) {
|
|
177
|
+
const response = await fetch(`${process.env.MAGENTO_API_URL}/carts/mine/clear`, {
|
|
178
|
+
method: 'POST',
|
|
179
|
+
headers: {
|
|
180
|
+
'Authorization': `Bearer ${auth.token.value}`
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
if (!response.ok) {
|
|
184
|
+
throw new CartError('Failed to clear cart', 'CART_ERROR');
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
this.items = [];
|
|
188
|
+
this.total = 0;
|
|
189
|
+
this.quoteId = null;
|
|
190
|
+
// Clear cart-related cache
|
|
191
|
+
const cache = useCache();
|
|
192
|
+
this.items.forEach(item => {
|
|
193
|
+
cache.setCacheItem(`cart_product_${item.sku}`, null);
|
|
194
|
+
});
|
|
195
|
+
loading.stopLoading();
|
|
196
|
+
const { show } = useNotification();
|
|
197
|
+
show({
|
|
198
|
+
type: 'success',
|
|
199
|
+
message: 'Cart cleared successfully'
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
loading.stopLoading();
|
|
204
|
+
errorHandler.handle(error);
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
async syncCartWithMagento() {
|
|
208
|
+
try {
|
|
209
|
+
const auth = useAuth();
|
|
210
|
+
const response = await fetch(`${process.env.MAGENTO_API_URL}/carts/mine/items`, {
|
|
211
|
+
headers: {
|
|
212
|
+
'Authorization': `Bearer ${auth.token.value}`
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
if (!response.ok) {
|
|
216
|
+
throw new CartError('Failed to sync cart', 'CART_ERROR');
|
|
217
|
+
}
|
|
218
|
+
const magentoItems = await response.json();
|
|
219
|
+
this.items = magentoItems;
|
|
220
|
+
await this.calculateTotal();
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
errorHandler.handle(error);
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
async validateCart() {
|
|
227
|
+
try {
|
|
228
|
+
// Check all items inventory
|
|
229
|
+
for (const item of this.items) {
|
|
230
|
+
const inventory = useInventory();
|
|
231
|
+
const isAvailable = await inventory.checkInventory(item.sku, item.qty);
|
|
232
|
+
if (!isAvailable) {
|
|
233
|
+
throw new CartError(`${item.name} is out of stock`, 'INVENTORY_ERROR');
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
// Validate prices
|
|
237
|
+
await this.syncCartWithMagento();
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
catch (error) {
|
|
241
|
+
errorHandler.handle(error);
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useCheckoutStore: any;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineStore } from 'pinia';
|
|
2
|
+
export const useCheckoutStore = defineStore('checkout', {
|
|
3
|
+
state: () => ({
|
|
4
|
+
shippingAddress: null,
|
|
5
|
+
paymentMethod: null,
|
|
6
|
+
orderId: '',
|
|
7
|
+
isLoading: false
|
|
8
|
+
}),
|
|
9
|
+
actions: {
|
|
10
|
+
setShippingAddress(address) {
|
|
11
|
+
this.shippingAddress = address;
|
|
12
|
+
},
|
|
13
|
+
setPaymentMethod(method) {
|
|
14
|
+
this.paymentMethod = method;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useCompareStore: any;
|