@behio/storefront-sdk 1.5.0 → 1.6.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.
@@ -972,6 +972,29 @@ var CartModule = class {
972
972
  this.client.emit("cart:updated", res.data);
973
973
  return res;
974
974
  }
975
+ /**
976
+ * Switch the CART currency server-side. The backend re-prices every line in
977
+ * the new currency (no FX conversion: a product must have a price configured
978
+ * in that currency, otherwise the call fails with 400 listing the items and
979
+ * the cart stays unchanged). Creates an empty cart in that currency when
980
+ * none exists yet.
981
+ *
982
+ * This is the money-path counterpart of `client.setCurrency()` (which only
983
+ * affects catalog display). Call BOTH from a currency switcher:
984
+ *
985
+ * ```ts
986
+ * client.setCurrency("EUR"); // catalog prices
987
+ * await client.cart.setCurrency("EUR"); // cart + checkout prices
988
+ * ```
989
+ */
990
+ async setCurrency(currency) {
991
+ const res = await this.client.request("PUT", "/cart/currency", {
992
+ body: { currency }
993
+ });
994
+ if (res.error) return res;
995
+ this.client.emit("cart:updated", res.data);
996
+ return res;
997
+ }
975
998
  /** Update item quantity */
976
999
  async updateQuantity(itemId, quantity) {
977
1000
  const res = await this.client.request(
@@ -972,6 +972,29 @@ var CartModule = class {
972
972
  this.client.emit("cart:updated", res.data);
973
973
  return res;
974
974
  }
975
+ /**
976
+ * Switch the CART currency server-side. The backend re-prices every line in
977
+ * the new currency (no FX conversion: a product must have a price configured
978
+ * in that currency, otherwise the call fails with 400 listing the items and
979
+ * the cart stays unchanged). Creates an empty cart in that currency when
980
+ * none exists yet.
981
+ *
982
+ * This is the money-path counterpart of `client.setCurrency()` (which only
983
+ * affects catalog display). Call BOTH from a currency switcher:
984
+ *
985
+ * ```ts
986
+ * client.setCurrency("EUR"); // catalog prices
987
+ * await client.cart.setCurrency("EUR"); // cart + checkout prices
988
+ * ```
989
+ */
990
+ async setCurrency(currency) {
991
+ const res = await this.client.request("PUT", "/cart/currency", {
992
+ body: { currency }
993
+ });
994
+ if (res.error) return res;
995
+ this.client.emit("cart:updated", res.data);
996
+ return res;
997
+ }
975
998
  /** Update item quantity */
976
999
  async updateQuantity(itemId, quantity) {
977
1000
  const res = await this.client.request(
@@ -2616,6 +2616,22 @@ declare class CartModule {
2616
2616
  addItem(input: AddToCartInput): Promise<SdkResult<Cart & {
2617
2617
  newSessionToken?: string;
2618
2618
  }>>;
2619
+ /**
2620
+ * Switch the CART currency server-side. The backend re-prices every line in
2621
+ * the new currency (no FX conversion: a product must have a price configured
2622
+ * in that currency, otherwise the call fails with 400 listing the items and
2623
+ * the cart stays unchanged). Creates an empty cart in that currency when
2624
+ * none exists yet.
2625
+ *
2626
+ * This is the money-path counterpart of `client.setCurrency()` (which only
2627
+ * affects catalog display). Call BOTH from a currency switcher:
2628
+ *
2629
+ * ```ts
2630
+ * client.setCurrency("EUR"); // catalog prices
2631
+ * await client.cart.setCurrency("EUR"); // cart + checkout prices
2632
+ * ```
2633
+ */
2634
+ setCurrency(currency: string): Promise<SdkResult<Cart>>;
2619
2635
  /** Update item quantity */
2620
2636
  updateQuantity(itemId: string, quantity: number): Promise<SdkResult<Cart>>;
2621
2637
  /** Remove item from cart */
@@ -2616,6 +2616,22 @@ declare class CartModule {
2616
2616
  addItem(input: AddToCartInput): Promise<SdkResult<Cart & {
2617
2617
  newSessionToken?: string;
2618
2618
  }>>;
2619
+ /**
2620
+ * Switch the CART currency server-side. The backend re-prices every line in
2621
+ * the new currency (no FX conversion: a product must have a price configured
2622
+ * in that currency, otherwise the call fails with 400 listing the items and
2623
+ * the cart stays unchanged). Creates an empty cart in that currency when
2624
+ * none exists yet.
2625
+ *
2626
+ * This is the money-path counterpart of `client.setCurrency()` (which only
2627
+ * affects catalog display). Call BOTH from a currency switcher:
2628
+ *
2629
+ * ```ts
2630
+ * client.setCurrency("EUR"); // catalog prices
2631
+ * await client.cart.setCurrency("EUR"); // cart + checkout prices
2632
+ * ```
2633
+ */
2634
+ setCurrency(currency: string): Promise<SdkResult<Cart>>;
2619
2635
  /** Update item quantity */
2620
2636
  updateQuantity(itemId: string, quantity: number): Promise<SdkResult<Cart>>;
2621
2637
  /** Remove item from cart */
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as ProductDetail, a as ProductVariant, B as BehioStorefront, S as SdkResult, C as CookieConsent } from './client-LetSVGM1.mjs';
2
- export { A as ActivePromotion, b as AddToCartInput, c as AddressDetail, d as AddressSuggestion, e as AddressType, f as AddressTypes, g as AuthTokens, h as BackInStockSubscription, i as BadgeTone, j as BehioApiError, k as BehioErrorCode, l as BehioEventHandler, m as BehioEventType, n as BehioNetworkError, o as BehioStorefrontConfig, p as Bundle, q as BundleItem, r as Cart, s as CartBundleLine, t as CartBundleLineItem, u as CartDiscount, v as CartItem, w as CartItemProduct, x as CartPromotion, y as Category, z as CategoryDetail, D as CertificateVerification, E as CheckoutAddress, F as CheckoutInput, G as CheckoutPaymentMethod, H as CheckoutSettings, I as CookieConsentInput, J as CourseAttachment, K as CourseCertificate, L as CourseComment, M as CourseCommentReply, N as CourseCommentsList, O as CourseDetail, Q as CourseLesson, R as CourseListItem, T as CourseModule, U as CoursePostedComment, V as CourseProgress, W as CourseTutorMessage, X as CourseTutorThread, Y as CrossSellItem, Z as CustomerAddress, _ as CustomerProfile, $ as DigitalDownload, a0 as DownloadUrl, a1 as Facet, a2 as FacetAvailability, a3 as FacetCategory, a4 as FacetLabel, a5 as FacetPriceRange, a6 as FacetRange, a7 as FacetRatingBucket, a8 as FacetValue, a9 as FacetsResponse, aa as FilterField, ab as FulfillmentStatus, ac as FulfillmentStatuses, ad as GiftCardBalance, ae as GiftCardPurchaseInput, af as GiftCardPurchaseResult, ag as GiftCardSummary, ah as LessonNote, ai as LessonQuiz, aj as LoginInput, ak as LoyaltyBalance, al as LoyaltyNextTier, am as LoyaltyProgram, an as LoyaltySummary, ao as LoyaltyTier, ap as LoyaltyTierPerks, aq as LoyaltyTransaction, ar as Menu, as as MenuItem, at as MenuItemRef, au as MenuItemType, av as MessageResponse, aw as NewsletterOptInDefault, ax as NewsletterSubscribeInput, ay as NewsletterSubscribeResult, az as NewsletterUnsubscribeResult, aA as OrderAccessRequestResponse, aB as OrderAccessVerifyResponse, aC as OrderDetail, aD as OrderItem, aE as OrderListItem, aF as OrderStatus, aG as OrderStatusHistory, aH as OrderStatuses, aI as OrderTracking, aJ as Page, aK as PageAttachment, aL as PageDetail, aM as PaginatedResponse, aN as PaymentStatus, aO as PaymentStatuses, aP as PickupPoint, aQ as PickupPointHours, aR as PickupPointsInput, aS as PriceDisplay, aT as ProductAvailability, aU as ProductGroup, aV as ProductLabel, aW as ProductListItem, aX as ProductMedia, aY as ProductMediaVariant, aZ as ProductParameter, a_ as ProductParameterGroup, a$ as ProductParametersResponse, b0 as ProductPrice, b1 as ProductPromotionSummary, b2 as ProductReview, b3 as ProductReviewsResponse, b4 as ProductSibling, b5 as ProductSort, b6 as ProductSortValue, b7 as ProductVolumePrice, b8 as ProductsQuery, b9 as QuizAnswerInput, ba as QuizAnswerResult, bb as QuizQuestion, bc as QuizResult, bd as QuoteItem, be as QuoteRequest, bf as RegisterInput, bg as RegisterResult, bh as RequestInterceptor, bi as RequestInterceptorConfig, bj as ResponseInterceptor, bk as ResponseInterceptorData, bl as ReturnRequest, bm as ReturnRequestItem, bn as ReturnStatus, bo as ReturnStatusItem, bp as ReturnableOrder, bq as ReturnableOrderItem, br as SdkError, bs as ShippingMethodSummary, bt as ShippingQuote, bu as ShippingQuoteInput, bv as ShopInfo, bw as ShopScript, bx as ShopScriptPlacement, by as ShopScriptType, bz as ShopScripts, bA as ShopSeo, bB as ShopSeoIdentity, bC as Sitemap, bD as SitemapEntry, bE as StockBehavior, bF as StockMode, bG as SubmitQuoteInput, bH as SubmitReturnInput, bI as SubmitReviewInput, bJ as Subscription, bK as SubscriptionAction, bL as SubscriptionFrequency, bM as SubscriptionItem, bN as SubscriptionStatus, bO as TaxBreakdownLine, bP as VariantAxis, bQ as VariantAxisValue, bR as WishlistItem, bS as err, bT as ok, bU as toSdkError } from './client-LetSVGM1.mjs';
1
+ import { P as ProductDetail, a as ProductVariant, B as BehioStorefront, S as SdkResult, C as CookieConsent } from './client-B9jHeWca.mjs';
2
+ export { A as ActivePromotion, b as AddToCartInput, c as AddressDetail, d as AddressSuggestion, e as AddressType, f as AddressTypes, g as AuthTokens, h as BackInStockSubscription, i as BadgeTone, j as BehioApiError, k as BehioErrorCode, l as BehioEventHandler, m as BehioEventType, n as BehioNetworkError, o as BehioStorefrontConfig, p as Bundle, q as BundleItem, r as Cart, s as CartBundleLine, t as CartBundleLineItem, u as CartDiscount, v as CartItem, w as CartItemProduct, x as CartPromotion, y as Category, z as CategoryDetail, D as CertificateVerification, E as CheckoutAddress, F as CheckoutInput, G as CheckoutPaymentMethod, H as CheckoutSettings, I as CookieConsentInput, J as CourseAttachment, K as CourseCertificate, L as CourseComment, M as CourseCommentReply, N as CourseCommentsList, O as CourseDetail, Q as CourseLesson, R as CourseListItem, T as CourseModule, U as CoursePostedComment, V as CourseProgress, W as CourseTutorMessage, X as CourseTutorThread, Y as CrossSellItem, Z as CustomerAddress, _ as CustomerProfile, $ as DigitalDownload, a0 as DownloadUrl, a1 as Facet, a2 as FacetAvailability, a3 as FacetCategory, a4 as FacetLabel, a5 as FacetPriceRange, a6 as FacetRange, a7 as FacetRatingBucket, a8 as FacetValue, a9 as FacetsResponse, aa as FilterField, ab as FulfillmentStatus, ac as FulfillmentStatuses, ad as GiftCardBalance, ae as GiftCardPurchaseInput, af as GiftCardPurchaseResult, ag as GiftCardSummary, ah as LessonNote, ai as LessonQuiz, aj as LoginInput, ak as LoyaltyBalance, al as LoyaltyNextTier, am as LoyaltyProgram, an as LoyaltySummary, ao as LoyaltyTier, ap as LoyaltyTierPerks, aq as LoyaltyTransaction, ar as Menu, as as MenuItem, at as MenuItemRef, au as MenuItemType, av as MessageResponse, aw as NewsletterOptInDefault, ax as NewsletterSubscribeInput, ay as NewsletterSubscribeResult, az as NewsletterUnsubscribeResult, aA as OrderAccessRequestResponse, aB as OrderAccessVerifyResponse, aC as OrderDetail, aD as OrderItem, aE as OrderListItem, aF as OrderStatus, aG as OrderStatusHistory, aH as OrderStatuses, aI as OrderTracking, aJ as Page, aK as PageAttachment, aL as PageDetail, aM as PaginatedResponse, aN as PaymentStatus, aO as PaymentStatuses, aP as PickupPoint, aQ as PickupPointHours, aR as PickupPointsInput, aS as PriceDisplay, aT as ProductAvailability, aU as ProductGroup, aV as ProductLabel, aW as ProductListItem, aX as ProductMedia, aY as ProductMediaVariant, aZ as ProductParameter, a_ as ProductParameterGroup, a$ as ProductParametersResponse, b0 as ProductPrice, b1 as ProductPromotionSummary, b2 as ProductReview, b3 as ProductReviewsResponse, b4 as ProductSibling, b5 as ProductSort, b6 as ProductSortValue, b7 as ProductVolumePrice, b8 as ProductsQuery, b9 as QuizAnswerInput, ba as QuizAnswerResult, bb as QuizQuestion, bc as QuizResult, bd as QuoteItem, be as QuoteRequest, bf as RegisterInput, bg as RegisterResult, bh as RequestInterceptor, bi as RequestInterceptorConfig, bj as ResponseInterceptor, bk as ResponseInterceptorData, bl as ReturnRequest, bm as ReturnRequestItem, bn as ReturnStatus, bo as ReturnStatusItem, bp as ReturnableOrder, bq as ReturnableOrderItem, br as SdkError, bs as ShippingMethodSummary, bt as ShippingQuote, bu as ShippingQuoteInput, bv as ShopInfo, bw as ShopScript, bx as ShopScriptPlacement, by as ShopScriptType, bz as ShopScripts, bA as ShopSeo, bB as ShopSeoIdentity, bC as Sitemap, bD as SitemapEntry, bE as StockBehavior, bF as StockMode, bG as SubmitQuoteInput, bH as SubmitReturnInput, bI as SubmitReviewInput, bJ as Subscription, bK as SubscriptionAction, bL as SubscriptionFrequency, bM as SubscriptionItem, bN as SubscriptionStatus, bO as TaxBreakdownLine, bP as VariantAxis, bQ as VariantAxisValue, bR as WishlistItem, bS as err, bT as ok, bU as toSdkError } from './client-B9jHeWca.mjs';
3
3
 
4
4
  /**
5
5
  * Format a price amount with currency using Intl.NumberFormat.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as ProductDetail, a as ProductVariant, B as BehioStorefront, S as SdkResult, C as CookieConsent } from './client-LetSVGM1.js';
2
- export { A as ActivePromotion, b as AddToCartInput, c as AddressDetail, d as AddressSuggestion, e as AddressType, f as AddressTypes, g as AuthTokens, h as BackInStockSubscription, i as BadgeTone, j as BehioApiError, k as BehioErrorCode, l as BehioEventHandler, m as BehioEventType, n as BehioNetworkError, o as BehioStorefrontConfig, p as Bundle, q as BundleItem, r as Cart, s as CartBundleLine, t as CartBundleLineItem, u as CartDiscount, v as CartItem, w as CartItemProduct, x as CartPromotion, y as Category, z as CategoryDetail, D as CertificateVerification, E as CheckoutAddress, F as CheckoutInput, G as CheckoutPaymentMethod, H as CheckoutSettings, I as CookieConsentInput, J as CourseAttachment, K as CourseCertificate, L as CourseComment, M as CourseCommentReply, N as CourseCommentsList, O as CourseDetail, Q as CourseLesson, R as CourseListItem, T as CourseModule, U as CoursePostedComment, V as CourseProgress, W as CourseTutorMessage, X as CourseTutorThread, Y as CrossSellItem, Z as CustomerAddress, _ as CustomerProfile, $ as DigitalDownload, a0 as DownloadUrl, a1 as Facet, a2 as FacetAvailability, a3 as FacetCategory, a4 as FacetLabel, a5 as FacetPriceRange, a6 as FacetRange, a7 as FacetRatingBucket, a8 as FacetValue, a9 as FacetsResponse, aa as FilterField, ab as FulfillmentStatus, ac as FulfillmentStatuses, ad as GiftCardBalance, ae as GiftCardPurchaseInput, af as GiftCardPurchaseResult, ag as GiftCardSummary, ah as LessonNote, ai as LessonQuiz, aj as LoginInput, ak as LoyaltyBalance, al as LoyaltyNextTier, am as LoyaltyProgram, an as LoyaltySummary, ao as LoyaltyTier, ap as LoyaltyTierPerks, aq as LoyaltyTransaction, ar as Menu, as as MenuItem, at as MenuItemRef, au as MenuItemType, av as MessageResponse, aw as NewsletterOptInDefault, ax as NewsletterSubscribeInput, ay as NewsletterSubscribeResult, az as NewsletterUnsubscribeResult, aA as OrderAccessRequestResponse, aB as OrderAccessVerifyResponse, aC as OrderDetail, aD as OrderItem, aE as OrderListItem, aF as OrderStatus, aG as OrderStatusHistory, aH as OrderStatuses, aI as OrderTracking, aJ as Page, aK as PageAttachment, aL as PageDetail, aM as PaginatedResponse, aN as PaymentStatus, aO as PaymentStatuses, aP as PickupPoint, aQ as PickupPointHours, aR as PickupPointsInput, aS as PriceDisplay, aT as ProductAvailability, aU as ProductGroup, aV as ProductLabel, aW as ProductListItem, aX as ProductMedia, aY as ProductMediaVariant, aZ as ProductParameter, a_ as ProductParameterGroup, a$ as ProductParametersResponse, b0 as ProductPrice, b1 as ProductPromotionSummary, b2 as ProductReview, b3 as ProductReviewsResponse, b4 as ProductSibling, b5 as ProductSort, b6 as ProductSortValue, b7 as ProductVolumePrice, b8 as ProductsQuery, b9 as QuizAnswerInput, ba as QuizAnswerResult, bb as QuizQuestion, bc as QuizResult, bd as QuoteItem, be as QuoteRequest, bf as RegisterInput, bg as RegisterResult, bh as RequestInterceptor, bi as RequestInterceptorConfig, bj as ResponseInterceptor, bk as ResponseInterceptorData, bl as ReturnRequest, bm as ReturnRequestItem, bn as ReturnStatus, bo as ReturnStatusItem, bp as ReturnableOrder, bq as ReturnableOrderItem, br as SdkError, bs as ShippingMethodSummary, bt as ShippingQuote, bu as ShippingQuoteInput, bv as ShopInfo, bw as ShopScript, bx as ShopScriptPlacement, by as ShopScriptType, bz as ShopScripts, bA as ShopSeo, bB as ShopSeoIdentity, bC as Sitemap, bD as SitemapEntry, bE as StockBehavior, bF as StockMode, bG as SubmitQuoteInput, bH as SubmitReturnInput, bI as SubmitReviewInput, bJ as Subscription, bK as SubscriptionAction, bL as SubscriptionFrequency, bM as SubscriptionItem, bN as SubscriptionStatus, bO as TaxBreakdownLine, bP as VariantAxis, bQ as VariantAxisValue, bR as WishlistItem, bS as err, bT as ok, bU as toSdkError } from './client-LetSVGM1.js';
1
+ import { P as ProductDetail, a as ProductVariant, B as BehioStorefront, S as SdkResult, C as CookieConsent } from './client-B9jHeWca.js';
2
+ export { A as ActivePromotion, b as AddToCartInput, c as AddressDetail, d as AddressSuggestion, e as AddressType, f as AddressTypes, g as AuthTokens, h as BackInStockSubscription, i as BadgeTone, j as BehioApiError, k as BehioErrorCode, l as BehioEventHandler, m as BehioEventType, n as BehioNetworkError, o as BehioStorefrontConfig, p as Bundle, q as BundleItem, r as Cart, s as CartBundleLine, t as CartBundleLineItem, u as CartDiscount, v as CartItem, w as CartItemProduct, x as CartPromotion, y as Category, z as CategoryDetail, D as CertificateVerification, E as CheckoutAddress, F as CheckoutInput, G as CheckoutPaymentMethod, H as CheckoutSettings, I as CookieConsentInput, J as CourseAttachment, K as CourseCertificate, L as CourseComment, M as CourseCommentReply, N as CourseCommentsList, O as CourseDetail, Q as CourseLesson, R as CourseListItem, T as CourseModule, U as CoursePostedComment, V as CourseProgress, W as CourseTutorMessage, X as CourseTutorThread, Y as CrossSellItem, Z as CustomerAddress, _ as CustomerProfile, $ as DigitalDownload, a0 as DownloadUrl, a1 as Facet, a2 as FacetAvailability, a3 as FacetCategory, a4 as FacetLabel, a5 as FacetPriceRange, a6 as FacetRange, a7 as FacetRatingBucket, a8 as FacetValue, a9 as FacetsResponse, aa as FilterField, ab as FulfillmentStatus, ac as FulfillmentStatuses, ad as GiftCardBalance, ae as GiftCardPurchaseInput, af as GiftCardPurchaseResult, ag as GiftCardSummary, ah as LessonNote, ai as LessonQuiz, aj as LoginInput, ak as LoyaltyBalance, al as LoyaltyNextTier, am as LoyaltyProgram, an as LoyaltySummary, ao as LoyaltyTier, ap as LoyaltyTierPerks, aq as LoyaltyTransaction, ar as Menu, as as MenuItem, at as MenuItemRef, au as MenuItemType, av as MessageResponse, aw as NewsletterOptInDefault, ax as NewsletterSubscribeInput, ay as NewsletterSubscribeResult, az as NewsletterUnsubscribeResult, aA as OrderAccessRequestResponse, aB as OrderAccessVerifyResponse, aC as OrderDetail, aD as OrderItem, aE as OrderListItem, aF as OrderStatus, aG as OrderStatusHistory, aH as OrderStatuses, aI as OrderTracking, aJ as Page, aK as PageAttachment, aL as PageDetail, aM as PaginatedResponse, aN as PaymentStatus, aO as PaymentStatuses, aP as PickupPoint, aQ as PickupPointHours, aR as PickupPointsInput, aS as PriceDisplay, aT as ProductAvailability, aU as ProductGroup, aV as ProductLabel, aW as ProductListItem, aX as ProductMedia, aY as ProductMediaVariant, aZ as ProductParameter, a_ as ProductParameterGroup, a$ as ProductParametersResponse, b0 as ProductPrice, b1 as ProductPromotionSummary, b2 as ProductReview, b3 as ProductReviewsResponse, b4 as ProductSibling, b5 as ProductSort, b6 as ProductSortValue, b7 as ProductVolumePrice, b8 as ProductsQuery, b9 as QuizAnswerInput, ba as QuizAnswerResult, bb as QuizQuestion, bc as QuizResult, bd as QuoteItem, be as QuoteRequest, bf as RegisterInput, bg as RegisterResult, bh as RequestInterceptor, bi as RequestInterceptorConfig, bj as ResponseInterceptor, bk as ResponseInterceptorData, bl as ReturnRequest, bm as ReturnRequestItem, bn as ReturnStatus, bo as ReturnStatusItem, bp as ReturnableOrder, bq as ReturnableOrderItem, br as SdkError, bs as ShippingMethodSummary, bt as ShippingQuote, bu as ShippingQuoteInput, bv as ShopInfo, bw as ShopScript, bx as ShopScriptPlacement, by as ShopScriptType, bz as ShopScripts, bA as ShopSeo, bB as ShopSeoIdentity, bC as Sitemap, bD as SitemapEntry, bE as StockBehavior, bF as StockMode, bG as SubmitQuoteInput, bH as SubmitReturnInput, bI as SubmitReviewInput, bJ as Subscription, bK as SubscriptionAction, bL as SubscriptionFrequency, bM as SubscriptionItem, bN as SubscriptionStatus, bO as TaxBreakdownLine, bP as VariantAxis, bQ as VariantAxisValue, bR as WishlistItem, bS as err, bT as ok, bU as toSdkError } from './client-B9jHeWca.js';
3
3
 
4
4
  /**
5
5
  * Format a price amount with currency using Intl.NumberFormat.
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
 
12
12
 
13
- var _chunkOQK7PQYJjs = require('./chunk-OQK7PQYJ.js');
13
+ var _chunkTJ4TZ5FIjs = require('./chunk-TJ4TZ5FI.js');
14
14
 
15
15
  // src/react/utils/format-price.ts
16
16
  function formatPrice(amount, currency, locale) {
@@ -243,4 +243,4 @@ async function revokeAnalyticsConsent(client) {
243
243
 
244
244
 
245
245
 
246
- exports.AddressTypes = _chunkOQK7PQYJjs.AddressTypes; exports.BehioApiError = _chunkOQK7PQYJjs.BehioApiError; exports.BehioNetworkError = _chunkOQK7PQYJjs.BehioNetworkError; exports.BehioStorefront = _chunkOQK7PQYJjs.BehioStorefront; exports.FulfillmentStatuses = _chunkOQK7PQYJjs.FulfillmentStatuses; exports.OrderStatuses = _chunkOQK7PQYJjs.OrderStatuses; exports.PaymentStatuses = _chunkOQK7PQYJjs.PaymentStatuses; exports.ProductSort = _chunkOQK7PQYJjs.ProductSort; exports.VARIANT_QUERY_PARAM = VARIANT_QUERY_PARAM; exports.availableAxisValues = availableAxisValues; exports.buildVariantComparison = buildVariantComparison; exports.err = _chunkOQK7PQYJjs.err; exports.findVariantByAttributes = findVariantByAttributes; exports.formatPrice = formatPrice; exports.generateVisitorId = generateVisitorId; exports.getStoredVisitorId = getStoredVisitorId; exports.grantAnalyticsConsent = grantAnalyticsConsent; exports.ok = _chunkOQK7PQYJjs.ok; exports.resolveVariantContent = resolveVariantContent; exports.revokeAnalyticsConsent = revokeAnalyticsConsent; exports.toSdkError = _chunkOQK7PQYJjs.toSdkError; exports.trackEcommerceEvent = trackEcommerceEvent; exports.variantFromQuery = variantFromQuery; exports.variantHref = variantHref;
246
+ exports.AddressTypes = _chunkTJ4TZ5FIjs.AddressTypes; exports.BehioApiError = _chunkTJ4TZ5FIjs.BehioApiError; exports.BehioNetworkError = _chunkTJ4TZ5FIjs.BehioNetworkError; exports.BehioStorefront = _chunkTJ4TZ5FIjs.BehioStorefront; exports.FulfillmentStatuses = _chunkTJ4TZ5FIjs.FulfillmentStatuses; exports.OrderStatuses = _chunkTJ4TZ5FIjs.OrderStatuses; exports.PaymentStatuses = _chunkTJ4TZ5FIjs.PaymentStatuses; exports.ProductSort = _chunkTJ4TZ5FIjs.ProductSort; exports.VARIANT_QUERY_PARAM = VARIANT_QUERY_PARAM; exports.availableAxisValues = availableAxisValues; exports.buildVariantComparison = buildVariantComparison; exports.err = _chunkTJ4TZ5FIjs.err; exports.findVariantByAttributes = findVariantByAttributes; exports.formatPrice = formatPrice; exports.generateVisitorId = generateVisitorId; exports.getStoredVisitorId = getStoredVisitorId; exports.grantAnalyticsConsent = grantAnalyticsConsent; exports.ok = _chunkTJ4TZ5FIjs.ok; exports.resolveVariantContent = resolveVariantContent; exports.revokeAnalyticsConsent = revokeAnalyticsConsent; exports.toSdkError = _chunkTJ4TZ5FIjs.toSdkError; exports.trackEcommerceEvent = trackEcommerceEvent; exports.variantFromQuery = variantFromQuery; exports.variantHref = variantHref;
package/dist/index.mjs CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  err,
11
11
  ok,
12
12
  toSdkError
13
- } from "./chunk-7CFBSRUZ.mjs";
13
+ } from "./chunk-TOSF3K7J.mjs";
14
14
 
15
15
  // src/react/utils/format-price.ts
16
16
  function formatPrice(amount, currency, locale) {
package/dist/next.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { o as BehioStorefrontConfig, B as BehioStorefront } from './client-LetSVGM1.mjs';
1
+ import { o as BehioStorefrontConfig, B as BehioStorefront } from './client-B9jHeWca.mjs';
2
2
 
3
3
  interface GetBehioOptions extends Partial<BehioStorefrontConfig> {
4
4
  /** Override the cart session cookie name (default: "behio_cart_session"). */
package/dist/next.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { o as BehioStorefrontConfig, B as BehioStorefront } from './client-LetSVGM1.js';
1
+ import { o as BehioStorefrontConfig, B as BehioStorefront } from './client-B9jHeWca.js';
2
2
 
3
3
  interface GetBehioOptions extends Partial<BehioStorefrontConfig> {
4
4
  /** Override the cart session cookie name (default: "behio_cart_session"). */
package/dist/next.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkOQK7PQYJjs = require('./chunk-OQK7PQYJ.js');
3
+ var _chunkTJ4TZ5FIjs = require('./chunk-TJ4TZ5FI.js');
4
4
 
5
5
  // src/next.ts
6
6
  var _headers = require('next/headers');
@@ -18,7 +18,7 @@ async function getBehio(options = {}) {
18
18
  const locale = _nullishCoalesce(options.locale, () => ( process.env.BEHIO_LOCALE));
19
19
  const currency = _nullishCoalesce(options.currency, () => ( process.env.BEHIO_CURRENCY));
20
20
  const cookieName = _nullishCoalesce(options.cartCookieName, () => ( CART_COOKIE_NAME));
21
- const client = new (0, _chunkOQK7PQYJjs.BehioStorefront)({
21
+ const client = new (0, _chunkTJ4TZ5FIjs.BehioStorefront)({
22
22
  apiKey,
23
23
  ...baseUrl ? { baseUrl } : {},
24
24
  ...locale ? { locale } : {},
package/dist/next.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BehioStorefront
3
- } from "./chunk-7CFBSRUZ.mjs";
3
+ } from "./chunk-TOSF3K7J.mjs";
4
4
 
5
5
  // src/next.ts
6
6
  import { cookies, headers } from "next/headers";
package/dist/react.d.mts CHANGED
@@ -2660,6 +2660,22 @@ declare class CartModule {
2660
2660
  addItem(input: AddToCartInput): Promise<SdkResult<Cart & {
2661
2661
  newSessionToken?: string;
2662
2662
  }>>;
2663
+ /**
2664
+ * Switch the CART currency server-side. The backend re-prices every line in
2665
+ * the new currency (no FX conversion: a product must have a price configured
2666
+ * in that currency, otherwise the call fails with 400 listing the items and
2667
+ * the cart stays unchanged). Creates an empty cart in that currency when
2668
+ * none exists yet.
2669
+ *
2670
+ * This is the money-path counterpart of `client.setCurrency()` (which only
2671
+ * affects catalog display). Call BOTH from a currency switcher:
2672
+ *
2673
+ * ```ts
2674
+ * client.setCurrency("EUR"); // catalog prices
2675
+ * await client.cart.setCurrency("EUR"); // cart + checkout prices
2676
+ * ```
2677
+ */
2678
+ setCurrency(currency: string): Promise<SdkResult<Cart>>;
2663
2679
  /** Update item quantity */
2664
2680
  updateQuantity(itemId: string, quantity: number): Promise<SdkResult<Cart>>;
2665
2681
  /** Remove item from cart */
package/dist/react.d.ts CHANGED
@@ -2660,6 +2660,22 @@ declare class CartModule {
2660
2660
  addItem(input: AddToCartInput): Promise<SdkResult<Cart & {
2661
2661
  newSessionToken?: string;
2662
2662
  }>>;
2663
+ /**
2664
+ * Switch the CART currency server-side. The backend re-prices every line in
2665
+ * the new currency (no FX conversion: a product must have a price configured
2666
+ * in that currency, otherwise the call fails with 400 listing the items and
2667
+ * the cart stays unchanged). Creates an empty cart in that currency when
2668
+ * none exists yet.
2669
+ *
2670
+ * This is the money-path counterpart of `client.setCurrency()` (which only
2671
+ * affects catalog display). Call BOTH from a currency switcher:
2672
+ *
2673
+ * ```ts
2674
+ * client.setCurrency("EUR"); // catalog prices
2675
+ * await client.cart.setCurrency("EUR"); // cart + checkout prices
2676
+ * ```
2677
+ */
2678
+ setCurrency(currency: string): Promise<SdkResult<Cart>>;
2663
2679
  /** Update item quantity */
2664
2680
  updateQuantity(itemId: string, quantity: number): Promise<SdkResult<Cart>>;
2665
2681
  /** Remove item from cart */
package/dist/react.js CHANGED
@@ -1044,6 +1044,29 @@ var CartModule = class {
1044
1044
  this.client.emit("cart:updated", res.data);
1045
1045
  return res;
1046
1046
  }
1047
+ /**
1048
+ * Switch the CART currency server-side. The backend re-prices every line in
1049
+ * the new currency (no FX conversion: a product must have a price configured
1050
+ * in that currency, otherwise the call fails with 400 listing the items and
1051
+ * the cart stays unchanged). Creates an empty cart in that currency when
1052
+ * none exists yet.
1053
+ *
1054
+ * This is the money-path counterpart of `client.setCurrency()` (which only
1055
+ * affects catalog display). Call BOTH from a currency switcher:
1056
+ *
1057
+ * ```ts
1058
+ * client.setCurrency("EUR"); // catalog prices
1059
+ * await client.cart.setCurrency("EUR"); // cart + checkout prices
1060
+ * ```
1061
+ */
1062
+ async setCurrency(currency) {
1063
+ const res = await this.client.request("PUT", "/cart/currency", {
1064
+ body: { currency }
1065
+ });
1066
+ if (res.error) return res;
1067
+ this.client.emit("cart:updated", res.data);
1068
+ return res;
1069
+ }
1047
1070
  /** Update item quantity */
1048
1071
  async updateQuantity(itemId, quantity) {
1049
1072
  const res = await this.client.request(
@@ -2042,9 +2065,16 @@ function BehioProvider({
2042
2065
  else cookieStorage.remove(currencyCookieName);
2043
2066
  }
2044
2067
  onCurrencyChange?.(next);
2045
- void qc.invalidateQueries({ queryKey: ["behio"] });
2068
+ const cartTarget = next ?? defaultCurrency;
2069
+ if (cartTarget && (client.getCartSession() || client.auth.isLoggedIn())) {
2070
+ void client.cart.setCurrency(cartTarget).finally(() => {
2071
+ void qc.invalidateQueries({ queryKey: ["behio"] });
2072
+ });
2073
+ } else {
2074
+ void qc.invalidateQueries({ queryKey: ["behio"] });
2075
+ }
2046
2076
  },
2047
- [client, qc, persistCurrency, currencyCookieName, onCurrencyChange]
2077
+ [client, qc, persistCurrency, currencyCookieName, onCurrencyChange, defaultCurrency]
2048
2078
  );
2049
2079
  const ctxValue = (0, import_react2.useMemo)(
2050
2080
  () => ({
package/dist/react.mjs CHANGED
@@ -941,6 +941,29 @@ var CartModule = class {
941
941
  this.client.emit("cart:updated", res.data);
942
942
  return res;
943
943
  }
944
+ /**
945
+ * Switch the CART currency server-side. The backend re-prices every line in
946
+ * the new currency (no FX conversion: a product must have a price configured
947
+ * in that currency, otherwise the call fails with 400 listing the items and
948
+ * the cart stays unchanged). Creates an empty cart in that currency when
949
+ * none exists yet.
950
+ *
951
+ * This is the money-path counterpart of `client.setCurrency()` (which only
952
+ * affects catalog display). Call BOTH from a currency switcher:
953
+ *
954
+ * ```ts
955
+ * client.setCurrency("EUR"); // catalog prices
956
+ * await client.cart.setCurrency("EUR"); // cart + checkout prices
957
+ * ```
958
+ */
959
+ async setCurrency(currency) {
960
+ const res = await this.client.request("PUT", "/cart/currency", {
961
+ body: { currency }
962
+ });
963
+ if (res.error) return res;
964
+ this.client.emit("cart:updated", res.data);
965
+ return res;
966
+ }
944
967
  /** Update item quantity */
945
968
  async updateQuantity(itemId, quantity) {
946
969
  const res = await this.client.request(
@@ -1939,9 +1962,16 @@ function BehioProvider({
1939
1962
  else cookieStorage.remove(currencyCookieName);
1940
1963
  }
1941
1964
  onCurrencyChange?.(next);
1942
- void qc.invalidateQueries({ queryKey: ["behio"] });
1965
+ const cartTarget = next ?? defaultCurrency;
1966
+ if (cartTarget && (client.getCartSession() || client.auth.isLoggedIn())) {
1967
+ void client.cart.setCurrency(cartTarget).finally(() => {
1968
+ void qc.invalidateQueries({ queryKey: ["behio"] });
1969
+ });
1970
+ } else {
1971
+ void qc.invalidateQueries({ queryKey: ["behio"] });
1972
+ }
1943
1973
  },
1944
- [client, qc, persistCurrency, currencyCookieName, onCurrencyChange]
1974
+ [client, qc, persistCurrency, currencyCookieName, onCurrencyChange, defaultCurrency]
1945
1975
  );
1946
1976
  const ctxValue = useMemo(
1947
1977
  () => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@behio/storefront-sdk",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "TypeScript SDK for Behio Headless E-Shop — core client + React hooks",
5
5
  "author": "Behio",
6
6
  "license": "MIT",