@shopware/composables 1.8.1 → 1.9.0

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 CHANGED
@@ -165,9 +165,15 @@ All composable functions are fully typed with TypeScript and they are registed g
165
165
 
166
166
  Full changelog for stable version is available [here](https://github.com/shopware/frontends/blob/main/packages/composables/CHANGELOG.md)
167
167
 
168
- ### Latest changes: 1.8.1
168
+ ### Latest changes: 1.9.0
169
+
170
+ ### Minor Changes
171
+
172
+ - [#1812](https://github.com/shopware/frontends/pull/1812) [`c28810d`](https://github.com/shopware/frontends/commit/c28810d0ca503b97c232438e200bbf5ba5dab403) Thanks [@patzick](https://github.com/patzick)! - `useShopwareContext` - added `browserLocale` field. With nuxt-module it's automatically injected into context. Should be used for proper date formatting.
173
+
174
+ - [#1737](https://github.com/shopware/frontends/pull/1737) [`bd70905`](https://github.com/shopware/frontends/commit/bd70905b8443fd57d8d8cb3cfc6501a9117dea49) Thanks [@mdanilowicz](https://github.com/mdanilowicz)! - Set `setDefaultPaymentMethod` as a deprecated method from `useUser` composable. The API endpoint is removed in the 6.7 version. The default payment method is now set on the checkout process
169
175
 
170
176
  ### Patch Changes
171
177
 
172
- - Updated dependencies [[`7324620`](https://github.com/shopware/frontends/commit/7324620a3f39c1b62f7cc294192a3e8b8b336d09)]:
173
- - @shopware/api-client@1.2.1
178
+ - Updated dependencies [[`d016d6b`](https://github.com/shopware/frontends/commit/d016d6b845bff9a148405a74dae88d7fc81ec99c), [`a7ff606`](https://github.com/shopware/frontends/commit/a7ff60681d1a164d5c9f2020c506262e96fad5dc), [`d016d6b`](https://github.com/shopware/frontends/commit/d016d6b845bff9a148405a74dae88d7fc81ec99c)]:
179
+ - @shopware/api-client@1.3.0
package/dist/index.d.mts CHANGED
@@ -51,6 +51,7 @@ type CmsBlockGalleryBuybox = BlockType<TWO_COLUMNS>;
51
51
  type CmsBlockProductDescriptionReviews = BlockType<"content">;
52
52
  type CmsBlockCrossSelling = BlockType<"content">;
53
53
  type CmsBlockForm = BlockType<"content">;
54
+ type CmsBlockHtml = BlockType<"content">;
54
55
 
55
56
  type SourceType = "static" | "mapped";
56
57
  type Position = "left" | "center" | "right";
@@ -84,6 +85,13 @@ type CmsElementText = Schemas["CmsSlot"] & {
84
85
  config: TextElementConfig;
85
86
  };
86
87
  };
88
+ type CmsElementHtml = Schemas["CmsSlot"] & {
89
+ type: "html";
90
+ data: {
91
+ content: string;
92
+ apiAlias: "cms_html";
93
+ };
94
+ };
87
95
  type ImageElementConfig = {
88
96
  url: ElementConfig<string>;
89
97
  media: ElementConfig<string>;
@@ -410,6 +418,7 @@ declare function useCmsElementConfig<T extends Schemas["CmsSlot"] & {
410
418
  declare function createShopwareContext(app: App, options: {
411
419
  devStorefrontUrl?: string | null;
412
420
  enableDevtools?: boolean;
421
+ browserLocale?: string;
413
422
  }): vue.Raw<{
414
423
  install(app: App): void;
415
424
  _a: App<any>;
@@ -418,6 +427,7 @@ declare function createShopwareContext(app: App, options: {
418
427
  state: {
419
428
  interceptors: {};
420
429
  } | undefined;
430
+ browserLocale: string;
421
431
  }>;
422
432
 
423
433
  type UseAddressReturn = {
@@ -1579,13 +1589,17 @@ type UsePriceReturn = {
1579
1589
  * Update configuration
1580
1590
  */
1581
1591
  update(params: {
1582
- localeCode: string | undefined;
1592
+ localeCode?: string | undefined;
1583
1593
  currencyCode: string;
1584
1594
  }): void;
1585
1595
  /**
1586
1596
  * Currency code
1587
1597
  */
1588
1598
  currencyCode: ComputedRef<string>;
1599
+ /**
1600
+ * Currency locale
1601
+ */
1602
+ currencyLocale: ComputedRef<string>;
1589
1603
  };
1590
1604
  /**
1591
1605
  * Composable for getting formatted price
@@ -1595,7 +1609,7 @@ type UsePriceReturn = {
1595
1609
  * @category Product
1596
1610
  */
1597
1611
  declare function _usePrice(params?: {
1598
- localeCode: string | undefined;
1612
+ localeCode?: string | undefined;
1599
1613
  currencyCode: string;
1600
1614
  }): UsePriceReturn;
1601
1615
  /**
@@ -1957,6 +1971,11 @@ type ShopwareContext = {
1957
1971
  * Shopware API client
1958
1972
  */
1959
1973
  apiClient: ApiClient;
1974
+ /**
1975
+ * Browser locale, working in SSR
1976
+ * If not provided, it will be "en-US"
1977
+ */
1978
+ browserLocale: string;
1960
1979
  };
1961
1980
  /**
1962
1981
  * @public
@@ -2084,6 +2103,8 @@ type UseUserReturn = {
2084
2103
  */
2085
2104
  updateEmail(updateEmailData: operations["changeEmail post /account/change-email"]["body"]): Promise<void>;
2086
2105
  /**
2106
+ * @deprecated API endpoint is removed in Shopware 6.7
2107
+ *
2087
2108
  * Sets the default payment method for given id
2088
2109
  * @param paymentMethodId
2089
2110
  * @returns
@@ -2236,4 +2257,4 @@ declare function getDefaultApiParams(): {
2236
2257
  [composableName: string]: unknown;
2237
2258
  };
2238
2259
 
2239
- export { type BoxLayout, type Breadcrumb, type ChangePaymentShippingMethodParams, type CmsBlockCategoryNavigation, type CmsBlockCenterText, type CmsBlockCrossSelling, type CmsBlockForm, type CmsBlockGalleryBuybox, type CmsBlockImage, type CmsBlockImageBubbleRow, type CmsBlockImageCover, type CmsBlockImageFourColumn, type CmsBlockImageGallery, type CmsBlockImageHighlightRow, type CmsBlockImageSimpleGrid, type CmsBlockImageSlider, type CmsBlockImageText, type CmsBlockImageTextBubble, type CmsBlockImageTextCover, type CmsBlockImageTextGallery, type CmsBlockImageTextRow, type CmsBlockImageThreeColumn, type CmsBlockImageThreeCover, type CmsBlockImageTwoColumn, type CmsBlockProductDescriptionReviews, type CmsBlockProductHeading, type CmsBlockProductListing, type CmsBlockProductSlider, type CmsBlockProductThreeColumn, type CmsBlockSidebarFilter, type CmsBlockText, type CmsBlockTextHero, type CmsBlockTextOnImage, type CmsBlockTextTeaser, type CmsBlockTextTeaserSection, type CmsBlockTextThreeColumn, type CmsBlockTextTwoColumn, type CmsBlockVimeoVideo, type CmsBlockYoutubeVideo, type CmsElementBuyBox, type CmsElementCategoryNavigation, type CmsElementCrossSelling, type CmsElementForm, type CmsElementImage, type CmsElementImageGallery, type CmsElementImageSlider, type CmsElementManufacturerLogo, type CmsElementProductBox, type CmsElementProductDescriptionReviews, type CmsElementProductListing, type CmsElementProductName, type CmsElementProductSlider, type CmsElementSidebarFilter, type CmsElementText, type CmsElementVimeoVideo, type CmsElementYoutubeVideo, type CmsSectionBlock, type CmsSectionDefault, type CmsSectionSidebar, type DisplayMode, type ElementConfig, type ErrorObjectParam, type ImageContainerAttrs, type ListingType, type Notification, type NotificationOptions, type Position, type RouteObject, type ShopwareContext, type ShortcutFilterParam, type SliderElementConfig, type SourceType, type UseAddToCartReturn, type UseAddressReturn, type UseBreadcrumbsReturn, type UseCartErrorParamsResolver, type UseCartItemReturn, type UseCartReturn, type UseCategoryReturn, type UseCategorySearchReturn, type UseCheckoutReturn, type UseCmsBlockReturn, type UseCmsElementImage, type UseCmsMetaReturn, type UseCountriesReturn, type UseCustomerOrdersReturn, type UseCustomerPasswordReturn, type UseDefaultOrderAssociationsReturn, type UseInternationalizationReturn, type UseLandingSearchReturn, type UseListingReturn, type UseLocalWishlistReturn, type UseNavigationContextReturn, type UseNavigationReturn, type UseNavigationSearchReturn, type UseNewsletterReturn, type UseNotificationsReturn, type UseOrderDetailsReturn, type UseOrderPaymentReturn, type UsePriceReturn, type UseProductAssociationsReturn, type UseProductConfiguratorReturn, type UseProductPriceReturn, type UseProductReturn, type UseProductReviewsReturn, type UseProductSearchReturn, type UseProductSearchSuggestReturn, type UseProductWishlistReturn, type UseSalutationsReturn, type UseSessionContextReturn, type UseSyncWishlistReturn, type UseUserReturn, type UseWishlistReturn, type VerticalAlign, createCategoryListingContext, createListingComposable, createShopwareContext, getDefaultApiParams, resolveCmsComponent, useAddToCart, useAddress, useB2bQuoteManagement, useBreadcrumbs, useCart, useCartErrorParamsResolver, useCartFunction, useCartItem, useCartNotification, type useCartNotificationReturn, useCategory, useCategoryListing, useCategorySearch, useCheckout, useCmsBlock, useCmsElementConfig, useCmsElementImage, useCmsMeta, useCmsSection, useCmsTranslations, useContext, useCountries, useCustomerOrders, useCustomerPassword, useDefaultOrderAssociations, useInternationalization, useLandingSearch, useListing, useLocalWishlist, useNavigation, useNavigationContext, useNavigationSearch, useNewsletter, useNotifications, useOrderDetails, useOrderPayment, usePrice, useProduct, useProductAssociations, useProductConfigurator, useProductPrice, useProductReviews, useProductSearch, useProductSearchListing, useProductSearchSuggest, useProductWishlist, useSalutations, useSessionContext, useShopwareContext, useSyncWishlist, useUrlResolver, useUser, useWishlist };
2260
+ export { type BoxLayout, type Breadcrumb, type ChangePaymentShippingMethodParams, type CmsBlockCategoryNavigation, type CmsBlockCenterText, type CmsBlockCrossSelling, type CmsBlockForm, type CmsBlockGalleryBuybox, type CmsBlockHtml, type CmsBlockImage, type CmsBlockImageBubbleRow, type CmsBlockImageCover, type CmsBlockImageFourColumn, type CmsBlockImageGallery, type CmsBlockImageHighlightRow, type CmsBlockImageSimpleGrid, type CmsBlockImageSlider, type CmsBlockImageText, type CmsBlockImageTextBubble, type CmsBlockImageTextCover, type CmsBlockImageTextGallery, type CmsBlockImageTextRow, type CmsBlockImageThreeColumn, type CmsBlockImageThreeCover, type CmsBlockImageTwoColumn, type CmsBlockProductDescriptionReviews, type CmsBlockProductHeading, type CmsBlockProductListing, type CmsBlockProductSlider, type CmsBlockProductThreeColumn, type CmsBlockSidebarFilter, type CmsBlockText, type CmsBlockTextHero, type CmsBlockTextOnImage, type CmsBlockTextTeaser, type CmsBlockTextTeaserSection, type CmsBlockTextThreeColumn, type CmsBlockTextTwoColumn, type CmsBlockVimeoVideo, type CmsBlockYoutubeVideo, type CmsElementBuyBox, type CmsElementCategoryNavigation, type CmsElementCrossSelling, type CmsElementForm, type CmsElementHtml, type CmsElementImage, type CmsElementImageGallery, type CmsElementImageSlider, type CmsElementManufacturerLogo, type CmsElementProductBox, type CmsElementProductDescriptionReviews, type CmsElementProductListing, type CmsElementProductName, type CmsElementProductSlider, type CmsElementSidebarFilter, type CmsElementText, type CmsElementVimeoVideo, type CmsElementYoutubeVideo, type CmsSectionBlock, type CmsSectionDefault, type CmsSectionSidebar, type DisplayMode, type ElementConfig, type ErrorObjectParam, type ImageContainerAttrs, type ListingType, type Notification, type NotificationOptions, type Position, type RouteObject, type ShopwareContext, type ShortcutFilterParam, type SliderElementConfig, type SourceType, type UseAddToCartReturn, type UseAddressReturn, type UseBreadcrumbsReturn, type UseCartErrorParamsResolver, type UseCartItemReturn, type UseCartReturn, type UseCategoryReturn, type UseCategorySearchReturn, type UseCheckoutReturn, type UseCmsBlockReturn, type UseCmsElementImage, type UseCmsMetaReturn, type UseCountriesReturn, type UseCustomerOrdersReturn, type UseCustomerPasswordReturn, type UseDefaultOrderAssociationsReturn, type UseInternationalizationReturn, type UseLandingSearchReturn, type UseListingReturn, type UseLocalWishlistReturn, type UseNavigationContextReturn, type UseNavigationReturn, type UseNavigationSearchReturn, type UseNewsletterReturn, type UseNotificationsReturn, type UseOrderDetailsReturn, type UseOrderPaymentReturn, type UsePriceReturn, type UseProductAssociationsReturn, type UseProductConfiguratorReturn, type UseProductPriceReturn, type UseProductReturn, type UseProductReviewsReturn, type UseProductSearchReturn, type UseProductSearchSuggestReturn, type UseProductWishlistReturn, type UseSalutationsReturn, type UseSessionContextReturn, type UseSyncWishlistReturn, type UseUserReturn, type UseWishlistReturn, type VerticalAlign, createCategoryListingContext, createListingComposable, createShopwareContext, getDefaultApiParams, resolveCmsComponent, useAddToCart, useAddress, useB2bQuoteManagement, useBreadcrumbs, useCart, useCartErrorParamsResolver, useCartFunction, useCartItem, useCartNotification, type useCartNotificationReturn, useCategory, useCategoryListing, useCategorySearch, useCheckout, useCmsBlock, useCmsElementConfig, useCmsElementImage, useCmsMeta, useCmsSection, useCmsTranslations, useContext, useCountries, useCustomerOrders, useCustomerPassword, useDefaultOrderAssociations, useInternationalization, useLandingSearch, useListing, useLocalWishlist, useNavigation, useNavigationContext, useNavigationSearch, useNewsletter, useNotifications, useOrderDetails, useOrderPayment, usePrice, useProduct, useProductAssociations, useProductConfigurator, useProductPrice, useProductReviews, useProductSearch, useProductSearchListing, useProductSearchSuggest, useProductWishlist, useSalutations, useSessionContext, useShopwareContext, useSyncWishlist, useUrlResolver, useUser, useWishlist };
package/dist/index.d.ts CHANGED
@@ -51,6 +51,7 @@ type CmsBlockGalleryBuybox = BlockType<TWO_COLUMNS>;
51
51
  type CmsBlockProductDescriptionReviews = BlockType<"content">;
52
52
  type CmsBlockCrossSelling = BlockType<"content">;
53
53
  type CmsBlockForm = BlockType<"content">;
54
+ type CmsBlockHtml = BlockType<"content">;
54
55
 
55
56
  type SourceType = "static" | "mapped";
56
57
  type Position = "left" | "center" | "right";
@@ -84,6 +85,13 @@ type CmsElementText = Schemas["CmsSlot"] & {
84
85
  config: TextElementConfig;
85
86
  };
86
87
  };
88
+ type CmsElementHtml = Schemas["CmsSlot"] & {
89
+ type: "html";
90
+ data: {
91
+ content: string;
92
+ apiAlias: "cms_html";
93
+ };
94
+ };
87
95
  type ImageElementConfig = {
88
96
  url: ElementConfig<string>;
89
97
  media: ElementConfig<string>;
@@ -410,6 +418,7 @@ declare function useCmsElementConfig<T extends Schemas["CmsSlot"] & {
410
418
  declare function createShopwareContext(app: App, options: {
411
419
  devStorefrontUrl?: string | null;
412
420
  enableDevtools?: boolean;
421
+ browserLocale?: string;
413
422
  }): vue.Raw<{
414
423
  install(app: App): void;
415
424
  _a: App<any>;
@@ -418,6 +427,7 @@ declare function createShopwareContext(app: App, options: {
418
427
  state: {
419
428
  interceptors: {};
420
429
  } | undefined;
430
+ browserLocale: string;
421
431
  }>;
422
432
 
423
433
  type UseAddressReturn = {
@@ -1579,13 +1589,17 @@ type UsePriceReturn = {
1579
1589
  * Update configuration
1580
1590
  */
1581
1591
  update(params: {
1582
- localeCode: string | undefined;
1592
+ localeCode?: string | undefined;
1583
1593
  currencyCode: string;
1584
1594
  }): void;
1585
1595
  /**
1586
1596
  * Currency code
1587
1597
  */
1588
1598
  currencyCode: ComputedRef<string>;
1599
+ /**
1600
+ * Currency locale
1601
+ */
1602
+ currencyLocale: ComputedRef<string>;
1589
1603
  };
1590
1604
  /**
1591
1605
  * Composable for getting formatted price
@@ -1595,7 +1609,7 @@ type UsePriceReturn = {
1595
1609
  * @category Product
1596
1610
  */
1597
1611
  declare function _usePrice(params?: {
1598
- localeCode: string | undefined;
1612
+ localeCode?: string | undefined;
1599
1613
  currencyCode: string;
1600
1614
  }): UsePriceReturn;
1601
1615
  /**
@@ -1957,6 +1971,11 @@ type ShopwareContext = {
1957
1971
  * Shopware API client
1958
1972
  */
1959
1973
  apiClient: ApiClient;
1974
+ /**
1975
+ * Browser locale, working in SSR
1976
+ * If not provided, it will be "en-US"
1977
+ */
1978
+ browserLocale: string;
1960
1979
  };
1961
1980
  /**
1962
1981
  * @public
@@ -2084,6 +2103,8 @@ type UseUserReturn = {
2084
2103
  */
2085
2104
  updateEmail(updateEmailData: operations["changeEmail post /account/change-email"]["body"]): Promise<void>;
2086
2105
  /**
2106
+ * @deprecated API endpoint is removed in Shopware 6.7
2107
+ *
2087
2108
  * Sets the default payment method for given id
2088
2109
  * @param paymentMethodId
2089
2110
  * @returns
@@ -2236,4 +2257,4 @@ declare function getDefaultApiParams(): {
2236
2257
  [composableName: string]: unknown;
2237
2258
  };
2238
2259
 
2239
- export { type BoxLayout, type Breadcrumb, type ChangePaymentShippingMethodParams, type CmsBlockCategoryNavigation, type CmsBlockCenterText, type CmsBlockCrossSelling, type CmsBlockForm, type CmsBlockGalleryBuybox, type CmsBlockImage, type CmsBlockImageBubbleRow, type CmsBlockImageCover, type CmsBlockImageFourColumn, type CmsBlockImageGallery, type CmsBlockImageHighlightRow, type CmsBlockImageSimpleGrid, type CmsBlockImageSlider, type CmsBlockImageText, type CmsBlockImageTextBubble, type CmsBlockImageTextCover, type CmsBlockImageTextGallery, type CmsBlockImageTextRow, type CmsBlockImageThreeColumn, type CmsBlockImageThreeCover, type CmsBlockImageTwoColumn, type CmsBlockProductDescriptionReviews, type CmsBlockProductHeading, type CmsBlockProductListing, type CmsBlockProductSlider, type CmsBlockProductThreeColumn, type CmsBlockSidebarFilter, type CmsBlockText, type CmsBlockTextHero, type CmsBlockTextOnImage, type CmsBlockTextTeaser, type CmsBlockTextTeaserSection, type CmsBlockTextThreeColumn, type CmsBlockTextTwoColumn, type CmsBlockVimeoVideo, type CmsBlockYoutubeVideo, type CmsElementBuyBox, type CmsElementCategoryNavigation, type CmsElementCrossSelling, type CmsElementForm, type CmsElementImage, type CmsElementImageGallery, type CmsElementImageSlider, type CmsElementManufacturerLogo, type CmsElementProductBox, type CmsElementProductDescriptionReviews, type CmsElementProductListing, type CmsElementProductName, type CmsElementProductSlider, type CmsElementSidebarFilter, type CmsElementText, type CmsElementVimeoVideo, type CmsElementYoutubeVideo, type CmsSectionBlock, type CmsSectionDefault, type CmsSectionSidebar, type DisplayMode, type ElementConfig, type ErrorObjectParam, type ImageContainerAttrs, type ListingType, type Notification, type NotificationOptions, type Position, type RouteObject, type ShopwareContext, type ShortcutFilterParam, type SliderElementConfig, type SourceType, type UseAddToCartReturn, type UseAddressReturn, type UseBreadcrumbsReturn, type UseCartErrorParamsResolver, type UseCartItemReturn, type UseCartReturn, type UseCategoryReturn, type UseCategorySearchReturn, type UseCheckoutReturn, type UseCmsBlockReturn, type UseCmsElementImage, type UseCmsMetaReturn, type UseCountriesReturn, type UseCustomerOrdersReturn, type UseCustomerPasswordReturn, type UseDefaultOrderAssociationsReturn, type UseInternationalizationReturn, type UseLandingSearchReturn, type UseListingReturn, type UseLocalWishlistReturn, type UseNavigationContextReturn, type UseNavigationReturn, type UseNavigationSearchReturn, type UseNewsletterReturn, type UseNotificationsReturn, type UseOrderDetailsReturn, type UseOrderPaymentReturn, type UsePriceReturn, type UseProductAssociationsReturn, type UseProductConfiguratorReturn, type UseProductPriceReturn, type UseProductReturn, type UseProductReviewsReturn, type UseProductSearchReturn, type UseProductSearchSuggestReturn, type UseProductWishlistReturn, type UseSalutationsReturn, type UseSessionContextReturn, type UseSyncWishlistReturn, type UseUserReturn, type UseWishlistReturn, type VerticalAlign, createCategoryListingContext, createListingComposable, createShopwareContext, getDefaultApiParams, resolveCmsComponent, useAddToCart, useAddress, useB2bQuoteManagement, useBreadcrumbs, useCart, useCartErrorParamsResolver, useCartFunction, useCartItem, useCartNotification, type useCartNotificationReturn, useCategory, useCategoryListing, useCategorySearch, useCheckout, useCmsBlock, useCmsElementConfig, useCmsElementImage, useCmsMeta, useCmsSection, useCmsTranslations, useContext, useCountries, useCustomerOrders, useCustomerPassword, useDefaultOrderAssociations, useInternationalization, useLandingSearch, useListing, useLocalWishlist, useNavigation, useNavigationContext, useNavigationSearch, useNewsletter, useNotifications, useOrderDetails, useOrderPayment, usePrice, useProduct, useProductAssociations, useProductConfigurator, useProductPrice, useProductReviews, useProductSearch, useProductSearchListing, useProductSearchSuggest, useProductWishlist, useSalutations, useSessionContext, useShopwareContext, useSyncWishlist, useUrlResolver, useUser, useWishlist };
2260
+ export { type BoxLayout, type Breadcrumb, type ChangePaymentShippingMethodParams, type CmsBlockCategoryNavigation, type CmsBlockCenterText, type CmsBlockCrossSelling, type CmsBlockForm, type CmsBlockGalleryBuybox, type CmsBlockHtml, type CmsBlockImage, type CmsBlockImageBubbleRow, type CmsBlockImageCover, type CmsBlockImageFourColumn, type CmsBlockImageGallery, type CmsBlockImageHighlightRow, type CmsBlockImageSimpleGrid, type CmsBlockImageSlider, type CmsBlockImageText, type CmsBlockImageTextBubble, type CmsBlockImageTextCover, type CmsBlockImageTextGallery, type CmsBlockImageTextRow, type CmsBlockImageThreeColumn, type CmsBlockImageThreeCover, type CmsBlockImageTwoColumn, type CmsBlockProductDescriptionReviews, type CmsBlockProductHeading, type CmsBlockProductListing, type CmsBlockProductSlider, type CmsBlockProductThreeColumn, type CmsBlockSidebarFilter, type CmsBlockText, type CmsBlockTextHero, type CmsBlockTextOnImage, type CmsBlockTextTeaser, type CmsBlockTextTeaserSection, type CmsBlockTextThreeColumn, type CmsBlockTextTwoColumn, type CmsBlockVimeoVideo, type CmsBlockYoutubeVideo, type CmsElementBuyBox, type CmsElementCategoryNavigation, type CmsElementCrossSelling, type CmsElementForm, type CmsElementHtml, type CmsElementImage, type CmsElementImageGallery, type CmsElementImageSlider, type CmsElementManufacturerLogo, type CmsElementProductBox, type CmsElementProductDescriptionReviews, type CmsElementProductListing, type CmsElementProductName, type CmsElementProductSlider, type CmsElementSidebarFilter, type CmsElementText, type CmsElementVimeoVideo, type CmsElementYoutubeVideo, type CmsSectionBlock, type CmsSectionDefault, type CmsSectionSidebar, type DisplayMode, type ElementConfig, type ErrorObjectParam, type ImageContainerAttrs, type ListingType, type Notification, type NotificationOptions, type Position, type RouteObject, type ShopwareContext, type ShortcutFilterParam, type SliderElementConfig, type SourceType, type UseAddToCartReturn, type UseAddressReturn, type UseBreadcrumbsReturn, type UseCartErrorParamsResolver, type UseCartItemReturn, type UseCartReturn, type UseCategoryReturn, type UseCategorySearchReturn, type UseCheckoutReturn, type UseCmsBlockReturn, type UseCmsElementImage, type UseCmsMetaReturn, type UseCountriesReturn, type UseCustomerOrdersReturn, type UseCustomerPasswordReturn, type UseDefaultOrderAssociationsReturn, type UseInternationalizationReturn, type UseLandingSearchReturn, type UseListingReturn, type UseLocalWishlistReturn, type UseNavigationContextReturn, type UseNavigationReturn, type UseNavigationSearchReturn, type UseNewsletterReturn, type UseNotificationsReturn, type UseOrderDetailsReturn, type UseOrderPaymentReturn, type UsePriceReturn, type UseProductAssociationsReturn, type UseProductConfiguratorReturn, type UseProductPriceReturn, type UseProductReturn, type UseProductReviewsReturn, type UseProductSearchReturn, type UseProductSearchSuggestReturn, type UseProductWishlistReturn, type UseSalutationsReturn, type UseSessionContextReturn, type UseSyncWishlistReturn, type UseUserReturn, type UseWishlistReturn, type VerticalAlign, createCategoryListingContext, createListingComposable, createShopwareContext, getDefaultApiParams, resolveCmsComponent, useAddToCart, useAddress, useB2bQuoteManagement, useBreadcrumbs, useCart, useCartErrorParamsResolver, useCartFunction, useCartItem, useCartNotification, type useCartNotificationReturn, useCategory, useCategoryListing, useCategorySearch, useCheckout, useCmsBlock, useCmsElementConfig, useCmsElementImage, useCmsMeta, useCmsSection, useCmsTranslations, useContext, useCountries, useCustomerOrders, useCustomerPassword, useDefaultOrderAssociations, useInternationalization, useLandingSearch, useListing, useLocalWishlist, useNavigation, useNavigationContext, useNavigationSearch, useNewsletter, useNotifications, useOrderDetails, useOrderPayment, usePrice, useProduct, useProductAssociations, useProductConfigurator, useProductPrice, useProductReviews, useProductSearch, useProductSearchListing, useProductSearchSuggest, useProductWishlist, useSalutations, useSessionContext, useShopwareContext, useSyncWishlist, useUrlResolver, useUser, useWishlist };
package/dist/index.mjs CHANGED
@@ -82,7 +82,8 @@ function createShopwareContext(app, options) {
82
82
  _a: app,
83
83
  _e: scope,
84
84
  devStorefrontUrl: options.devStorefrontUrl,
85
- state
85
+ state,
86
+ browserLocale: options.browserLocale || "en-US"
86
87
  });
87
88
  if (options?.enableDevtools && typeof window !== "undefined") ;
88
89
  return shopwarePlugin;
@@ -186,8 +187,7 @@ function useAddToCart(product) {
186
187
  const { addProduct, cartItems } = useCart();
187
188
  const quantity = ref(1);
188
189
  async function addToCart() {
189
- if (!_product.value?.id)
190
- throw new Error("Product id is required");
190
+ if (!_product.value?.id) throw new Error("Product id is required");
191
191
  const addToCartResponse = await addProduct({
192
192
  id: _product.value?.id,
193
193
  quantity: quantity.value
@@ -224,10 +224,8 @@ function useBreadcrumbs(newBreadcrumbs) {
224
224
  _breadcrumbs.value = [];
225
225
  };
226
226
  const pushBreadcrumb = (breadcrumb) => {
227
- if (_breadcrumbs.value)
228
- _breadcrumbs.value.push(breadcrumb);
229
- else
230
- _breadcrumbs.value = [breadcrumb];
227
+ if (_breadcrumbs.value) _breadcrumbs.value.push(breadcrumb);
228
+ else _breadcrumbs.value = [breadcrumb];
231
229
  };
232
230
  const buildDynamicBreadcrumbs = async (breadcrumbs) => {
233
231
  _breadcrumbs.value = breadcrumbs.map((breadcrumb) => {
@@ -562,8 +560,7 @@ function useCheckout() {
562
560
  const shippingMethods = computed(() => storeShippingMethods.value || []);
563
561
  const paymentMethods = computed(() => storePaymentMethods.value || []);
564
562
  async function getShippingMethods({ forceReload } = { forceReload: false }, associations = {}) {
565
- if (shippingMethods.value.length && !forceReload)
566
- return shippingMethods;
563
+ if (shippingMethods.value.length && !forceReload) return shippingMethods;
567
564
  const mergedAssociations = defu(
568
565
  shippingMethodsAssociations,
569
566
  associations
@@ -585,8 +582,7 @@ function useCheckout() {
585
582
  return shippingMethods;
586
583
  }
587
584
  async function getPaymentMethods({ forceReload } = { forceReload: false }) {
588
- if (paymentMethods.value.length && !forceReload)
589
- return paymentMethods;
585
+ if (paymentMethods.value.length && !forceReload) return paymentMethods;
590
586
  const response = await apiClient.invoke(
591
587
  "readPaymentMethod post /payment-method",
592
588
  {
@@ -849,11 +845,9 @@ function useInternationalization(pathResolver) {
849
845
  return devStorefrontUrl ? url.replace(`${current.protocol}//${current.host}`, devStorefrontUrl) : url;
850
846
  }
851
847
  function formatLink(link) {
852
- if (!pathResolver)
853
- return link;
848
+ if (!pathResolver) return link;
854
849
  if (typeof link === "string") {
855
- if (urlIsAbsolute(link))
856
- return link;
850
+ if (urlIsAbsolute(link)) return link;
857
851
  return pathResolver(link);
858
852
  }
859
853
  if (link.path) {
@@ -902,8 +896,7 @@ function isObject(item) {
902
896
  return item && typeof item === "object" && !Array.isArray(item);
903
897
  }
904
898
  function merge(target, ...sources) {
905
- if (!sources.length)
906
- return target;
899
+ if (!sources.length) return target;
907
900
  const source = sources.shift();
908
901
  if (source === void 0) {
909
902
  return target;
@@ -911,8 +904,7 @@ function merge(target, ...sources) {
911
904
  if (isObject(target) && isObject(source)) {
912
905
  for (const key in source) {
913
906
  if (isObject(source[key])) {
914
- if (!target[key])
915
- Object.assign(target, { [key]: {} });
907
+ if (!target[key]) Object.assign(target, { [key]: {} });
916
908
  merge(target[key], source[key]);
917
909
  } else {
918
910
  Object.assign(target, { [key]: source[key] });
@@ -1130,7 +1122,9 @@ function createListingComposable({
1130
1122
  properties: appliedFilters.properties?.split("|")
1131
1123
  };
1132
1124
  }
1133
- return search(appliedFilters);
1125
+ return search(
1126
+ appliedFilters
1127
+ );
1134
1128
  };
1135
1129
  const resetFilters = () => {
1136
1130
  const defaultFilters = Object.assign(
@@ -1308,7 +1302,7 @@ function useNavigationSearch() {
1308
1302
  ]
1309
1303
  }
1310
1304
  });
1311
- return seoResult.data.elements?.[0];
1305
+ return seoResult.data.elements?.[0] ?? null;
1312
1306
  }
1313
1307
  return {
1314
1308
  resolvePath
@@ -1413,12 +1407,16 @@ function useOrderDetails(orderId, associations) {
1413
1407
  );
1414
1408
  provide("swOrderDetails", _sharedOrder);
1415
1409
  const orderAssociations = useDefaultOrderAssociations();
1416
- const paymentMethod = computed(
1417
- () => _sharedOrder.value?.transactions?.length ? _sharedOrder.value.transactions[_sharedOrder.value.transactions.length - 1].paymentMethod : void 0
1418
- );
1419
- const shippingMethod = computed(
1420
- () => _sharedOrder.value?.deliveries?.length ? _sharedOrder.value.deliveries[_sharedOrder.value.deliveries.length - 1].shippingMethod : void 0
1421
- );
1410
+ const paymentMethod = computed(() => {
1411
+ const transactions = _sharedOrder.value?.transactions;
1412
+ if (!transactions?.length) return void 0;
1413
+ return transactions[transactions.length - 1]?.paymentMethod;
1414
+ });
1415
+ const shippingMethod = computed(() => {
1416
+ const deliveries = _sharedOrder.value?.deliveries;
1417
+ if (!deliveries?.length) return void 0;
1418
+ return deliveries[deliveries.length - 1]?.shippingMethod;
1419
+ });
1422
1420
  const paymentUrl = ref();
1423
1421
  const personalDetails = computed(() => ({
1424
1422
  email: _sharedOrder.value?.orderCustomer?.email,
@@ -1464,7 +1462,7 @@ function useOrderDetails(orderId, associations) {
1464
1462
  body: params
1465
1463
  }
1466
1464
  );
1467
- _sharedOrder.value = orderDetailsResponse.data.orders?.elements?.[0] ?? null;
1465
+ _sharedOrder.value = orderDetailsResponse.data.orders?.elements?.[0] ?? void 0;
1468
1466
  paymentChangeableList.value = orderDetailsResponse.data.paymentChangeable ?? {};
1469
1467
  return orderDetailsResponse.data;
1470
1468
  }
@@ -1534,7 +1532,7 @@ function useOrderDetails(orderId, associations) {
1534
1532
  const hasDocuments = computed(() => !!_sharedOrder.value?.documents.length);
1535
1533
  const documents = computed(() => _sharedOrder.value?.documents || []);
1536
1534
  const paymentChangeable = computed(() => {
1537
- return Object.keys(paymentChangeableList.value).length ? paymentChangeableList.value[orderId] : false;
1535
+ return paymentChangeableList.value?.[orderId] ?? false;
1538
1536
  });
1539
1537
  const getPaymentMethods = async () => {
1540
1538
  const response = await apiClient.invoke(
@@ -1627,29 +1625,28 @@ function useOrderPayment(order) {
1627
1625
 
1628
1626
  function _usePrice(params) {
1629
1627
  const { sessionContext } = useSessionContext();
1630
- const currencyLocale = ref();
1628
+ const { browserLocale } = useShopwareContext();
1629
+ const currencyLocale = ref(browserLocale);
1631
1630
  const currencyCode = ref("");
1632
1631
  if (params) {
1633
1632
  currencyCode.value = params.currencyCode;
1634
- currencyLocale.value = params.localeCode;
1633
+ _setLocaleCode(params.localeCode);
1635
1634
  }
1636
1635
  function update(params2) {
1637
1636
  _setCurrencyCode(params2.currencyCode);
1638
- _setLocaleCode(
1639
- params2.localeCode || currencyLocale.value || typeof navigator !== "undefined" && navigator?.language || "en-US"
1640
- );
1637
+ _setLocaleCode(params2.localeCode);
1641
1638
  }
1642
1639
  function _setCurrencyCode(code) {
1643
1640
  currencyCode.value = code;
1644
1641
  }
1645
1642
  function _setLocaleCode(locale) {
1646
- currencyLocale.value = locale;
1643
+ currencyLocale.value = locale || currencyLocale.value;
1647
1644
  }
1648
1645
  function getFormattedPrice(value) {
1649
1646
  if (typeof value === "undefined") {
1650
1647
  return "";
1651
1648
  }
1652
- if (!currencyLocale.value) {
1649
+ if (!currencyLocale.value || !currencyCode.value) {
1653
1650
  return value.toString();
1654
1651
  }
1655
1652
  return new Intl.NumberFormat(currencyLocale.value, {
@@ -1673,7 +1670,8 @@ function _usePrice(params) {
1673
1670
  return {
1674
1671
  getFormattedPrice,
1675
1672
  update,
1676
- currencyCode: computed(() => currencyCode.value)
1673
+ currencyCode: computed(() => currencyCode.value),
1674
+ currencyLocale: computed(() => currencyLocale.value)
1677
1675
  };
1678
1676
  }
1679
1677
  const usePrice = createSharedComposable(_usePrice);
@@ -1789,6 +1787,7 @@ function useProductConfigurator() {
1789
1787
  return response.data.elements?.[0];
1790
1788
  } catch (e) {
1791
1789
  console.error("SwProductDetails:findVariantForSelectedOptions", e);
1790
+ return void 0;
1792
1791
  }
1793
1792
  }
1794
1793
  const handleChange = async (group, option, onChangeHandled) => {
@@ -2159,7 +2158,8 @@ function useShopwareContext() {
2159
2158
  }
2160
2159
  return {
2161
2160
  apiClient,
2162
- devStorefrontUrl: shopwareContext.devStorefrontUrl
2161
+ devStorefrontUrl: shopwareContext.devStorefrontUrl,
2162
+ browserLocale: shopwareContext.browserLocale || "en-US"
2163
2163
  };
2164
2164
  }
2165
2165
 
@@ -2197,8 +2197,7 @@ function useSyncWishlist() {
2197
2197
  _currentPage.value = response.data.products.page ?? 1;
2198
2198
  } catch (e) {
2199
2199
  if (e instanceof ApiClientError) {
2200
- if (e.status !== 404)
2201
- console.error(e);
2200
+ if (e.status !== 404) console.error(e);
2202
2201
  _wishlistItems.value = [];
2203
2202
  }
2204
2203
  }
@@ -2390,7 +2389,6 @@ function useUser() {
2390
2389
  logout,
2391
2390
  updateEmail,
2392
2391
  updatePersonalInfo,
2393
- setDefaultPaymentMethod,
2394
2392
  loadSalutation,
2395
2393
  salutation,
2396
2394
  loadCountry,
@@ -2399,6 +2397,7 @@ function useUser() {
2399
2397
  defaultShippingAddressId,
2400
2398
  userDefaultPaymentMethod,
2401
2399
  userDefaultBillingAddress,
2400
+ setDefaultPaymentMethod,
2402
2401
  userDefaultShippingAddress
2403
2402
  };
2404
2403
  }
@@ -2527,8 +2526,7 @@ function useB2bQuoteManagement() {
2527
2526
  };
2528
2527
  const changePaymentShippingMethod = async (params) => {
2529
2528
  const body = {};
2530
- if (params.paymentMethodId)
2531
- body.paymentMethodId = params.paymentMethodId;
2529
+ if (params.paymentMethodId) body.paymentMethodId = params.paymentMethodId;
2532
2530
  if (params.shippingMethodId)
2533
2531
  body.shippingMethodId = params.shippingMethodId;
2534
2532
  await apiClient.invoke(
@@ -2573,24 +2571,23 @@ function useCartNotification() {
2573
2571
  const { consumeCartErrors } = useCart();
2574
2572
  const codeErrorsNotification = () => {
2575
2573
  const errors = consumeCartErrors();
2576
- if (!errors || Array.isArray(errors))
2577
- return;
2574
+ if (!errors || Array.isArray(errors)) return;
2578
2575
  for (const element of Object.keys(errors)) {
2579
- if (successCodes.includes(errors[element].messageKey)) {
2580
- pushSuccess(errors[element].message);
2576
+ const error = errors[element];
2577
+ if (successCodes.includes(error.messageKey)) {
2578
+ pushSuccess(error.message);
2581
2579
  } else {
2582
- pushError(errors[element].message);
2580
+ pushError(error.message);
2583
2581
  }
2584
2582
  }
2585
2583
  };
2586
2584
  const getErrorsCodes = () => {
2587
2585
  const errors = consumeCartErrors();
2588
- if (!errors || Array.isArray(errors))
2589
- return [];
2586
+ if (!errors || Array.isArray(errors)) return [];
2590
2587
  return Object.keys(errors).reduce(
2591
2588
  (acc, element) => {
2592
- if (!successCodes.includes(errors[element].messageKey))
2593
- acc.push(errors[element]);
2589
+ const error = errors[element];
2590
+ if (!successCodes.includes(error.messageKey)) acc.push(error);
2594
2591
  return acc;
2595
2592
  },
2596
2593
  []
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopware/composables",
3
- "version": "1.8.1",
3
+ "version": "1.9.0",
4
4
  "description": "Shopware Frontends composables for Vue",
5
5
  "author": "Shopware",
6
6
  "repository": {
@@ -51,21 +51,21 @@
51
51
  "types"
52
52
  ],
53
53
  "dependencies": {
54
- "@vueuse/core": "12.5.0",
54
+ "@vueuse/core": "13.1.0",
55
55
  "defu": "6.1.4",
56
56
  "scule": "1.3.0",
57
57
  "@shopware/helpers": "1.4.0",
58
- "@shopware/api-client": "1.2.1"
58
+ "@shopware/api-client": "1.3.0"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@biomejs/biome": "1.8.3",
62
- "@nuxt/kit": "3.15.4",
63
- "@vitest/coverage-v8": "3.0.5",
62
+ "@nuxt/kit": "3.16.2",
63
+ "@vitest/coverage-v8": "3.1.1",
64
64
  "@vue/test-utils": "2.4.6",
65
- "happy-dom": "17.1.0",
66
- "typescript": "5.6.3",
65
+ "happy-dom": "17.4.4",
66
+ "typescript": "5.8.3",
67
67
  "unbuild": "2.0.0",
68
- "vitest": "3.0.5",
68
+ "vitest": "3.1.1",
69
69
  "vue": "3.5.13",
70
70
  "tsconfig": "0.0.0"
71
71
  },
@@ -13,6 +13,7 @@ export function createShopwareContext(
13
13
  options: {
14
14
  devStorefrontUrl?: string | null;
15
15
  enableDevtools?: boolean;
16
+ browserLocale?: string;
16
17
  },
17
18
  ) {
18
19
  const scope: EffectScope = effectScope(true);
@@ -34,6 +35,7 @@ export function createShopwareContext(
34
35
  _e: scope,
35
36
  devStorefrontUrl: options.devStorefrontUrl,
36
37
  state,
38
+ browserLocale: options.browserLocale || "en-US",
37
39
  });
38
40
 
39
41
  if (options?.enableDevtools && typeof window !== "undefined") {
package/src/index.test.ts CHANGED
@@ -8,9 +8,10 @@ vi.mock("vue");
8
8
  describe("resolveCmsComponent", () => {
9
9
  vi.spyOn(vue, "resolveComponent").mockImplementation((element) => element);
10
10
  it("should resolve a cms component", () => {
11
- const result = resolveCmsComponent(
12
- CmsPage.cmsPage.sections[0].blocks[0] as unknown as Schemas["CmsBlock"],
13
- );
11
+ const section = CmsPage.cmsPage.sections?.[0];
12
+ const block = section?.blocks?.[0];
13
+
14
+ const result = resolveCmsComponent(block as unknown as Schemas["CmsBlock"]);
14
15
  expect(result.componentName).toBe("image-simple-grid");
15
16
  expect(result.componentNameToResolve).toBe("CmsBlockImageSimpleGrid");
16
17
  expect(result.isResolved).toBe(true);
@@ -78,3 +78,4 @@ export type CmsBlockProductDescriptionReviews = BlockType<"content">;
78
78
  export type CmsBlockCrossSelling = BlockType<"content">;
79
79
 
80
80
  export type CmsBlockForm = BlockType<"content">;
81
+ export type CmsBlockHtml = BlockType<"content">;
@@ -45,6 +45,15 @@ export type CmsElementText = Schemas["CmsSlot"] & {
45
45
  };
46
46
  };
47
47
 
48
+ // HTML
49
+ export type CmsElementHtml = Schemas["CmsSlot"] & {
50
+ type: "html";
51
+ data: {
52
+ content: string;
53
+ apiAlias: "cms_html";
54
+ };
55
+ };
56
+
48
57
  // Image
49
58
 
50
59
  type ImageElementConfig = {
@@ -52,7 +52,7 @@ describe("useBreadcrumbs", () => {
52
52
  { path: "test" } as Schemas["Breadcrumb"],
53
53
  ]);
54
54
 
55
- expect(vm.breadcrumbs[0].path).toBe("/test");
55
+ expect(vm.breadcrumbs[0]?.path).toBe("/test");
56
56
  });
57
57
 
58
58
  it("should push breadcrumb", async () => {
@@ -43,8 +43,8 @@ describe("useCart", () => {
43
43
  expect(vm.totalPrice).toBe(0);
44
44
  expect(vm.subtotal).toBe(0);
45
45
  await vm.addProduct({
46
- id: itemsMock.items[0].referencedId as string,
47
- quantity: itemsMock.items[0].quantity,
46
+ id: itemsMock.items[0]?.referencedId as string,
47
+ quantity: itemsMock.items[0]?.quantity,
48
48
  });
49
49
 
50
50
  expect(injections.apiClient.invoke).toHaveBeenCalledWith(
@@ -53,9 +53,9 @@ describe("useCart", () => {
53
53
  body: {
54
54
  items: [
55
55
  {
56
- type: itemsMock.items[0].type,
57
- id: itemsMock.items[0].referencedId,
58
- quantity: itemsMock.items[0].quantity,
56
+ type: itemsMock.items[0]?.type,
57
+ id: itemsMock.items[0]?.referencedId,
58
+ quantity: itemsMock.items[0]?.quantity,
59
59
  },
60
60
  ],
61
61
  },
@@ -63,7 +63,7 @@ describe("useCart", () => {
63
63
  );
64
64
 
65
65
  await vm.addProduct({
66
- id: itemsMock.items[0].referencedId as string,
66
+ id: itemsMock.items[0]?.referencedId as string,
67
67
  });
68
68
 
69
69
  expect(injections.apiClient.invoke).toHaveBeenCalledWith(
@@ -72,8 +72,8 @@ describe("useCart", () => {
72
72
  body: {
73
73
  items: [
74
74
  {
75
- type: itemsMock.items[0].type,
76
- id: itemsMock.items[0].referencedId,
75
+ type: itemsMock.items[0]?.type,
76
+ id: itemsMock.items[0]?.referencedId,
77
77
  quantity: 0,
78
78
  },
79
79
  ],
@@ -112,7 +112,7 @@ describe("useCart", () => {
112
112
 
113
113
  it("change product quantity", async () => {
114
114
  await vm.changeProductQuantity({
115
- id: itemsMock.items[0].referencedId as string,
115
+ id: itemsMock.items[0]?.referencedId as string,
116
116
  quantity: 4,
117
117
  });
118
118
  expect(injections.apiClient.invoke).toHaveBeenCalledWith(
@@ -121,7 +121,7 @@ describe("useCart", () => {
121
121
  body: {
122
122
  items: [
123
123
  {
124
- id: itemsMock.items[0].referencedId,
124
+ id: itemsMock.items[0]?.referencedId,
125
125
  quantity: 4,
126
126
  },
127
127
  ],
@@ -35,7 +35,7 @@ describe("useCartItem", () => {
35
35
  expect(vm.isRemovable).toBe(true);
36
36
  expect(vm.isStackable).toBe(true);
37
37
  expect(vm.isDigital).toBe(false);
38
- expect(vm.itemImageThumbnailUrl).toBe(lineItem.cover?.url);
38
+ expect(vm.itemImageThumbnailUrl).toBe(lineItem?.cover?.url);
39
39
  expect(vm.itemType).toBe("product");
40
40
  expect(vm.itemQuantity).toBe(1);
41
41
  expect(vm.itemStock).toBe(49485);
@@ -112,7 +112,7 @@ describe("useCartItem", () => {
112
112
 
113
113
  expect(changeProductQuantitySpy).toHaveBeenCalledWith({
114
114
  quantity: 5,
115
- id: lineItem.id,
115
+ id: lineItem?.id,
116
116
  });
117
117
  expect(result).toEqual(mockedResponse);
118
118
 
@@ -120,7 +120,7 @@ describe("useCartItem", () => {
120
120
  vm.changeItemQuantity("6");
121
121
  expect(changeProductQuantitySpy).toHaveBeenCalledWith({
122
122
  quantity: 6,
123
- id: lineItem.id,
123
+ id: lineItem?.id,
124
124
  });
125
125
  });
126
126
 
@@ -28,10 +28,11 @@ export function useCartNotification(): useCartNotificationReturn {
28
28
  if (!errors || Array.isArray(errors)) return;
29
29
 
30
30
  for (const element of Object.keys(errors)) {
31
- if (successCodes.includes(errors[element].messageKey)) {
32
- pushSuccess(errors[element].message);
31
+ const error = errors[element] as Schemas["CartError"];
32
+ if (successCodes.includes(error.messageKey)) {
33
+ pushSuccess(error.message);
33
34
  } else {
34
- pushError(errors[element].message);
35
+ pushError(error.message);
35
36
  }
36
37
  }
37
38
  };
@@ -47,9 +48,8 @@ export function useCartNotification(): useCartNotificationReturn {
47
48
 
48
49
  return Object.keys(errors).reduce(
49
50
  (acc, element) => {
50
- if (!successCodes.includes(errors[element].messageKey))
51
- acc.push(errors[element] as Schemas["CartError"]);
52
-
51
+ const error = errors[element] as Schemas["CartError"];
52
+ if (!successCodes.includes(error.messageKey)) acc.push(error);
53
53
  return acc;
54
54
  },
55
55
  [] as Schemas["CartError"][],
@@ -6,13 +6,13 @@ import { useCmsSection } from "./useCmsSection";
6
6
 
7
7
  describe("useCmsSection", () => {
8
8
  it("search", async () => {
9
+ const section = CmsPage.cmsPage.sections?.[0];
10
+
9
11
  const { vm, injections } = useSetup(() =>
10
- useCmsSection(
11
- CmsPage.cmsPage.sections[0] as unknown as Schemas["CmsSection"],
12
- ),
12
+ useCmsSection(section as unknown as Schemas["CmsSection"]),
13
13
  );
14
14
  injections.apiClient.invoke.mockResolvedValue({ data: {} });
15
15
  const block = await vm.getPositionContent("main");
16
- expect(block).toEqual(CmsPage.cmsPage.sections[0].blocks);
16
+ expect(block).toEqual(section?.blocks);
17
17
  });
18
18
  });
@@ -14,9 +14,9 @@ describe("useCountries", () => {
14
14
  });
15
15
  await vm.fetchCountries();
16
16
 
17
- expect(vm.getStatesForCountry(CountryMock.elements[0].id)).toStrictEqual(
18
- CountryMock.elements[0].states,
19
- );
17
+ expect(
18
+ vm.getStatesForCountry(CountryMock.elements?.[0]?.id as string),
19
+ ).toStrictEqual(CountryMock.elements?.[0]?.states);
20
20
 
21
21
  expect(injections.apiClient.invoke).toHaveBeenCalledWith(
22
22
  expect.stringContaining("readCountry"),
@@ -42,9 +42,9 @@ describe("useCountries", () => {
42
42
  });
43
43
  await vm.fetchCountries();
44
44
 
45
- expect(vm.getStatesForCountry(CountryMock.elements[0].id)).toStrictEqual(
46
- null,
47
- );
45
+ expect(
46
+ vm.getStatesForCountry(CountryMock.elements?.[0]?.id as string),
47
+ ).toStrictEqual(null);
48
48
  });
49
49
 
50
50
  it("useCountries flow - empty", async () => {
@@ -525,7 +525,9 @@ export function createListingComposable({
525
525
  };
526
526
  }
527
527
 
528
- return search(appliedFilters);
528
+ return search(
529
+ appliedFilters as operations["searchPage post /search"]["body"],
530
+ );
529
531
  };
530
532
 
531
533
  const resetFilters = () => {
@@ -18,7 +18,7 @@ export function useNavigationSearch(): UseNavigationSearchReturn {
18
18
  const { apiClient } = useShopwareContext();
19
19
  const { sessionContext } = useSessionContext();
20
20
 
21
- async function resolvePath(path: string) {
21
+ async function resolvePath(path: string): Promise<Schemas["SeoUrl"] | null> {
22
22
  if (path === "/") {
23
23
  // please ignore optional chaining for salesChannel object as it's always present (type definition issue)
24
24
  const categoryId =
@@ -51,7 +51,7 @@ export function useNavigationSearch(): UseNavigationSearchReturn {
51
51
  },
52
52
  });
53
53
 
54
- return seoResult.data.elements?.[0];
54
+ return seoResult.data.elements?.[0] ?? null;
55
55
  }
56
56
 
57
57
  return {
@@ -20,7 +20,7 @@ describe("useNotifications", () => {
20
20
  vm.pushWarning("Warning message", { persistent: true });
21
21
 
22
22
  expect(vm.notifications.length).toBe(4);
23
- vm.removeOne(vm.notifications[0].id);
23
+ vm.removeOne(vm.notifications[0]?.id as number);
24
24
  expect(vm.notifications.length).toBe(3);
25
25
  vm.removeAll();
26
26
  expect(vm.notifications.length).toBe(0);
@@ -15,15 +15,15 @@ describe("useOrderDetails", () => {
15
15
  );
16
16
 
17
17
  expect(vm.personalDetails).toEqual({
18
- email: Order.orders.elements[0].orderCustomer.email,
19
- firstName: Order.orders.elements[0].orderCustomer.firstName,
20
- lastName: Order.orders.elements[0].orderCustomer.lastName,
18
+ email: Order.orders.elements?.[0]?.orderCustomer.email,
19
+ firstName: Order.orders.elements?.[0]?.orderCustomer.firstName,
20
+ lastName: Order.orders.elements?.[0]?.orderCustomer.lastName,
21
21
  });
22
22
 
23
23
  expect(vm.billingAddress).toEqual(
24
- Order.orders.elements[0].addresses.find(
24
+ Order.orders.elements?.[0]?.addresses.find(
25
25
  ({ id }: { id: string }) =>
26
- id === Order.orders.elements[0].billingAddressId,
26
+ id === Order.orders.elements?.[0]?.billingAddressId,
27
27
  ),
28
28
  );
29
29
  });
@@ -139,20 +139,17 @@ export function useOrderDetails(
139
139
 
140
140
  const orderAssociations = useDefaultOrderAssociations();
141
141
 
142
- const paymentMethod = computed(() =>
143
- _sharedOrder.value?.transactions?.length
144
- ? _sharedOrder.value.transactions[
145
- _sharedOrder.value.transactions.length - 1
146
- ].paymentMethod
147
- : undefined,
148
- );
142
+ const paymentMethod = computed(() => {
143
+ const transactions = _sharedOrder.value?.transactions;
144
+ if (!transactions?.length) return undefined;
145
+ return transactions[transactions.length - 1]?.paymentMethod;
146
+ });
149
147
 
150
- const shippingMethod = computed(() =>
151
- _sharedOrder.value?.deliveries?.length
152
- ? _sharedOrder.value.deliveries[_sharedOrder.value.deliveries.length - 1]
153
- .shippingMethod
154
- : undefined,
155
- );
148
+ const shippingMethod = computed(() => {
149
+ const deliveries = _sharedOrder.value?.deliveries;
150
+ if (!deliveries?.length) return undefined;
151
+ return deliveries[deliveries.length - 1]?.shippingMethod;
152
+ });
156
153
 
157
154
  const paymentUrl = ref();
158
155
 
@@ -204,7 +201,7 @@ export function useOrderDetails(
204
201
  },
205
202
  );
206
203
  _sharedOrder.value =
207
- orderDetailsResponse.data.orders?.elements?.[0] ?? null;
204
+ orderDetailsResponse.data.orders?.elements?.[0] ?? undefined;
208
205
  paymentChangeableList.value =
209
206
  orderDetailsResponse.data.paymentChangeable ?? {};
210
207
  return orderDetailsResponse.data;
@@ -285,11 +282,7 @@ export function useOrderDetails(
285
282
  const documents = computed(() => _sharedOrder.value?.documents || []);
286
283
 
287
284
  const paymentChangeable = computed(() => {
288
- return Object.keys(paymentChangeableList.value).length
289
- ? (paymentChangeableList.value as { [key: string]: boolean })[
290
- orderId as string
291
- ]
292
- : false;
285
+ return paymentChangeableList.value?.[orderId as string] ?? false;
293
286
  });
294
287
 
295
288
  const getPaymentMethods = async () => {
@@ -10,7 +10,7 @@ describe("useOrderPayment", () => {
10
10
  it("should handle the order payment", async () => {
11
11
  const { vm, injections } = useSetup(() =>
12
12
  useOrderPayment(
13
- computed(() => Order.orders.elements[0]) as unknown as ComputedRef<
13
+ computed(() => Order.orders.elements?.[0]) as unknown as ComputedRef<
14
14
  Schemas["Order"]
15
15
  >,
16
16
  ),
@@ -24,13 +24,13 @@ describe("useOrderPayment", () => {
24
24
  body: {
25
25
  errorUrl: undefined,
26
26
  finishUrl: undefined,
27
- orderId: Order.orders.elements[0].id,
27
+ orderId: Order.orders.elements?.[0]?.id,
28
28
  },
29
29
  }),
30
30
  );
31
31
 
32
32
  expect(vm.activeTransaction).toEqual(
33
- Order.orders.elements[0].transactions[0],
33
+ Order.orders.elements?.[0]?.transactions[0],
34
34
  );
35
35
 
36
36
  vm.changePaymentMethod("test");
@@ -59,19 +59,18 @@ describe("useOrderPayment", () => {
59
59
  it("should be a asynchronous payment", () => {
60
60
  const { vm } = useSetup(() =>
61
61
  useOrderPayment(
62
- computed(() =>
63
- Object.assign(Order.orders.elements[0], {
64
- transactions: [
65
- {
66
- paymentMethod: {
67
- active: true,
68
- asynchronous: true,
69
- afterOrderEnabled: true,
70
- },
62
+ computed(() => ({
63
+ ...Order.orders.elements?.[0],
64
+ transactions: [
65
+ {
66
+ paymentMethod: {
67
+ active: true,
68
+ asynchronous: true,
69
+ afterOrderEnabled: true,
71
70
  },
72
- ],
73
- }),
74
- ) as unknown as ComputedRef<Schemas["Order"]>,
71
+ },
72
+ ],
73
+ })) as unknown as ComputedRef<Schemas["Order"]>,
75
74
  ),
76
75
  );
77
76
 
@@ -2,12 +2,20 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
2
2
  import { ref } from "vue";
3
3
  import { usePrice, useSessionContext } from "#imports";
4
4
  import { useSetup } from "../_test";
5
- const currentNavigator = global.navigator;
5
+
6
+ vi.mock("@vueuse/core", async (importOriginal) => {
7
+ const actual = await importOriginal<typeof import("@vueuse/core")>();
8
+ return {
9
+ ...actual,
10
+ createSharedComposable: (fn: (...args: unknown[]) => unknown) => fn,
11
+ };
12
+ });
6
13
 
7
14
  vi.mock("../useSessionContext/useSessionContext.ts");
8
15
  const sessionContext = ref();
9
16
 
10
17
  beforeEach(() => {
18
+ sessionContext.value = null;
11
19
  vi.clearAllMocks();
12
20
  vi.mocked(useSessionContext).mockReturnValue({
13
21
  sessionContext,
@@ -20,9 +28,6 @@ describe("usePrice", () => {
20
28
  });
21
29
 
22
30
  it("use default locale if locale is not provided", () => {
23
- vi.spyOn(global, "navigator", "get").mockImplementation(
24
- () => ({}) as Navigator,
25
- );
26
31
  const { vm } = useSetup(usePrice);
27
32
  expect(vm.getFormattedPrice(2.55)).toMatchInlineSnapshot('"2.55"');
28
33
  vm.update({
@@ -30,20 +35,22 @@ describe("usePrice", () => {
30
35
  localeCode: undefined,
31
36
  });
32
37
 
38
+ expect(vm.currencyLocale).toBe("en-US");
33
39
  expect(vm.getFormattedPrice(2.55)).toMatchInlineSnapshot('"$2.55"');
34
40
  });
35
41
 
36
42
  it("should use navigator language if locale is not provided", () => {
37
- vi.spyOn(global, "navigator", "get").mockImplementation(
38
- () => currentNavigator,
39
- );
40
- vi.spyOn(navigator, "language", "get").mockImplementation(() => "en-FR");
41
- const { vm } = useSetup(usePrice);
43
+ const { vm } = useSetup(usePrice, {
44
+ shopware: {
45
+ browserLocale: "en-FR",
46
+ },
47
+ });
42
48
  vm.update({
43
49
  currencyCode: "USD",
44
50
  localeCode: undefined,
45
51
  });
46
52
 
53
+ expect(vm.currencyLocale).toBe("en-FR");
47
54
  expect(vm.getFormattedPrice(2.55)).toMatchInlineSnapshot('"$2.55"');
48
55
  });
49
56
 
@@ -71,10 +78,14 @@ describe("usePrice", () => {
71
78
  it("should return price with current locale", async () => {
72
79
  const { vm } = useSetup(usePrice);
73
80
 
81
+ await vm.update({
82
+ localeCode: "de-DE",
83
+ currencyCode: "EUR",
84
+ });
85
+
74
86
  await vm.update({
75
87
  currencyCode: "USD",
76
- // @ts-expect-error string expected here
77
- currencyLocale: undefined,
88
+ localeCode: undefined,
78
89
  });
79
90
  expect(vm.getFormattedPrice(2.55)).toMatchInlineSnapshot('"2,55 $"');
80
91
  });
@@ -94,4 +105,28 @@ describe("usePrice", () => {
94
105
  await vm.$nextTick();
95
106
  expect(vm.currencyCode).toBe("PLN");
96
107
  });
108
+
109
+ it("should use default en-US locale if locale is not provided", async () => {
110
+ const { vm } = useSetup(usePrice);
111
+
112
+ await vm.update({
113
+ currencyCode: "USD",
114
+ });
115
+ expect(vm.currencyLocale).toBe("en-US");
116
+ expect(vm.getFormattedPrice(2.55)).toMatchInlineSnapshot('"$2.55"');
117
+ });
118
+
119
+ it("should take locale from shopware context", async () => {
120
+ const { vm } = useSetup(usePrice, {
121
+ shopware: {
122
+ browserLocale: "en-GB",
123
+ },
124
+ });
125
+
126
+ await vm.update({
127
+ currencyCode: "USD",
128
+ });
129
+ expect(vm.currencyLocale).toBe("en-GB");
130
+ expect(vm.getFormattedPrice(2.55)).toMatchInlineSnapshot(`"US$2.55"`);
131
+ });
97
132
  });
@@ -1,7 +1,7 @@
1
1
  import { createSharedComposable } from "@vueuse/core";
2
2
  import { computed, ref, watch } from "vue";
3
3
  import type { ComputedRef } from "vue";
4
- import { useSessionContext } from "#imports";
4
+ import { useSessionContext, useShopwareContext } from "#imports";
5
5
 
6
6
  export type UsePriceReturn = {
7
7
  /**
@@ -12,13 +12,17 @@ export type UsePriceReturn = {
12
12
  * Update configuration
13
13
  */
14
14
  update(params: {
15
- localeCode: string | undefined;
15
+ localeCode?: string | undefined;
16
16
  currencyCode: string;
17
17
  }): void;
18
18
  /**
19
19
  * Currency code
20
20
  */
21
21
  currencyCode: ComputedRef<string>;
22
+ /**
23
+ * Currency locale
24
+ */
25
+ currencyLocale: ComputedRef<string>;
22
26
  };
23
27
 
24
28
  /**
@@ -29,16 +33,17 @@ export type UsePriceReturn = {
29
33
  * @category Product
30
34
  */
31
35
  function _usePrice(params?: {
32
- localeCode: string | undefined;
36
+ localeCode?: string | undefined;
33
37
  currencyCode: string;
34
38
  }): UsePriceReturn {
35
39
  const { sessionContext } = useSessionContext();
36
- const currencyLocale = ref<string | undefined>();
40
+ const { browserLocale } = useShopwareContext();
41
+ const currencyLocale = ref<string>(browserLocale);
37
42
  const currencyCode = ref<string>("");
38
43
 
39
44
  if (params) {
40
45
  currencyCode.value = params.currencyCode;
41
- currencyLocale.value = params.localeCode;
46
+ _setLocaleCode(params.localeCode);
42
47
  }
43
48
 
44
49
  function update(params: {
@@ -46,20 +51,15 @@ function _usePrice(params?: {
46
51
  currencyCode: string;
47
52
  }) {
48
53
  _setCurrencyCode(params.currencyCode);
49
- _setLocaleCode(
50
- params.localeCode ||
51
- currencyLocale.value ||
52
- (typeof navigator !== "undefined" && navigator?.language) ||
53
- "en-US",
54
- );
54
+ _setLocaleCode(params.localeCode);
55
55
  }
56
56
 
57
57
  function _setCurrencyCode(code: string) {
58
58
  currencyCode.value = code;
59
59
  }
60
60
 
61
- function _setLocaleCode(locale: string) {
62
- currencyLocale.value = locale;
61
+ function _setLocaleCode(locale: string | undefined) {
62
+ currencyLocale.value = locale || currencyLocale.value;
63
63
  }
64
64
 
65
65
  /**
@@ -70,10 +70,9 @@ function _usePrice(params?: {
70
70
  return "";
71
71
  }
72
72
 
73
- if (!currencyLocale.value) {
73
+ if (!currencyLocale.value || !currencyCode.value) {
74
74
  return value.toString();
75
75
  }
76
-
77
76
  return new Intl.NumberFormat(currencyLocale.value, {
78
77
  style: "currency",
79
78
  currency: currencyCode.value,
@@ -98,6 +97,7 @@ function _usePrice(params?: {
98
97
  getFormattedPrice,
99
98
  update,
100
99
  currencyCode: computed(() => currencyCode.value),
100
+ currencyLocale: computed(() => currencyLocale.value),
101
101
  };
102
102
  }
103
103
  /**
@@ -107,6 +107,7 @@ export function useProductConfigurator(): UseProductConfiguratorReturn {
107
107
  return response.data.elements?.[0]; // return first matching product
108
108
  } catch (e) {
109
109
  console.error("SwProductDetails:findVariantForSelectedOptions", e);
110
+ return undefined;
110
111
  }
111
112
  }
112
113
 
@@ -37,7 +37,7 @@ describe("useProductPrice", () => {
37
37
  productTierPrices.product.calculatedPrices[2],
38
38
  );
39
39
  expect(vm.referencePrice).toStrictEqual(
40
- productTierPrices.product.calculatedPrices[0].referencePrice,
40
+ productTierPrices.product.calculatedPrices?.[0]?.referencePrice,
41
41
  );
42
42
  expect(vm.displayFrom).toBe(true);
43
43
  expect(vm.displayFromVariants).toBe(20);
@@ -8,6 +8,11 @@ export type ShopwareContext = {
8
8
  * Shopware API client
9
9
  */
10
10
  apiClient: ApiClient;
11
+ /**
12
+ * Browser locale, working in SSR
13
+ * If not provided, it will be "en-US"
14
+ */
15
+ browserLocale: string;
11
16
  };
12
17
 
13
18
  /**
@@ -27,5 +32,6 @@ export function useShopwareContext(): ShopwareContext {
27
32
  return {
28
33
  apiClient,
29
34
  devStorefrontUrl: shopwareContext.devStorefrontUrl,
35
+ browserLocale: shopwareContext.browserLocale || "en-US",
30
36
  };
31
37
  }
@@ -100,6 +100,8 @@ export type UseUserReturn = {
100
100
  updateEmailData: operations["changeEmail post /account/change-email"]["body"],
101
101
  ): Promise<void>;
102
102
  /**
103
+ * @deprecated API endpoint is removed in Shopware 6.7
104
+ *
103
105
  * Sets the default payment method for given id
104
106
  * @param paymentMethodId
105
107
  * @returns
@@ -281,6 +283,7 @@ export function useUser(): UseUserReturn {
281
283
  },
282
284
  );
283
285
  }
286
+
284
287
  const defaultBillingAddressId = computed(
285
288
  () => user.value?.defaultBillingAddressId || null,
286
289
  );
@@ -307,7 +310,6 @@ export function useUser(): UseUserReturn {
307
310
  logout,
308
311
  updateEmail,
309
312
  updatePersonalInfo,
310
- setDefaultPaymentMethod,
311
313
  loadSalutation,
312
314
  salutation,
313
315
  loadCountry,
@@ -316,6 +318,7 @@ export function useUser(): UseUserReturn {
316
318
  defaultShippingAddressId,
317
319
  userDefaultPaymentMethod,
318
320
  userDefaultBillingAddress,
321
+ setDefaultPaymentMethod,
319
322
  userDefaultShippingAddress,
320
323
  };
321
324
  }