@behio/storefront-sdk 2.27.0 → 2.28.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.
@@ -1184,13 +1184,19 @@ var CartModule = class {
1184
1184
  /** Add the complete selection atomically. Invalid/unavailable lines leave the cart unchanged. */
1185
1185
  async addItems(input) {
1186
1186
  const res = await this.client.request("POST", "/cart/items/batch", {
1187
- body: { items: input.items.map((item) => ({ productId: item.productId, quantity: item.quantity })) }
1187
+ body: { items: input.items.map((item) => ({ productId: item.productId, quantity: item.quantity, ...item.assignToProductId ? { assignToProductId: item.assignToProductId } : {} })) }
1188
1188
  });
1189
1189
  if (res.error) return res;
1190
1190
  if (res.data.newSessionToken) this.client.setCartSession(res.data.newSessionToken);
1191
1191
  this.client.emit("cart:updated", res.data);
1192
1192
  return res;
1193
1193
  }
1194
+ /** Idempotent selection of one extra package for a particular main cart line. */
1195
+ async setAddon(itemId, productId, selected) {
1196
+ const res = await this.client.request("PUT", `/cart/items/${encodeURIComponent(itemId)}/addons/${encodeURIComponent(productId)}`, { body: { selected } });
1197
+ if (!res.error) this.client.emit("cart:updated", res.data);
1198
+ return res;
1199
+ }
1194
1200
  /**
1195
1201
  * Switch the CART currency server-side. The backend re-prices every line in
1196
1202
  * the new currency (no FX conversion: a product must have a price configured
@@ -1184,13 +1184,19 @@ var CartModule = class {
1184
1184
  /** Add the complete selection atomically. Invalid/unavailable lines leave the cart unchanged. */
1185
1185
  async addItems(input) {
1186
1186
  const res = await this.client.request("POST", "/cart/items/batch", {
1187
- body: { items: input.items.map((item) => ({ productId: item.productId, quantity: item.quantity })) }
1187
+ body: { items: input.items.map((item) => ({ productId: item.productId, quantity: item.quantity, ...item.assignToProductId ? { assignToProductId: item.assignToProductId } : {} })) }
1188
1188
  });
1189
1189
  if (res.error) return res;
1190
1190
  if (res.data.newSessionToken) this.client.setCartSession(res.data.newSessionToken);
1191
1191
  this.client.emit("cart:updated", res.data);
1192
1192
  return res;
1193
1193
  }
1194
+ /** Idempotent selection of one extra package for a particular main cart line. */
1195
+ async setAddon(itemId, productId, selected) {
1196
+ const res = await this.client.request("PUT", `/cart/items/${encodeURIComponent(itemId)}/addons/${encodeURIComponent(productId)}`, { body: { selected } });
1197
+ if (!res.error) this.client.emit("cart:updated", res.data);
1198
+ return res;
1199
+ }
1194
1200
  /**
1195
1201
  * Switch the CART currency server-side. The backend re-prices every line in
1196
1202
  * the new currency (no FX conversion: a product must have a price configured
@@ -1370,6 +1370,11 @@ interface CartItemProduct {
1370
1370
  orderQuantityStep?: number | null;
1371
1371
  }
1372
1372
  interface CartItem {
1373
+ /** Extras allocated to this exact main cart line. Older servers omit it. */
1374
+ addonSelections?: Array<{
1375
+ productId: string;
1376
+ quantity: number;
1377
+ }>;
1373
1378
  id: string;
1374
1379
  /** A retained row can be unavailable after the merchant changes its offer. */
1375
1380
  isPurchasable: boolean;
@@ -1558,7 +1563,9 @@ interface GiftCardSummary {
1558
1563
  }
1559
1564
  /** Atomic multi-product purchase; every product is validated before any line changes. */
1560
1565
  interface AddToCartItemsInput {
1561
- items: AddToCartInput[];
1566
+ items: Array<AddToCartInput & {
1567
+ assignToProductId?: string;
1568
+ }>;
1562
1569
  }
1563
1570
  interface AddToCartInput {
1564
1571
  /**
@@ -3981,6 +3988,8 @@ declare class CartModule {
3981
3988
  addItems(input: AddToCartItemsInput): Promise<SdkResult<Cart & {
3982
3989
  newSessionToken?: string;
3983
3990
  }>>;
3991
+ /** Idempotent selection of one extra package for a particular main cart line. */
3992
+ setAddon(itemId: string, productId: string, selected: boolean): Promise<SdkResult<Cart>>;
3984
3993
  /**
3985
3994
  * Switch the CART currency server-side. The backend re-prices every line in
3986
3995
  * the new currency (no FX conversion: a product must have a price configured
@@ -1370,6 +1370,11 @@ interface CartItemProduct {
1370
1370
  orderQuantityStep?: number | null;
1371
1371
  }
1372
1372
  interface CartItem {
1373
+ /** Extras allocated to this exact main cart line. Older servers omit it. */
1374
+ addonSelections?: Array<{
1375
+ productId: string;
1376
+ quantity: number;
1377
+ }>;
1373
1378
  id: string;
1374
1379
  /** A retained row can be unavailable after the merchant changes its offer. */
1375
1380
  isPurchasable: boolean;
@@ -1558,7 +1563,9 @@ interface GiftCardSummary {
1558
1563
  }
1559
1564
  /** Atomic multi-product purchase; every product is validated before any line changes. */
1560
1565
  interface AddToCartItemsInput {
1561
- items: AddToCartInput[];
1566
+ items: Array<AddToCartInput & {
1567
+ assignToProductId?: string;
1568
+ }>;
1562
1569
  }
1563
1570
  interface AddToCartInput {
1564
1571
  /**
@@ -3981,6 +3988,8 @@ declare class CartModule {
3981
3988
  addItems(input: AddToCartItemsInput): Promise<SdkResult<Cart & {
3982
3989
  newSessionToken?: string;
3983
3990
  }>>;
3991
+ /** Idempotent selection of one extra package for a particular main cart line. */
3992
+ setAddon(itemId: string, productId: string, selected: boolean): Promise<SdkResult<Cart>>;
3984
3993
  /**
3985
3994
  * Switch the CART currency server-side. The backend re-prices every line in
3986
3995
  * the new currency (no FX conversion: a product must have a price configured
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, b as StorefrontFormFieldError } from './client-EjtvqiPK.mjs';
2
- export { A as ActivePromotion, c as AddToCartInput, d as AddToCartItemsInput, e as AddressDetail, f as AddressSuggestion, g as AddressType, h as AddressTypes, i as AuthTokens, j as BackInStockSubscription, k as BadgeTone, l as BehioApiError, m as BehioErrorCode, n as BehioEventHandler, o as BehioEventType, p as BehioNetworkError, q as BehioStorefrontConfig, r as Blog, s as BlogPostDetail, t as BlogPostListItem, u as BlogPostsPage, v as BlogPostsQuery, w as BlogSettings, x as BlogTag, y as Booking, z as BookingCategory, D as BookingConfig, E as BookingCreateInput, F as BookingCreated, G as BookingLocale, H as BookingLocation, I as BookingManageSlotsQuery, J as BookingService, K as BookingSlot, L as BookingSlots, M as BookingSlotsQuery, N as BookingStaff, O as BookingStatus, Q as Bundle, R as BundleCatalogQuery, T as BundleItem, U as Cart, V as CartBundleLine, W as CartBundleLineItem, X as CartDiscount, Y as CartItem, Z as CartItemProduct, _ as CartLinkClaimed, $ as CartPromotion, a0 as CartSummaryEvent, a1 as Category, a2 as CategoryDetail, a3 as CertificateVerification, a4 as CheckoutAddress, a5 as CheckoutInput, a6 as CheckoutPaymentMethod, a7 as CheckoutPreview, a8 as CheckoutResult, a9 as CheckoutSettings, aa as CookieConsentInput, ab as CourseAttachment, ac as CourseCertificate, ad as CourseComment, ae as CourseCommentReply, af as CourseCommentsList, ag as CourseDetail, ah as CourseLesson, ai as CourseListItem, aj as CourseModule, ak as CoursePostedComment, al as CourseProgress, am as CourseTutorMessage, an as CourseTutorThread, ao as CrossSellItem, ap as CurrencyDisplayFormat, aq as CustomerAddress, ar as CustomerBadge, as as CustomerChallenge, at as CustomerGamification, au as CustomerGamificationQuery, av as CustomerProfile, aw as DigitalDownload, ax as DownloadUrl, ay as Facet, az as FacetAvailability, aA as FacetCategory, aB as FacetLabel, aC as FacetPriceRange, aD as FacetRange, aE as FacetRatingBucket, aF as FacetValue, aG as FacetsResponse, aH as FilterField, aI as FulfillmentStatus, aJ as FulfillmentStatuses, aK as GamificationRefreshResult, aL as GiftCardBalance, aM as GiftCardPurchaseInput, aN as GiftCardPurchaseResult, aO as GiftCardSummary, aP as LessonNote, aQ as LessonQuiz, aR as LoginInput, aS as LoyaltyBalance, aT as LoyaltyNextTier, aU as LoyaltyProgram, aV as LoyaltyQuery, aW as LoyaltyReferralResult, aX as LoyaltySummary, aY as LoyaltyTier, aZ as LoyaltyTierPerks, a_ as LoyaltyTransaction, a$ as Menu, b0 as MenuItem, b1 as MenuItemRef, b2 as MenuItemType, b3 as MessageResponse, b4 as NewsletterOptInDefault, b5 as NewsletterSubscribeInput, b6 as NewsletterSubscribeResult, b7 as NewsletterUnsubscribeResult, b8 as OrderAccessRequestResponse, b9 as OrderAccessVerifyResponse, ba as OrderDetail, bb as OrderDiscount, bc as OrderDocument, bd as OrderItem, be as OrderListItem, bf as OrderPaymentInstructions, bg as OrderPickupPoint, bh as OrderShipment, bi as OrderStatus, bj as OrderStatusHistory, bk as OrderStatuses, bl as OrderTracking, bm as Page, bn as PageAttachment, bo as PageDetail, bp as PaginatedResponse, bq as PaymentInstrument, br as PaymentStatus, bs as PaymentStatuses, bt as PaymentSwift, bu as PickupPoint, bv as PickupPointHours, bw as PickupPointsInput, bx as PickupWidgetConfig, by as PriceDisplay, bz as ProductAssetGroup, bA as ProductAssetItem, bB as ProductAvailability, bC as ProductGroup, bD as ProductLabel, bE as ProductListItem, bF as ProductMedia, bG as ProductMediaVariant, bH as ProductParameter, bI as ProductParameterGroup, bJ as ProductParametersResponse, bK as ProductPrice, bL as ProductPromotionSummary, bM as ProductReview, bN as ProductReviewsResponse, bO as ProductSibling, bP as ProductSort, bQ as ProductSortValue, bR as ProductVolumePrice, bS as ProductsQuery, bT as QuizAnswerInput, bU as QuizAnswerResult, bV as QuizQuestion, bW as QuizResult, bX as QuoteItem, bY as QuoteRequest, bZ as RegisterInput, b_ as RegisterResult, b$ as RequestInterceptor, c0 as RequestInterceptorConfig, c1 as ResponseInterceptor, c2 as ResponseInterceptorData, c3 as ReturnRequest, c4 as ReturnRequestItem, c5 as ReturnStatus, c6 as ReturnStatusItem, c7 as ReturnableOrder, c8 as ReturnableOrderItem, c9 as SdkError, ca as ShippingMethodSummary, cb as ShippingPublicConfig, cc as ShippingQuote, cd as ShippingQuoteInput, ce as ShopAppearance, cf as ShopCommerce, cg as ShopInfo, ch as ShopScript, ci as ShopScriptPlacement, cj as ShopScriptType, ck as ShopScripts, cl as ShopSeo, cm as ShopSeoIdentity, cn as SiteFormField, co as SiteFormFieldOption, cp as SiteFormFieldType, cq as Sitemap, cr as SitemapEntry, cs as StockBehavior, ct as StockMode, cu as StorefrontCollection, cv as StorefrontCollectionField, cw as StorefrontCollectionFieldType, cx as StorefrontCollectionItem, cy as StorefrontCollectionQuery, cz as StorefrontFaqGroup, cA as StorefrontFaqGroupSummary, cB as StorefrontFaqGroups, cC as StorefrontFaqItem, cD as StorefrontFaqQuery, cE as StorefrontForm, cF as StorefrontFormFieldErrorCode, cG as StorefrontFormFile, cH as StorefrontFormSettings, cI as StorefrontFormSubmitInput, cJ as StorefrontFormSubmitResult, cK as StorefrontFormUpload, cL as SubmitQuoteInput, cM as SubmitReturnInput, cN as SubmitReviewInput, cO as SubmitWithdrawalInput, cP as Subscription, cQ as SubscriptionAction, cR as SubscriptionFrequency, cS as SubscriptionItem, cT as SubscriptionStatus, cU as TaxBreakdownLine, cV as VariantAxis, cW as VariantAxisValue, cX as WishlistItem, cY as WithdrawalAcknowledgement, cZ as WithdrawalFlag, c_ as WithdrawalSettings, c$ as WithdrawalWindow, d0 as clearCartSummary, d1 as err, d2 as ok, d3 as publishCartSummary, d4 as toSdkError } from './client-EjtvqiPK.mjs';
1
+ import { P as ProductDetail, a as ProductVariant, B as BehioStorefront, S as SdkResult, C as CookieConsent, b as StorefrontFormFieldError } from './client-Bm8Fwcp7.mjs';
2
+ export { A as ActivePromotion, c as AddToCartInput, d as AddToCartItemsInput, e as AddressDetail, f as AddressSuggestion, g as AddressType, h as AddressTypes, i as AuthTokens, j as BackInStockSubscription, k as BadgeTone, l as BehioApiError, m as BehioErrorCode, n as BehioEventHandler, o as BehioEventType, p as BehioNetworkError, q as BehioStorefrontConfig, r as Blog, s as BlogPostDetail, t as BlogPostListItem, u as BlogPostsPage, v as BlogPostsQuery, w as BlogSettings, x as BlogTag, y as Booking, z as BookingCategory, D as BookingConfig, E as BookingCreateInput, F as BookingCreated, G as BookingLocale, H as BookingLocation, I as BookingManageSlotsQuery, J as BookingService, K as BookingSlot, L as BookingSlots, M as BookingSlotsQuery, N as BookingStaff, O as BookingStatus, Q as Bundle, R as BundleCatalogQuery, T as BundleItem, U as Cart, V as CartBundleLine, W as CartBundleLineItem, X as CartDiscount, Y as CartItem, Z as CartItemProduct, _ as CartLinkClaimed, $ as CartPromotion, a0 as CartSummaryEvent, a1 as Category, a2 as CategoryDetail, a3 as CertificateVerification, a4 as CheckoutAddress, a5 as CheckoutInput, a6 as CheckoutPaymentMethod, a7 as CheckoutPreview, a8 as CheckoutResult, a9 as CheckoutSettings, aa as CookieConsentInput, ab as CourseAttachment, ac as CourseCertificate, ad as CourseComment, ae as CourseCommentReply, af as CourseCommentsList, ag as CourseDetail, ah as CourseLesson, ai as CourseListItem, aj as CourseModule, ak as CoursePostedComment, al as CourseProgress, am as CourseTutorMessage, an as CourseTutorThread, ao as CrossSellItem, ap as CurrencyDisplayFormat, aq as CustomerAddress, ar as CustomerBadge, as as CustomerChallenge, at as CustomerGamification, au as CustomerGamificationQuery, av as CustomerProfile, aw as DigitalDownload, ax as DownloadUrl, ay as Facet, az as FacetAvailability, aA as FacetCategory, aB as FacetLabel, aC as FacetPriceRange, aD as FacetRange, aE as FacetRatingBucket, aF as FacetValue, aG as FacetsResponse, aH as FilterField, aI as FulfillmentStatus, aJ as FulfillmentStatuses, aK as GamificationRefreshResult, aL as GiftCardBalance, aM as GiftCardPurchaseInput, aN as GiftCardPurchaseResult, aO as GiftCardSummary, aP as LessonNote, aQ as LessonQuiz, aR as LoginInput, aS as LoyaltyBalance, aT as LoyaltyNextTier, aU as LoyaltyProgram, aV as LoyaltyQuery, aW as LoyaltyReferralResult, aX as LoyaltySummary, aY as LoyaltyTier, aZ as LoyaltyTierPerks, a_ as LoyaltyTransaction, a$ as Menu, b0 as MenuItem, b1 as MenuItemRef, b2 as MenuItemType, b3 as MessageResponse, b4 as NewsletterOptInDefault, b5 as NewsletterSubscribeInput, b6 as NewsletterSubscribeResult, b7 as NewsletterUnsubscribeResult, b8 as OrderAccessRequestResponse, b9 as OrderAccessVerifyResponse, ba as OrderDetail, bb as OrderDiscount, bc as OrderDocument, bd as OrderItem, be as OrderListItem, bf as OrderPaymentInstructions, bg as OrderPickupPoint, bh as OrderShipment, bi as OrderStatus, bj as OrderStatusHistory, bk as OrderStatuses, bl as OrderTracking, bm as Page, bn as PageAttachment, bo as PageDetail, bp as PaginatedResponse, bq as PaymentInstrument, br as PaymentStatus, bs as PaymentStatuses, bt as PaymentSwift, bu as PickupPoint, bv as PickupPointHours, bw as PickupPointsInput, bx as PickupWidgetConfig, by as PriceDisplay, bz as ProductAssetGroup, bA as ProductAssetItem, bB as ProductAvailability, bC as ProductGroup, bD as ProductLabel, bE as ProductListItem, bF as ProductMedia, bG as ProductMediaVariant, bH as ProductParameter, bI as ProductParameterGroup, bJ as ProductParametersResponse, bK as ProductPrice, bL as ProductPromotionSummary, bM as ProductReview, bN as ProductReviewsResponse, bO as ProductSibling, bP as ProductSort, bQ as ProductSortValue, bR as ProductVolumePrice, bS as ProductsQuery, bT as QuizAnswerInput, bU as QuizAnswerResult, bV as QuizQuestion, bW as QuizResult, bX as QuoteItem, bY as QuoteRequest, bZ as RegisterInput, b_ as RegisterResult, b$ as RequestInterceptor, c0 as RequestInterceptorConfig, c1 as ResponseInterceptor, c2 as ResponseInterceptorData, c3 as ReturnRequest, c4 as ReturnRequestItem, c5 as ReturnStatus, c6 as ReturnStatusItem, c7 as ReturnableOrder, c8 as ReturnableOrderItem, c9 as SdkError, ca as ShippingMethodSummary, cb as ShippingPublicConfig, cc as ShippingQuote, cd as ShippingQuoteInput, ce as ShopAppearance, cf as ShopCommerce, cg as ShopInfo, ch as ShopScript, ci as ShopScriptPlacement, cj as ShopScriptType, ck as ShopScripts, cl as ShopSeo, cm as ShopSeoIdentity, cn as SiteFormField, co as SiteFormFieldOption, cp as SiteFormFieldType, cq as Sitemap, cr as SitemapEntry, cs as StockBehavior, ct as StockMode, cu as StorefrontCollection, cv as StorefrontCollectionField, cw as StorefrontCollectionFieldType, cx as StorefrontCollectionItem, cy as StorefrontCollectionQuery, cz as StorefrontFaqGroup, cA as StorefrontFaqGroupSummary, cB as StorefrontFaqGroups, cC as StorefrontFaqItem, cD as StorefrontFaqQuery, cE as StorefrontForm, cF as StorefrontFormFieldErrorCode, cG as StorefrontFormFile, cH as StorefrontFormSettings, cI as StorefrontFormSubmitInput, cJ as StorefrontFormSubmitResult, cK as StorefrontFormUpload, cL as SubmitQuoteInput, cM as SubmitReturnInput, cN as SubmitReviewInput, cO as SubmitWithdrawalInput, cP as Subscription, cQ as SubscriptionAction, cR as SubscriptionFrequency, cS as SubscriptionItem, cT as SubscriptionStatus, cU as TaxBreakdownLine, cV as VariantAxis, cW as VariantAxisValue, cX as WishlistItem, cY as WithdrawalAcknowledgement, cZ as WithdrawalFlag, c_ as WithdrawalSettings, c$ as WithdrawalWindow, d0 as clearCartSummary, d1 as err, d2 as ok, d3 as publishCartSummary, d4 as toSdkError } from './client-Bm8Fwcp7.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, b as StorefrontFormFieldError } from './client-EjtvqiPK.js';
2
- export { A as ActivePromotion, c as AddToCartInput, d as AddToCartItemsInput, e as AddressDetail, f as AddressSuggestion, g as AddressType, h as AddressTypes, i as AuthTokens, j as BackInStockSubscription, k as BadgeTone, l as BehioApiError, m as BehioErrorCode, n as BehioEventHandler, o as BehioEventType, p as BehioNetworkError, q as BehioStorefrontConfig, r as Blog, s as BlogPostDetail, t as BlogPostListItem, u as BlogPostsPage, v as BlogPostsQuery, w as BlogSettings, x as BlogTag, y as Booking, z as BookingCategory, D as BookingConfig, E as BookingCreateInput, F as BookingCreated, G as BookingLocale, H as BookingLocation, I as BookingManageSlotsQuery, J as BookingService, K as BookingSlot, L as BookingSlots, M as BookingSlotsQuery, N as BookingStaff, O as BookingStatus, Q as Bundle, R as BundleCatalogQuery, T as BundleItem, U as Cart, V as CartBundleLine, W as CartBundleLineItem, X as CartDiscount, Y as CartItem, Z as CartItemProduct, _ as CartLinkClaimed, $ as CartPromotion, a0 as CartSummaryEvent, a1 as Category, a2 as CategoryDetail, a3 as CertificateVerification, a4 as CheckoutAddress, a5 as CheckoutInput, a6 as CheckoutPaymentMethod, a7 as CheckoutPreview, a8 as CheckoutResult, a9 as CheckoutSettings, aa as CookieConsentInput, ab as CourseAttachment, ac as CourseCertificate, ad as CourseComment, ae as CourseCommentReply, af as CourseCommentsList, ag as CourseDetail, ah as CourseLesson, ai as CourseListItem, aj as CourseModule, ak as CoursePostedComment, al as CourseProgress, am as CourseTutorMessage, an as CourseTutorThread, ao as CrossSellItem, ap as CurrencyDisplayFormat, aq as CustomerAddress, ar as CustomerBadge, as as CustomerChallenge, at as CustomerGamification, au as CustomerGamificationQuery, av as CustomerProfile, aw as DigitalDownload, ax as DownloadUrl, ay as Facet, az as FacetAvailability, aA as FacetCategory, aB as FacetLabel, aC as FacetPriceRange, aD as FacetRange, aE as FacetRatingBucket, aF as FacetValue, aG as FacetsResponse, aH as FilterField, aI as FulfillmentStatus, aJ as FulfillmentStatuses, aK as GamificationRefreshResult, aL as GiftCardBalance, aM as GiftCardPurchaseInput, aN as GiftCardPurchaseResult, aO as GiftCardSummary, aP as LessonNote, aQ as LessonQuiz, aR as LoginInput, aS as LoyaltyBalance, aT as LoyaltyNextTier, aU as LoyaltyProgram, aV as LoyaltyQuery, aW as LoyaltyReferralResult, aX as LoyaltySummary, aY as LoyaltyTier, aZ as LoyaltyTierPerks, a_ as LoyaltyTransaction, a$ as Menu, b0 as MenuItem, b1 as MenuItemRef, b2 as MenuItemType, b3 as MessageResponse, b4 as NewsletterOptInDefault, b5 as NewsletterSubscribeInput, b6 as NewsletterSubscribeResult, b7 as NewsletterUnsubscribeResult, b8 as OrderAccessRequestResponse, b9 as OrderAccessVerifyResponse, ba as OrderDetail, bb as OrderDiscount, bc as OrderDocument, bd as OrderItem, be as OrderListItem, bf as OrderPaymentInstructions, bg as OrderPickupPoint, bh as OrderShipment, bi as OrderStatus, bj as OrderStatusHistory, bk as OrderStatuses, bl as OrderTracking, bm as Page, bn as PageAttachment, bo as PageDetail, bp as PaginatedResponse, bq as PaymentInstrument, br as PaymentStatus, bs as PaymentStatuses, bt as PaymentSwift, bu as PickupPoint, bv as PickupPointHours, bw as PickupPointsInput, bx as PickupWidgetConfig, by as PriceDisplay, bz as ProductAssetGroup, bA as ProductAssetItem, bB as ProductAvailability, bC as ProductGroup, bD as ProductLabel, bE as ProductListItem, bF as ProductMedia, bG as ProductMediaVariant, bH as ProductParameter, bI as ProductParameterGroup, bJ as ProductParametersResponse, bK as ProductPrice, bL as ProductPromotionSummary, bM as ProductReview, bN as ProductReviewsResponse, bO as ProductSibling, bP as ProductSort, bQ as ProductSortValue, bR as ProductVolumePrice, bS as ProductsQuery, bT as QuizAnswerInput, bU as QuizAnswerResult, bV as QuizQuestion, bW as QuizResult, bX as QuoteItem, bY as QuoteRequest, bZ as RegisterInput, b_ as RegisterResult, b$ as RequestInterceptor, c0 as RequestInterceptorConfig, c1 as ResponseInterceptor, c2 as ResponseInterceptorData, c3 as ReturnRequest, c4 as ReturnRequestItem, c5 as ReturnStatus, c6 as ReturnStatusItem, c7 as ReturnableOrder, c8 as ReturnableOrderItem, c9 as SdkError, ca as ShippingMethodSummary, cb as ShippingPublicConfig, cc as ShippingQuote, cd as ShippingQuoteInput, ce as ShopAppearance, cf as ShopCommerce, cg as ShopInfo, ch as ShopScript, ci as ShopScriptPlacement, cj as ShopScriptType, ck as ShopScripts, cl as ShopSeo, cm as ShopSeoIdentity, cn as SiteFormField, co as SiteFormFieldOption, cp as SiteFormFieldType, cq as Sitemap, cr as SitemapEntry, cs as StockBehavior, ct as StockMode, cu as StorefrontCollection, cv as StorefrontCollectionField, cw as StorefrontCollectionFieldType, cx as StorefrontCollectionItem, cy as StorefrontCollectionQuery, cz as StorefrontFaqGroup, cA as StorefrontFaqGroupSummary, cB as StorefrontFaqGroups, cC as StorefrontFaqItem, cD as StorefrontFaqQuery, cE as StorefrontForm, cF as StorefrontFormFieldErrorCode, cG as StorefrontFormFile, cH as StorefrontFormSettings, cI as StorefrontFormSubmitInput, cJ as StorefrontFormSubmitResult, cK as StorefrontFormUpload, cL as SubmitQuoteInput, cM as SubmitReturnInput, cN as SubmitReviewInput, cO as SubmitWithdrawalInput, cP as Subscription, cQ as SubscriptionAction, cR as SubscriptionFrequency, cS as SubscriptionItem, cT as SubscriptionStatus, cU as TaxBreakdownLine, cV as VariantAxis, cW as VariantAxisValue, cX as WishlistItem, cY as WithdrawalAcknowledgement, cZ as WithdrawalFlag, c_ as WithdrawalSettings, c$ as WithdrawalWindow, d0 as clearCartSummary, d1 as err, d2 as ok, d3 as publishCartSummary, d4 as toSdkError } from './client-EjtvqiPK.js';
1
+ import { P as ProductDetail, a as ProductVariant, B as BehioStorefront, S as SdkResult, C as CookieConsent, b as StorefrontFormFieldError } from './client-Bm8Fwcp7.js';
2
+ export { A as ActivePromotion, c as AddToCartInput, d as AddToCartItemsInput, e as AddressDetail, f as AddressSuggestion, g as AddressType, h as AddressTypes, i as AuthTokens, j as BackInStockSubscription, k as BadgeTone, l as BehioApiError, m as BehioErrorCode, n as BehioEventHandler, o as BehioEventType, p as BehioNetworkError, q as BehioStorefrontConfig, r as Blog, s as BlogPostDetail, t as BlogPostListItem, u as BlogPostsPage, v as BlogPostsQuery, w as BlogSettings, x as BlogTag, y as Booking, z as BookingCategory, D as BookingConfig, E as BookingCreateInput, F as BookingCreated, G as BookingLocale, H as BookingLocation, I as BookingManageSlotsQuery, J as BookingService, K as BookingSlot, L as BookingSlots, M as BookingSlotsQuery, N as BookingStaff, O as BookingStatus, Q as Bundle, R as BundleCatalogQuery, T as BundleItem, U as Cart, V as CartBundleLine, W as CartBundleLineItem, X as CartDiscount, Y as CartItem, Z as CartItemProduct, _ as CartLinkClaimed, $ as CartPromotion, a0 as CartSummaryEvent, a1 as Category, a2 as CategoryDetail, a3 as CertificateVerification, a4 as CheckoutAddress, a5 as CheckoutInput, a6 as CheckoutPaymentMethod, a7 as CheckoutPreview, a8 as CheckoutResult, a9 as CheckoutSettings, aa as CookieConsentInput, ab as CourseAttachment, ac as CourseCertificate, ad as CourseComment, ae as CourseCommentReply, af as CourseCommentsList, ag as CourseDetail, ah as CourseLesson, ai as CourseListItem, aj as CourseModule, ak as CoursePostedComment, al as CourseProgress, am as CourseTutorMessage, an as CourseTutorThread, ao as CrossSellItem, ap as CurrencyDisplayFormat, aq as CustomerAddress, ar as CustomerBadge, as as CustomerChallenge, at as CustomerGamification, au as CustomerGamificationQuery, av as CustomerProfile, aw as DigitalDownload, ax as DownloadUrl, ay as Facet, az as FacetAvailability, aA as FacetCategory, aB as FacetLabel, aC as FacetPriceRange, aD as FacetRange, aE as FacetRatingBucket, aF as FacetValue, aG as FacetsResponse, aH as FilterField, aI as FulfillmentStatus, aJ as FulfillmentStatuses, aK as GamificationRefreshResult, aL as GiftCardBalance, aM as GiftCardPurchaseInput, aN as GiftCardPurchaseResult, aO as GiftCardSummary, aP as LessonNote, aQ as LessonQuiz, aR as LoginInput, aS as LoyaltyBalance, aT as LoyaltyNextTier, aU as LoyaltyProgram, aV as LoyaltyQuery, aW as LoyaltyReferralResult, aX as LoyaltySummary, aY as LoyaltyTier, aZ as LoyaltyTierPerks, a_ as LoyaltyTransaction, a$ as Menu, b0 as MenuItem, b1 as MenuItemRef, b2 as MenuItemType, b3 as MessageResponse, b4 as NewsletterOptInDefault, b5 as NewsletterSubscribeInput, b6 as NewsletterSubscribeResult, b7 as NewsletterUnsubscribeResult, b8 as OrderAccessRequestResponse, b9 as OrderAccessVerifyResponse, ba as OrderDetail, bb as OrderDiscount, bc as OrderDocument, bd as OrderItem, be as OrderListItem, bf as OrderPaymentInstructions, bg as OrderPickupPoint, bh as OrderShipment, bi as OrderStatus, bj as OrderStatusHistory, bk as OrderStatuses, bl as OrderTracking, bm as Page, bn as PageAttachment, bo as PageDetail, bp as PaginatedResponse, bq as PaymentInstrument, br as PaymentStatus, bs as PaymentStatuses, bt as PaymentSwift, bu as PickupPoint, bv as PickupPointHours, bw as PickupPointsInput, bx as PickupWidgetConfig, by as PriceDisplay, bz as ProductAssetGroup, bA as ProductAssetItem, bB as ProductAvailability, bC as ProductGroup, bD as ProductLabel, bE as ProductListItem, bF as ProductMedia, bG as ProductMediaVariant, bH as ProductParameter, bI as ProductParameterGroup, bJ as ProductParametersResponse, bK as ProductPrice, bL as ProductPromotionSummary, bM as ProductReview, bN as ProductReviewsResponse, bO as ProductSibling, bP as ProductSort, bQ as ProductSortValue, bR as ProductVolumePrice, bS as ProductsQuery, bT as QuizAnswerInput, bU as QuizAnswerResult, bV as QuizQuestion, bW as QuizResult, bX as QuoteItem, bY as QuoteRequest, bZ as RegisterInput, b_ as RegisterResult, b$ as RequestInterceptor, c0 as RequestInterceptorConfig, c1 as ResponseInterceptor, c2 as ResponseInterceptorData, c3 as ReturnRequest, c4 as ReturnRequestItem, c5 as ReturnStatus, c6 as ReturnStatusItem, c7 as ReturnableOrder, c8 as ReturnableOrderItem, c9 as SdkError, ca as ShippingMethodSummary, cb as ShippingPublicConfig, cc as ShippingQuote, cd as ShippingQuoteInput, ce as ShopAppearance, cf as ShopCommerce, cg as ShopInfo, ch as ShopScript, ci as ShopScriptPlacement, cj as ShopScriptType, ck as ShopScripts, cl as ShopSeo, cm as ShopSeoIdentity, cn as SiteFormField, co as SiteFormFieldOption, cp as SiteFormFieldType, cq as Sitemap, cr as SitemapEntry, cs as StockBehavior, ct as StockMode, cu as StorefrontCollection, cv as StorefrontCollectionField, cw as StorefrontCollectionFieldType, cx as StorefrontCollectionItem, cy as StorefrontCollectionQuery, cz as StorefrontFaqGroup, cA as StorefrontFaqGroupSummary, cB as StorefrontFaqGroups, cC as StorefrontFaqItem, cD as StorefrontFaqQuery, cE as StorefrontForm, cF as StorefrontFormFieldErrorCode, cG as StorefrontFormFile, cH as StorefrontFormSettings, cI as StorefrontFormSubmitInput, cJ as StorefrontFormSubmitResult, cK as StorefrontFormUpload, cL as SubmitQuoteInput, cM as SubmitReturnInput, cN as SubmitReviewInput, cO as SubmitWithdrawalInput, cP as Subscription, cQ as SubscriptionAction, cR as SubscriptionFrequency, cS as SubscriptionItem, cT as SubscriptionStatus, cU as TaxBreakdownLine, cV as VariantAxis, cW as VariantAxisValue, cX as WishlistItem, cY as WithdrawalAcknowledgement, cZ as WithdrawalFlag, c_ as WithdrawalSettings, c$ as WithdrawalWindow, d0 as clearCartSummary, d1 as err, d2 as ok, d3 as publishCartSummary, d4 as toSdkError } from './client-Bm8Fwcp7.js';
3
3
 
4
4
  /**
5
5
  * Format a price amount with currency using Intl.NumberFormat.
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
 
14
14
 
15
- var _chunkOOLOURJMjs = require('./chunk-OOLOURJM.js');
15
+ var _chunkIB3DU7B6js = require('./chunk-IB3DU7B6.js');
16
16
 
17
17
  // src/react/utils/format-price.ts
18
18
  function formatPrice(amount, currency, locale, display) {
@@ -1106,7 +1106,7 @@ var GENERIC = {
1106
1106
  en: "Something went wrong, please try again."
1107
1107
  };
1108
1108
  function bodyOf(err2) {
1109
- const body = err2 instanceof _chunkOOLOURJMjs.BehioApiError ? err2.body : err2 && typeof err2 === "object" && "body" in err2 ? err2.body : err2;
1109
+ const body = err2 instanceof _chunkIB3DU7B6js.BehioApiError ? err2.body : err2 && typeof err2 === "object" && "body" in err2 ? err2.body : err2;
1110
1110
  return body && typeof body === "object" ? body : null;
1111
1111
  }
1112
1112
  function errorCode(err2) {
@@ -1223,4 +1223,4 @@ function formFieldErrors(err2) {
1223
1223
 
1224
1224
 
1225
1225
 
1226
- exports.AddressTypes = _chunkOOLOURJMjs.AddressTypes; exports.BehioApiError = _chunkOOLOURJMjs.BehioApiError; exports.BehioNetworkError = _chunkOOLOURJMjs.BehioNetworkError; exports.BehioStorefront = _chunkOOLOURJMjs.BehioStorefront; exports.FulfillmentStatuses = _chunkOOLOURJMjs.FulfillmentStatuses; exports.OrderStatuses = _chunkOOLOURJMjs.OrderStatuses; exports.PaymentStatuses = _chunkOOLOURJMjs.PaymentStatuses; exports.ProductSort = _chunkOOLOURJMjs.ProductSort; exports.VARIANT_QUERY_PARAM = VARIANT_QUERY_PARAM; exports.availableAxisValues = availableAxisValues; exports.buildVariantComparison = buildVariantComparison; exports.clearCartSummary = _chunkOOLOURJMjs.clearCartSummary; exports.err = _chunkOOLOURJMjs.err; exports.errorCode = errorCode; exports.errorMessage = errorMessage; exports.errorParams = errorParams; exports.findVariantByAttributes = findVariantByAttributes; exports.formFieldErrors = formFieldErrors; exports.formatPrice = formatPrice; exports.generateVisitorId = generateVisitorId; exports.getStoredVisitorId = getStoredVisitorId; exports.grantAnalyticsConsent = grantAnalyticsConsent; exports.ok = _chunkOOLOURJMjs.ok; exports.publishCartSummary = _chunkOOLOURJMjs.publishCartSummary; exports.resolveVariantContent = resolveVariantContent; exports.revokeAnalyticsConsent = revokeAnalyticsConsent; exports.toSdkError = _chunkOOLOURJMjs.toSdkError; exports.trackEcommerceEvent = trackEcommerceEvent; exports.validationFieldMessages = validationFieldMessages; exports.variantFromQuery = variantFromQuery; exports.variantHref = variantHref;
1226
+ exports.AddressTypes = _chunkIB3DU7B6js.AddressTypes; exports.BehioApiError = _chunkIB3DU7B6js.BehioApiError; exports.BehioNetworkError = _chunkIB3DU7B6js.BehioNetworkError; exports.BehioStorefront = _chunkIB3DU7B6js.BehioStorefront; exports.FulfillmentStatuses = _chunkIB3DU7B6js.FulfillmentStatuses; exports.OrderStatuses = _chunkIB3DU7B6js.OrderStatuses; exports.PaymentStatuses = _chunkIB3DU7B6js.PaymentStatuses; exports.ProductSort = _chunkIB3DU7B6js.ProductSort; exports.VARIANT_QUERY_PARAM = VARIANT_QUERY_PARAM; exports.availableAxisValues = availableAxisValues; exports.buildVariantComparison = buildVariantComparison; exports.clearCartSummary = _chunkIB3DU7B6js.clearCartSummary; exports.err = _chunkIB3DU7B6js.err; exports.errorCode = errorCode; exports.errorMessage = errorMessage; exports.errorParams = errorParams; exports.findVariantByAttributes = findVariantByAttributes; exports.formFieldErrors = formFieldErrors; exports.formatPrice = formatPrice; exports.generateVisitorId = generateVisitorId; exports.getStoredVisitorId = getStoredVisitorId; exports.grantAnalyticsConsent = grantAnalyticsConsent; exports.ok = _chunkIB3DU7B6js.ok; exports.publishCartSummary = _chunkIB3DU7B6js.publishCartSummary; exports.resolveVariantContent = resolveVariantContent; exports.revokeAnalyticsConsent = revokeAnalyticsConsent; exports.toSdkError = _chunkIB3DU7B6js.toSdkError; exports.trackEcommerceEvent = trackEcommerceEvent; exports.validationFieldMessages = validationFieldMessages; exports.variantFromQuery = variantFromQuery; exports.variantHref = variantHref;
package/dist/index.mjs CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  ok,
13
13
  publishCartSummary,
14
14
  toSdkError
15
- } from "./chunk-3TAXKDUJ.mjs";
15
+ } from "./chunk-VYJLUJXO.mjs";
16
16
 
17
17
  // src/react/utils/format-price.ts
18
18
  function formatPrice(amount, currency, locale, display) {
package/dist/next.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { q as BehioStorefrontConfig, B as BehioStorefront } from './client-EjtvqiPK.mjs';
1
+ import { q as BehioStorefrontConfig, B as BehioStorefront } from './client-Bm8Fwcp7.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 { q as BehioStorefrontConfig, B as BehioStorefront } from './client-EjtvqiPK.js';
1
+ import { q as BehioStorefrontConfig, B as BehioStorefront } from './client-Bm8Fwcp7.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 _chunkOOLOURJMjs = require('./chunk-OOLOURJM.js');
3
+ var _chunkIB3DU7B6js = require('./chunk-IB3DU7B6.js');
4
4
 
5
5
  // src/next.ts
6
6
  var _headers = require('next/headers');
@@ -19,7 +19,7 @@ async function getBehio(options = {}) {
19
19
  const locale = _nullishCoalesce(options.locale, () => ( process.env.BEHIO_LOCALE));
20
20
  const currency = _nullishCoalesce(options.currency, () => ( process.env.BEHIO_CURRENCY));
21
21
  const cookieName = _nullishCoalesce(options.cartCookieName, () => ( CART_COOKIE_NAME));
22
- const client = new (0, _chunkOOLOURJMjs.BehioStorefront)({
22
+ const client = new (0, _chunkIB3DU7B6js.BehioStorefront)({
23
23
  apiKey,
24
24
  ...baseUrl ? { baseUrl } : {},
25
25
  ...locale ? { locale } : {},
package/dist/next.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BehioStorefront
3
- } from "./chunk-3TAXKDUJ.mjs";
3
+ } from "./chunk-VYJLUJXO.mjs";
4
4
 
5
5
  // src/next.ts
6
6
  import { cookies, headers } from "next/headers";
package/dist/react.d.mts CHANGED
@@ -1427,6 +1427,11 @@ interface CartItemProduct {
1427
1427
  orderQuantityStep?: number | null;
1428
1428
  }
1429
1429
  interface CartItem {
1430
+ /** Extras allocated to this exact main cart line. Older servers omit it. */
1431
+ addonSelections?: Array<{
1432
+ productId: string;
1433
+ quantity: number;
1434
+ }>;
1430
1435
  id: string;
1431
1436
  /** A retained row can be unavailable after the merchant changes its offer. */
1432
1437
  isPurchasable: boolean;
@@ -1615,7 +1620,9 @@ interface GiftCardSummary {
1615
1620
  }
1616
1621
  /** Atomic multi-product purchase; every product is validated before any line changes. */
1617
1622
  interface AddToCartItemsInput {
1618
- items: AddToCartInput[];
1623
+ items: Array<AddToCartInput & {
1624
+ assignToProductId?: string;
1625
+ }>;
1619
1626
  }
1620
1627
  interface AddToCartInput {
1621
1628
  /**
@@ -4018,6 +4025,8 @@ declare class CartModule {
4018
4025
  addItems(input: AddToCartItemsInput): Promise<SdkResult<Cart & {
4019
4026
  newSessionToken?: string;
4020
4027
  }>>;
4028
+ /** Idempotent selection of one extra package for a particular main cart line. */
4029
+ setAddon(itemId: string, productId: string, selected: boolean): Promise<SdkResult<Cart>>;
4021
4030
  /**
4022
4031
  * Switch the CART currency server-side. The backend re-prices every line in
4023
4032
  * the new currency (no FX conversion: a product must have a price configured
@@ -4830,6 +4839,11 @@ declare function useCart(options?: UseCartOptions): {
4830
4839
  addItems: _tanstack_react_query.UseMutateAsyncFunction<Cart & {
4831
4840
  newSessionToken?: string;
4832
4841
  }, Error, AddToCartItemsInput, void>;
4842
+ setAddon: _tanstack_react_query.UseMutateAsyncFunction<Cart, Error, {
4843
+ itemId: string;
4844
+ productId: string;
4845
+ selected: boolean;
4846
+ }, void>;
4833
4847
  updateQuantity: (itemId: string, quantity: number) => Promise<Cart>;
4834
4848
  removeItem: (itemId: string) => Promise<Cart>;
4835
4849
  clear: () => Promise<void>;
package/dist/react.d.ts CHANGED
@@ -1427,6 +1427,11 @@ interface CartItemProduct {
1427
1427
  orderQuantityStep?: number | null;
1428
1428
  }
1429
1429
  interface CartItem {
1430
+ /** Extras allocated to this exact main cart line. Older servers omit it. */
1431
+ addonSelections?: Array<{
1432
+ productId: string;
1433
+ quantity: number;
1434
+ }>;
1430
1435
  id: string;
1431
1436
  /** A retained row can be unavailable after the merchant changes its offer. */
1432
1437
  isPurchasable: boolean;
@@ -1615,7 +1620,9 @@ interface GiftCardSummary {
1615
1620
  }
1616
1621
  /** Atomic multi-product purchase; every product is validated before any line changes. */
1617
1622
  interface AddToCartItemsInput {
1618
- items: AddToCartInput[];
1623
+ items: Array<AddToCartInput & {
1624
+ assignToProductId?: string;
1625
+ }>;
1619
1626
  }
1620
1627
  interface AddToCartInput {
1621
1628
  /**
@@ -4018,6 +4025,8 @@ declare class CartModule {
4018
4025
  addItems(input: AddToCartItemsInput): Promise<SdkResult<Cart & {
4019
4026
  newSessionToken?: string;
4020
4027
  }>>;
4028
+ /** Idempotent selection of one extra package for a particular main cart line. */
4029
+ setAddon(itemId: string, productId: string, selected: boolean): Promise<SdkResult<Cart>>;
4021
4030
  /**
4022
4031
  * Switch the CART currency server-side. The backend re-prices every line in
4023
4032
  * the new currency (no FX conversion: a product must have a price configured
@@ -4830,6 +4839,11 @@ declare function useCart(options?: UseCartOptions): {
4830
4839
  addItems: _tanstack_react_query.UseMutateAsyncFunction<Cart & {
4831
4840
  newSessionToken?: string;
4832
4841
  }, Error, AddToCartItemsInput, void>;
4842
+ setAddon: _tanstack_react_query.UseMutateAsyncFunction<Cart, Error, {
4843
+ itemId: string;
4844
+ productId: string;
4845
+ selected: boolean;
4846
+ }, void>;
4833
4847
  updateQuantity: (itemId: string, quantity: number) => Promise<Cart>;
4834
4848
  removeItem: (itemId: string) => Promise<Cart>;
4835
4849
  clear: () => Promise<void>;
package/dist/react.js CHANGED
@@ -1276,13 +1276,19 @@ var CartModule = class {
1276
1276
  /** Add the complete selection atomically. Invalid/unavailable lines leave the cart unchanged. */
1277
1277
  async addItems(input) {
1278
1278
  const res = await this.client.request("POST", "/cart/items/batch", {
1279
- body: { items: input.items.map((item) => ({ productId: item.productId, quantity: item.quantity })) }
1279
+ body: { items: input.items.map((item) => ({ productId: item.productId, quantity: item.quantity, ...item.assignToProductId ? { assignToProductId: item.assignToProductId } : {} })) }
1280
1280
  });
1281
1281
  if (res.error) return res;
1282
1282
  if (res.data.newSessionToken) this.client.setCartSession(res.data.newSessionToken);
1283
1283
  this.client.emit("cart:updated", res.data);
1284
1284
  return res;
1285
1285
  }
1286
+ /** Idempotent selection of one extra package for a particular main cart line. */
1287
+ async setAddon(itemId, productId, selected) {
1288
+ const res = await this.client.request("PUT", `/cart/items/${encodeURIComponent(itemId)}/addons/${encodeURIComponent(productId)}`, { body: { selected } });
1289
+ if (!res.error) this.client.emit("cart:updated", res.data);
1290
+ return res;
1291
+ }
1286
1292
  /**
1287
1293
  * Switch the CART currency server-side. The backend re-prices every line in
1288
1294
  * the new currency (no FX conversion: a product must have a price configured
@@ -2970,6 +2976,11 @@ function useCart(options) {
2970
2976
  await acceptCart(result);
2971
2977
  }
2972
2978
  });
2979
+ const setAddonMutation = (0, import_react_query12.useMutation)({
2980
+ mutationFn: ({ itemId, productId, selected }) => unwrap(client.cart.setAddon(itemId, productId, selected)),
2981
+ onMutate: cancelCartRead,
2982
+ onSuccess: acceptCart
2983
+ });
2973
2984
  const updateMutation = (0, import_react_query12.useMutation)({
2974
2985
  mutationFn: async ({ itemId, quantity }) => {
2975
2986
  return unwrap(client.cart.updateQuantity(itemId, quantity));
@@ -3089,6 +3100,7 @@ function useCart(options) {
3089
3100
  // Actions
3090
3101
  addItem,
3091
3102
  addItems: addItemsMutation.mutateAsync,
3103
+ setAddon: setAddonMutation.mutateAsync,
3092
3104
  updateQuantity,
3093
3105
  removeItem,
3094
3106
  clear,
@@ -3103,7 +3115,7 @@ function useCart(options) {
3103
3115
  isEmpty: !cart || cart.items.length === 0 && (cart.bundleLines?.length ?? 0) === 0,
3104
3116
  // Mutation states
3105
3117
  isAdding: addMutation.isPending || addItemsMutation.isPending,
3106
- isUpdating: updateMutation.isPending,
3118
+ isUpdating: updateMutation.isPending || setAddonMutation.isPending,
3107
3119
  isRemoving: removeMutation.isPending,
3108
3120
  isUpdatingBundle: addBundleMutation.isPending || updateBundleMutation.isPending || removeBundleMutation.isPending
3109
3121
  };
package/dist/react.mjs CHANGED
@@ -1153,13 +1153,19 @@ var CartModule = class {
1153
1153
  /** Add the complete selection atomically. Invalid/unavailable lines leave the cart unchanged. */
1154
1154
  async addItems(input) {
1155
1155
  const res = await this.client.request("POST", "/cart/items/batch", {
1156
- body: { items: input.items.map((item) => ({ productId: item.productId, quantity: item.quantity })) }
1156
+ body: { items: input.items.map((item) => ({ productId: item.productId, quantity: item.quantity, ...item.assignToProductId ? { assignToProductId: item.assignToProductId } : {} })) }
1157
1157
  });
1158
1158
  if (res.error) return res;
1159
1159
  if (res.data.newSessionToken) this.client.setCartSession(res.data.newSessionToken);
1160
1160
  this.client.emit("cart:updated", res.data);
1161
1161
  return res;
1162
1162
  }
1163
+ /** Idempotent selection of one extra package for a particular main cart line. */
1164
+ async setAddon(itemId, productId, selected) {
1165
+ const res = await this.client.request("PUT", `/cart/items/${encodeURIComponent(itemId)}/addons/${encodeURIComponent(productId)}`, { body: { selected } });
1166
+ if (!res.error) this.client.emit("cart:updated", res.data);
1167
+ return res;
1168
+ }
1163
1169
  /**
1164
1170
  * Switch the CART currency server-side. The backend re-prices every line in
1165
1171
  * the new currency (no FX conversion: a product must have a price configured
@@ -2847,6 +2853,11 @@ function useCart(options) {
2847
2853
  await acceptCart(result);
2848
2854
  }
2849
2855
  });
2856
+ const setAddonMutation = useMutation({
2857
+ mutationFn: ({ itemId, productId, selected }) => unwrap(client.cart.setAddon(itemId, productId, selected)),
2858
+ onMutate: cancelCartRead,
2859
+ onSuccess: acceptCart
2860
+ });
2850
2861
  const updateMutation = useMutation({
2851
2862
  mutationFn: async ({ itemId, quantity }) => {
2852
2863
  return unwrap(client.cart.updateQuantity(itemId, quantity));
@@ -2966,6 +2977,7 @@ function useCart(options) {
2966
2977
  // Actions
2967
2978
  addItem,
2968
2979
  addItems: addItemsMutation.mutateAsync,
2980
+ setAddon: setAddonMutation.mutateAsync,
2969
2981
  updateQuantity,
2970
2982
  removeItem,
2971
2983
  clear,
@@ -2980,7 +2992,7 @@ function useCart(options) {
2980
2992
  isEmpty: !cart || cart.items.length === 0 && (cart.bundleLines?.length ?? 0) === 0,
2981
2993
  // Mutation states
2982
2994
  isAdding: addMutation.isPending || addItemsMutation.isPending,
2983
- isUpdating: updateMutation.isPending,
2995
+ isUpdating: updateMutation.isPending || setAddonMutation.isPending,
2984
2996
  isRemoving: removeMutation.isPending,
2985
2997
  isUpdatingBundle: addBundleMutation.isPending || updateBundleMutation.isPending || removeBundleMutation.isPending
2986
2998
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@behio/storefront-sdk",
3
- "version": "2.27.0",
3
+ "version": "2.28.0",
4
4
  "description": "TypeScript SDK for Behio headless e-commerce: core client + React hooks",
5
5
  "author": "Behio",
6
6
  "license": "MIT",