@behio/storefront-sdk 2.26.0 → 2.27.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/dist/{chunk-GNWW2O3A.mjs → chunk-3TAXKDUJ.mjs} +10 -0
- package/dist/{chunk-IUC57IOB.js → chunk-OOLOURJM.js} +10 -0
- package/dist/{client-BuL50_BZ.d.mts → client-EjtvqiPK.d.mts} +9 -1
- package/dist/{client-BuL50_BZ.d.ts → client-EjtvqiPK.d.ts} +9 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/index.mjs +1 -1
- package/dist/next.d.mts +1 -1
- package/dist/next.d.ts +1 -1
- package/dist/next.js +2 -2
- package/dist/next.mjs +1 -1
- package/dist/react.d.mts +11 -0
- package/dist/react.d.ts +11 -0
- package/dist/react.js +20 -1
- package/dist/react.mjs +20 -1
- package/package.json +1 -1
|
@@ -1181,6 +1181,16 @@ var CartModule = class {
|
|
|
1181
1181
|
this.client.emit("cart:updated", res.data);
|
|
1182
1182
|
return res;
|
|
1183
1183
|
}
|
|
1184
|
+
/** Add the complete selection atomically. Invalid/unavailable lines leave the cart unchanged. */
|
|
1185
|
+
async addItems(input) {
|
|
1186
|
+
const res = await this.client.request("POST", "/cart/items/batch", {
|
|
1187
|
+
body: { items: input.items.map((item) => ({ productId: item.productId, quantity: item.quantity })) }
|
|
1188
|
+
});
|
|
1189
|
+
if (res.error) return res;
|
|
1190
|
+
if (res.data.newSessionToken) this.client.setCartSession(res.data.newSessionToken);
|
|
1191
|
+
this.client.emit("cart:updated", res.data);
|
|
1192
|
+
return res;
|
|
1193
|
+
}
|
|
1184
1194
|
/**
|
|
1185
1195
|
* Switch the CART currency server-side. The backend re-prices every line in
|
|
1186
1196
|
* the new currency (no FX conversion: a product must have a price configured
|
|
@@ -1181,6 +1181,16 @@ var CartModule = class {
|
|
|
1181
1181
|
this.client.emit("cart:updated", res.data);
|
|
1182
1182
|
return res;
|
|
1183
1183
|
}
|
|
1184
|
+
/** Add the complete selection atomically. Invalid/unavailable lines leave the cart unchanged. */
|
|
1185
|
+
async addItems(input) {
|
|
1186
|
+
const res = await this.client.request("POST", "/cart/items/batch", {
|
|
1187
|
+
body: { items: input.items.map((item) => ({ productId: item.productId, quantity: item.quantity })) }
|
|
1188
|
+
});
|
|
1189
|
+
if (res.error) return res;
|
|
1190
|
+
if (res.data.newSessionToken) this.client.setCartSession(res.data.newSessionToken);
|
|
1191
|
+
this.client.emit("cart:updated", res.data);
|
|
1192
|
+
return res;
|
|
1193
|
+
}
|
|
1184
1194
|
/**
|
|
1185
1195
|
* Switch the CART currency server-side. The backend re-prices every line in
|
|
1186
1196
|
* the new currency (no FX conversion: a product must have a price configured
|
|
@@ -1556,6 +1556,10 @@ interface GiftCardSummary {
|
|
|
1556
1556
|
balance: number;
|
|
1557
1557
|
currency: string;
|
|
1558
1558
|
}
|
|
1559
|
+
/** Atomic multi-product purchase; every product is validated before any line changes. */
|
|
1560
|
+
interface AddToCartItemsInput {
|
|
1561
|
+
items: AddToCartInput[];
|
|
1562
|
+
}
|
|
1559
1563
|
interface AddToCartInput {
|
|
1560
1564
|
/**
|
|
1561
1565
|
* Eshop product ID of the sellable unit. A variant is its own eshop product,
|
|
@@ -3973,6 +3977,10 @@ declare class CartModule {
|
|
|
3973
3977
|
addItem(input: AddToCartInput): Promise<SdkResult<Cart & {
|
|
3974
3978
|
newSessionToken?: string;
|
|
3975
3979
|
}>>;
|
|
3980
|
+
/** Add the complete selection atomically. Invalid/unavailable lines leave the cart unchanged. */
|
|
3981
|
+
addItems(input: AddToCartItemsInput): Promise<SdkResult<Cart & {
|
|
3982
|
+
newSessionToken?: string;
|
|
3983
|
+
}>>;
|
|
3976
3984
|
/**
|
|
3977
3985
|
* Switch the CART currency server-side. The backend re-prices every line in
|
|
3978
3986
|
* the new currency (no FX conversion: a product must have a price configured
|
|
@@ -4620,4 +4628,4 @@ declare function clearCartSummary(): void;
|
|
|
4620
4628
|
/** Publish only authoritative current totals; server cart consumers call this after hydration and revalidation. */
|
|
4621
4629
|
declare function publishCartSummary(summary: CartSummaryEvent): void;
|
|
4622
4630
|
|
|
4623
|
-
export { type
|
|
4631
|
+
export { type CartPromotion as $, type ActivePromotion as A, BehioStorefront as B, type CookieConsent as C, type BookingConfig as D, type BookingCreateInput as E, type BookingCreated as F, type BookingLocale as G, type BookingLocation as H, type BookingManageSlotsQuery as I, type BookingService as J, type BookingSlot as K, type BookingSlots as L, type BookingSlotsQuery as M, type BookingStaff as N, type BookingStatus as O, type ProductDetail as P, type Bundle as Q, type BundleCatalogQuery as R, type SdkResult as S, type BundleItem as T, type Cart as U, type CartBundleLine as V, type CartBundleLineItem as W, type CartDiscount as X, type CartItem as Y, type CartItemProduct as Z, type CartLinkClaimed as _, type ProductVariant as a, type Menu as a$, type CartSummaryEvent as a0, type Category as a1, type CategoryDetail as a2, type CertificateVerification as a3, type CheckoutAddress as a4, type CheckoutInput as a5, type CheckoutPaymentMethod as a6, type CheckoutPreview as a7, type CheckoutResult as a8, type CheckoutSettings as a9, type FacetCategory as aA, type FacetLabel as aB, type FacetPriceRange as aC, type FacetRange as aD, type FacetRatingBucket as aE, type FacetValue as aF, type FacetsResponse as aG, type FilterField as aH, type FulfillmentStatus as aI, FulfillmentStatuses as aJ, type GamificationRefreshResult as aK, type GiftCardBalance as aL, type GiftCardPurchaseInput as aM, type GiftCardPurchaseResult as aN, type GiftCardSummary as aO, type LessonNote as aP, type LessonQuiz as aQ, type LoginInput as aR, type LoyaltyBalance as aS, type LoyaltyNextTier as aT, type LoyaltyProgram as aU, type LoyaltyQuery as aV, type LoyaltyReferralResult as aW, type LoyaltySummary as aX, type LoyaltyTier as aY, type LoyaltyTierPerks as aZ, type LoyaltyTransaction as a_, type CookieConsentInput as aa, type CourseAttachment as ab, type CourseCertificate as ac, type CourseComment as ad, type CourseCommentReply as ae, type CourseCommentsList as af, type CourseDetail as ag, type CourseLesson as ah, type CourseListItem as ai, type CourseModule as aj, type CoursePostedComment as ak, type CourseProgress as al, type CourseTutorMessage as am, type CourseTutorThread as an, type CrossSellItem as ao, type CurrencyDisplayFormat as ap, type CustomerAddress as aq, type CustomerBadge as ar, type CustomerChallenge as as, type CustomerGamification as at, type CustomerGamificationQuery as au, type CustomerProfile as av, type DigitalDownload as aw, type DownloadUrl as ax, type Facet as ay, type FacetAvailability as az, type StorefrontFormFieldError as b, type RequestInterceptor as b$, type MenuItem as b0, type MenuItemRef as b1, type MenuItemType as b2, type MessageResponse as b3, type NewsletterOptInDefault as b4, type NewsletterSubscribeInput as b5, type NewsletterSubscribeResult as b6, type NewsletterUnsubscribeResult as b7, type OrderAccessRequestResponse as b8, type OrderAccessVerifyResponse as b9, type ProductAssetItem as bA, type ProductAvailability as bB, type ProductGroup as bC, type ProductLabel as bD, type ProductListItem as bE, type ProductMedia as bF, type ProductMediaVariant as bG, type ProductParameter as bH, type ProductParameterGroup as bI, type ProductParametersResponse as bJ, type ProductPrice as bK, type ProductPromotionSummary as bL, type ProductReview as bM, type ProductReviewsResponse as bN, type ProductSibling as bO, ProductSort as bP, type ProductSortValue as bQ, type ProductVolumePrice as bR, type ProductsQuery as bS, type QuizAnswerInput as bT, type QuizAnswerResult as bU, type QuizQuestion as bV, type QuizResult as bW, type QuoteItem as bX, type QuoteRequest as bY, type RegisterInput as bZ, type RegisterResult as b_, type OrderDetail as ba, type OrderDiscount as bb, type OrderDocument as bc, type OrderItem as bd, type OrderListItem as be, type OrderPaymentInstructions as bf, type OrderPickupPoint as bg, type OrderShipment as bh, type OrderStatus as bi, type OrderStatusHistory as bj, OrderStatuses as bk, type OrderTracking as bl, type Page as bm, type PageAttachment as bn, type PageDetail as bo, type PaginatedResponse as bp, type PaymentInstrument as bq, type PaymentStatus as br, PaymentStatuses as bs, type PaymentSwift as bt, type PickupPoint as bu, type PickupPointHours as bv, type PickupPointsInput as bw, type PickupWidgetConfig as bx, type PriceDisplay as by, type ProductAssetGroup as bz, type AddToCartInput as c, type WithdrawalWindow as c$, type RequestInterceptorConfig as c0, type ResponseInterceptor as c1, type ResponseInterceptorData as c2, type ReturnRequest as c3, type ReturnRequestItem as c4, type ReturnStatus as c5, type ReturnStatusItem as c6, type ReturnableOrder as c7, type ReturnableOrderItem as c8, type SdkError as c9, type StorefrontFaqGroupSummary as cA, type StorefrontFaqGroups as cB, type StorefrontFaqItem as cC, type StorefrontFaqQuery as cD, type StorefrontForm as cE, type StorefrontFormFieldErrorCode as cF, type StorefrontFormFile as cG, type StorefrontFormSettings as cH, type StorefrontFormSubmitInput as cI, type StorefrontFormSubmitResult as cJ, type StorefrontFormUpload as cK, type SubmitQuoteInput as cL, type SubmitReturnInput as cM, type SubmitReviewInput as cN, type SubmitWithdrawalInput as cO, type Subscription as cP, type SubscriptionAction as cQ, type SubscriptionFrequency as cR, type SubscriptionItem as cS, type SubscriptionStatus as cT, type TaxBreakdownLine as cU, type VariantAxis as cV, type VariantAxisValue as cW, type WishlistItem as cX, type WithdrawalAcknowledgement as cY, type WithdrawalFlag as cZ, type WithdrawalSettings as c_, type ShippingMethodSummary as ca, type ShippingPublicConfig as cb, type ShippingQuote as cc, type ShippingQuoteInput as cd, type ShopAppearance as ce, type ShopCommerce as cf, type ShopInfo as cg, type ShopScript as ch, type ShopScriptPlacement as ci, type ShopScriptType as cj, type ShopScripts as ck, type ShopSeo as cl, type ShopSeoIdentity as cm, type SiteFormField as cn, type SiteFormFieldOption as co, type SiteFormFieldType as cp, type Sitemap as cq, type SitemapEntry as cr, type StockBehavior as cs, type StockMode as ct, type StorefrontCollection as cu, type StorefrontCollectionField as cv, type StorefrontCollectionFieldType as cw, type StorefrontCollectionItem as cx, type StorefrontCollectionQuery as cy, type StorefrontFaqGroup as cz, type AddToCartItemsInput as d, clearCartSummary as d0, err as d1, ok as d2, publishCartSummary as d3, toSdkError as d4, type AddressDetail as e, type AddressSuggestion as f, type AddressType as g, AddressTypes as h, type AuthTokens as i, type BackInStockSubscription as j, type BadgeTone as k, BehioApiError as l, type BehioErrorCode as m, type BehioEventHandler as n, type BehioEventType as o, BehioNetworkError as p, type BehioStorefrontConfig as q, type Blog as r, type BlogPostDetail as s, type BlogPostListItem as t, type BlogPostsPage as u, type BlogPostsQuery as v, type BlogSettings as w, type BlogTag as x, type Booking as y, type BookingCategory as z };
|
|
@@ -1556,6 +1556,10 @@ interface GiftCardSummary {
|
|
|
1556
1556
|
balance: number;
|
|
1557
1557
|
currency: string;
|
|
1558
1558
|
}
|
|
1559
|
+
/** Atomic multi-product purchase; every product is validated before any line changes. */
|
|
1560
|
+
interface AddToCartItemsInput {
|
|
1561
|
+
items: AddToCartInput[];
|
|
1562
|
+
}
|
|
1559
1563
|
interface AddToCartInput {
|
|
1560
1564
|
/**
|
|
1561
1565
|
* Eshop product ID of the sellable unit. A variant is its own eshop product,
|
|
@@ -3973,6 +3977,10 @@ declare class CartModule {
|
|
|
3973
3977
|
addItem(input: AddToCartInput): Promise<SdkResult<Cart & {
|
|
3974
3978
|
newSessionToken?: string;
|
|
3975
3979
|
}>>;
|
|
3980
|
+
/** Add the complete selection atomically. Invalid/unavailable lines leave the cart unchanged. */
|
|
3981
|
+
addItems(input: AddToCartItemsInput): Promise<SdkResult<Cart & {
|
|
3982
|
+
newSessionToken?: string;
|
|
3983
|
+
}>>;
|
|
3976
3984
|
/**
|
|
3977
3985
|
* Switch the CART currency server-side. The backend re-prices every line in
|
|
3978
3986
|
* the new currency (no FX conversion: a product must have a price configured
|
|
@@ -4620,4 +4628,4 @@ declare function clearCartSummary(): void;
|
|
|
4620
4628
|
/** Publish only authoritative current totals; server cart consumers call this after hydration and revalidation. */
|
|
4621
4629
|
declare function publishCartSummary(summary: CartSummaryEvent): void;
|
|
4622
4630
|
|
|
4623
|
-
export { type
|
|
4631
|
+
export { type CartPromotion as $, type ActivePromotion as A, BehioStorefront as B, type CookieConsent as C, type BookingConfig as D, type BookingCreateInput as E, type BookingCreated as F, type BookingLocale as G, type BookingLocation as H, type BookingManageSlotsQuery as I, type BookingService as J, type BookingSlot as K, type BookingSlots as L, type BookingSlotsQuery as M, type BookingStaff as N, type BookingStatus as O, type ProductDetail as P, type Bundle as Q, type BundleCatalogQuery as R, type SdkResult as S, type BundleItem as T, type Cart as U, type CartBundleLine as V, type CartBundleLineItem as W, type CartDiscount as X, type CartItem as Y, type CartItemProduct as Z, type CartLinkClaimed as _, type ProductVariant as a, type Menu as a$, type CartSummaryEvent as a0, type Category as a1, type CategoryDetail as a2, type CertificateVerification as a3, type CheckoutAddress as a4, type CheckoutInput as a5, type CheckoutPaymentMethod as a6, type CheckoutPreview as a7, type CheckoutResult as a8, type CheckoutSettings as a9, type FacetCategory as aA, type FacetLabel as aB, type FacetPriceRange as aC, type FacetRange as aD, type FacetRatingBucket as aE, type FacetValue as aF, type FacetsResponse as aG, type FilterField as aH, type FulfillmentStatus as aI, FulfillmentStatuses as aJ, type GamificationRefreshResult as aK, type GiftCardBalance as aL, type GiftCardPurchaseInput as aM, type GiftCardPurchaseResult as aN, type GiftCardSummary as aO, type LessonNote as aP, type LessonQuiz as aQ, type LoginInput as aR, type LoyaltyBalance as aS, type LoyaltyNextTier as aT, type LoyaltyProgram as aU, type LoyaltyQuery as aV, type LoyaltyReferralResult as aW, type LoyaltySummary as aX, type LoyaltyTier as aY, type LoyaltyTierPerks as aZ, type LoyaltyTransaction as a_, type CookieConsentInput as aa, type CourseAttachment as ab, type CourseCertificate as ac, type CourseComment as ad, type CourseCommentReply as ae, type CourseCommentsList as af, type CourseDetail as ag, type CourseLesson as ah, type CourseListItem as ai, type CourseModule as aj, type CoursePostedComment as ak, type CourseProgress as al, type CourseTutorMessage as am, type CourseTutorThread as an, type CrossSellItem as ao, type CurrencyDisplayFormat as ap, type CustomerAddress as aq, type CustomerBadge as ar, type CustomerChallenge as as, type CustomerGamification as at, type CustomerGamificationQuery as au, type CustomerProfile as av, type DigitalDownload as aw, type DownloadUrl as ax, type Facet as ay, type FacetAvailability as az, type StorefrontFormFieldError as b, type RequestInterceptor as b$, type MenuItem as b0, type MenuItemRef as b1, type MenuItemType as b2, type MessageResponse as b3, type NewsletterOptInDefault as b4, type NewsletterSubscribeInput as b5, type NewsletterSubscribeResult as b6, type NewsletterUnsubscribeResult as b7, type OrderAccessRequestResponse as b8, type OrderAccessVerifyResponse as b9, type ProductAssetItem as bA, type ProductAvailability as bB, type ProductGroup as bC, type ProductLabel as bD, type ProductListItem as bE, type ProductMedia as bF, type ProductMediaVariant as bG, type ProductParameter as bH, type ProductParameterGroup as bI, type ProductParametersResponse as bJ, type ProductPrice as bK, type ProductPromotionSummary as bL, type ProductReview as bM, type ProductReviewsResponse as bN, type ProductSibling as bO, ProductSort as bP, type ProductSortValue as bQ, type ProductVolumePrice as bR, type ProductsQuery as bS, type QuizAnswerInput as bT, type QuizAnswerResult as bU, type QuizQuestion as bV, type QuizResult as bW, type QuoteItem as bX, type QuoteRequest as bY, type RegisterInput as bZ, type RegisterResult as b_, type OrderDetail as ba, type OrderDiscount as bb, type OrderDocument as bc, type OrderItem as bd, type OrderListItem as be, type OrderPaymentInstructions as bf, type OrderPickupPoint as bg, type OrderShipment as bh, type OrderStatus as bi, type OrderStatusHistory as bj, OrderStatuses as bk, type OrderTracking as bl, type Page as bm, type PageAttachment as bn, type PageDetail as bo, type PaginatedResponse as bp, type PaymentInstrument as bq, type PaymentStatus as br, PaymentStatuses as bs, type PaymentSwift as bt, type PickupPoint as bu, type PickupPointHours as bv, type PickupPointsInput as bw, type PickupWidgetConfig as bx, type PriceDisplay as by, type ProductAssetGroup as bz, type AddToCartInput as c, type WithdrawalWindow as c$, type RequestInterceptorConfig as c0, type ResponseInterceptor as c1, type ResponseInterceptorData as c2, type ReturnRequest as c3, type ReturnRequestItem as c4, type ReturnStatus as c5, type ReturnStatusItem as c6, type ReturnableOrder as c7, type ReturnableOrderItem as c8, type SdkError as c9, type StorefrontFaqGroupSummary as cA, type StorefrontFaqGroups as cB, type StorefrontFaqItem as cC, type StorefrontFaqQuery as cD, type StorefrontForm as cE, type StorefrontFormFieldErrorCode as cF, type StorefrontFormFile as cG, type StorefrontFormSettings as cH, type StorefrontFormSubmitInput as cI, type StorefrontFormSubmitResult as cJ, type StorefrontFormUpload as cK, type SubmitQuoteInput as cL, type SubmitReturnInput as cM, type SubmitReviewInput as cN, type SubmitWithdrawalInput as cO, type Subscription as cP, type SubscriptionAction as cQ, type SubscriptionFrequency as cR, type SubscriptionItem as cS, type SubscriptionStatus as cT, type TaxBreakdownLine as cU, type VariantAxis as cV, type VariantAxisValue as cW, type WishlistItem as cX, type WithdrawalAcknowledgement as cY, type WithdrawalFlag as cZ, type WithdrawalSettings as c_, type ShippingMethodSummary as ca, type ShippingPublicConfig as cb, type ShippingQuote as cc, type ShippingQuoteInput as cd, type ShopAppearance as ce, type ShopCommerce as cf, type ShopInfo as cg, type ShopScript as ch, type ShopScriptPlacement as ci, type ShopScriptType as cj, type ShopScripts as ck, type ShopSeo as cl, type ShopSeoIdentity as cm, type SiteFormField as cn, type SiteFormFieldOption as co, type SiteFormFieldType as cp, type Sitemap as cq, type SitemapEntry as cr, type StockBehavior as cs, type StockMode as ct, type StorefrontCollection as cu, type StorefrontCollectionField as cv, type StorefrontCollectionFieldType as cw, type StorefrontCollectionItem as cx, type StorefrontCollectionQuery as cy, type StorefrontFaqGroup as cz, type AddToCartItemsInput as d, clearCartSummary as d0, err as d1, ok as d2, publishCartSummary as d3, toSdkError as d4, type AddressDetail as e, type AddressSuggestion as f, type AddressType as g, AddressTypes as h, type AuthTokens as i, type BackInStockSubscription as j, type BadgeTone as k, BehioApiError as l, type BehioErrorCode as m, type BehioEventHandler as n, type BehioEventType as o, BehioNetworkError as p, type BehioStorefrontConfig as q, type Blog as r, type BlogPostDetail as s, type BlogPostListItem as t, type BlogPostsPage as u, type BlogPostsQuery as v, type BlogSettings as w, type BlogTag as x, type Booking as y, type BookingCategory as z };
|
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-
|
|
2
|
-
export { A as ActivePromotion, c as AddToCartInput, d as
|
|
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';
|
|
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-
|
|
2
|
-
export { A as ActivePromotion, c as AddToCartInput, d as
|
|
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';
|
|
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
|
|
15
|
+
var _chunkOOLOURJMjs = require('./chunk-OOLOURJM.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
|
|
1109
|
+
const body = err2 instanceof _chunkOOLOURJMjs.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 =
|
|
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;
|
package/dist/index.mjs
CHANGED
package/dist/next.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { q as BehioStorefrontConfig, B as BehioStorefront } from './client-EjtvqiPK.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 {
|
|
1
|
+
import { q as BehioStorefrontConfig, B as BehioStorefront } from './client-EjtvqiPK.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
|
|
3
|
+
var _chunkOOLOURJMjs = require('./chunk-OOLOURJM.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,
|
|
22
|
+
const client = new (0, _chunkOOLOURJMjs.BehioStorefront)({
|
|
23
23
|
apiKey,
|
|
24
24
|
...baseUrl ? { baseUrl } : {},
|
|
25
25
|
...locale ? { locale } : {},
|
package/dist/next.mjs
CHANGED
package/dist/react.d.mts
CHANGED
|
@@ -1613,6 +1613,10 @@ interface GiftCardSummary {
|
|
|
1613
1613
|
balance: number;
|
|
1614
1614
|
currency: string;
|
|
1615
1615
|
}
|
|
1616
|
+
/** Atomic multi-product purchase; every product is validated before any line changes. */
|
|
1617
|
+
interface AddToCartItemsInput {
|
|
1618
|
+
items: AddToCartInput[];
|
|
1619
|
+
}
|
|
1616
1620
|
interface AddToCartInput {
|
|
1617
1621
|
/**
|
|
1618
1622
|
* Eshop product ID of the sellable unit. A variant is its own eshop product,
|
|
@@ -4010,6 +4014,10 @@ declare class CartModule {
|
|
|
4010
4014
|
addItem(input: AddToCartInput): Promise<SdkResult<Cart & {
|
|
4011
4015
|
newSessionToken?: string;
|
|
4012
4016
|
}>>;
|
|
4017
|
+
/** Add the complete selection atomically. Invalid/unavailable lines leave the cart unchanged. */
|
|
4018
|
+
addItems(input: AddToCartItemsInput): Promise<SdkResult<Cart & {
|
|
4019
|
+
newSessionToken?: string;
|
|
4020
|
+
}>>;
|
|
4013
4021
|
/**
|
|
4014
4022
|
* Switch the CART currency server-side. The backend re-prices every line in
|
|
4015
4023
|
* the new currency (no FX conversion: a product must have a price configured
|
|
@@ -4819,6 +4827,9 @@ declare function useCart(options?: UseCartOptions): {
|
|
|
4819
4827
|
addItem: (productId: string, quantity?: number) => Promise<Cart & {
|
|
4820
4828
|
newSessionToken?: string;
|
|
4821
4829
|
}>;
|
|
4830
|
+
addItems: _tanstack_react_query.UseMutateAsyncFunction<Cart & {
|
|
4831
|
+
newSessionToken?: string;
|
|
4832
|
+
}, Error, AddToCartItemsInput, void>;
|
|
4822
4833
|
updateQuantity: (itemId: string, quantity: number) => Promise<Cart>;
|
|
4823
4834
|
removeItem: (itemId: string) => Promise<Cart>;
|
|
4824
4835
|
clear: () => Promise<void>;
|
package/dist/react.d.ts
CHANGED
|
@@ -1613,6 +1613,10 @@ interface GiftCardSummary {
|
|
|
1613
1613
|
balance: number;
|
|
1614
1614
|
currency: string;
|
|
1615
1615
|
}
|
|
1616
|
+
/** Atomic multi-product purchase; every product is validated before any line changes. */
|
|
1617
|
+
interface AddToCartItemsInput {
|
|
1618
|
+
items: AddToCartInput[];
|
|
1619
|
+
}
|
|
1616
1620
|
interface AddToCartInput {
|
|
1617
1621
|
/**
|
|
1618
1622
|
* Eshop product ID of the sellable unit. A variant is its own eshop product,
|
|
@@ -4010,6 +4014,10 @@ declare class CartModule {
|
|
|
4010
4014
|
addItem(input: AddToCartInput): Promise<SdkResult<Cart & {
|
|
4011
4015
|
newSessionToken?: string;
|
|
4012
4016
|
}>>;
|
|
4017
|
+
/** Add the complete selection atomically. Invalid/unavailable lines leave the cart unchanged. */
|
|
4018
|
+
addItems(input: AddToCartItemsInput): Promise<SdkResult<Cart & {
|
|
4019
|
+
newSessionToken?: string;
|
|
4020
|
+
}>>;
|
|
4013
4021
|
/**
|
|
4014
4022
|
* Switch the CART currency server-side. The backend re-prices every line in
|
|
4015
4023
|
* the new currency (no FX conversion: a product must have a price configured
|
|
@@ -4819,6 +4827,9 @@ declare function useCart(options?: UseCartOptions): {
|
|
|
4819
4827
|
addItem: (productId: string, quantity?: number) => Promise<Cart & {
|
|
4820
4828
|
newSessionToken?: string;
|
|
4821
4829
|
}>;
|
|
4830
|
+
addItems: _tanstack_react_query.UseMutateAsyncFunction<Cart & {
|
|
4831
|
+
newSessionToken?: string;
|
|
4832
|
+
}, Error, AddToCartItemsInput, void>;
|
|
4822
4833
|
updateQuantity: (itemId: string, quantity: number) => Promise<Cart>;
|
|
4823
4834
|
removeItem: (itemId: string) => Promise<Cart>;
|
|
4824
4835
|
clear: () => Promise<void>;
|
package/dist/react.js
CHANGED
|
@@ -1273,6 +1273,16 @@ var CartModule = class {
|
|
|
1273
1273
|
this.client.emit("cart:updated", res.data);
|
|
1274
1274
|
return res;
|
|
1275
1275
|
}
|
|
1276
|
+
/** Add the complete selection atomically. Invalid/unavailable lines leave the cart unchanged. */
|
|
1277
|
+
async addItems(input) {
|
|
1278
|
+
const res = await this.client.request("POST", "/cart/items/batch", {
|
|
1279
|
+
body: { items: input.items.map((item) => ({ productId: item.productId, quantity: item.quantity })) }
|
|
1280
|
+
});
|
|
1281
|
+
if (res.error) return res;
|
|
1282
|
+
if (res.data.newSessionToken) this.client.setCartSession(res.data.newSessionToken);
|
|
1283
|
+
this.client.emit("cart:updated", res.data);
|
|
1284
|
+
return res;
|
|
1285
|
+
}
|
|
1276
1286
|
/**
|
|
1277
1287
|
* Switch the CART currency server-side. The backend re-prices every line in
|
|
1278
1288
|
* the new currency (no FX conversion: a product must have a price configured
|
|
@@ -2952,6 +2962,14 @@ function useCart(options) {
|
|
|
2952
2962
|
await acceptCart(result);
|
|
2953
2963
|
}
|
|
2954
2964
|
});
|
|
2965
|
+
const addItemsMutation = (0, import_react_query12.useMutation)({
|
|
2966
|
+
mutationFn: (input) => unwrap(client.cart.addItems(input)),
|
|
2967
|
+
onMutate: cancelCartRead,
|
|
2968
|
+
onSuccess: async (result) => {
|
|
2969
|
+
if (result.newSessionToken) storage.set(STORAGE_KEYS.CART_SESSION, result.newSessionToken);
|
|
2970
|
+
await acceptCart(result);
|
|
2971
|
+
}
|
|
2972
|
+
});
|
|
2955
2973
|
const updateMutation = (0, import_react_query12.useMutation)({
|
|
2956
2974
|
mutationFn: async ({ itemId, quantity }) => {
|
|
2957
2975
|
return unwrap(client.cart.updateQuantity(itemId, quantity));
|
|
@@ -3070,6 +3088,7 @@ function useCart(options) {
|
|
|
3070
3088
|
error,
|
|
3071
3089
|
// Actions
|
|
3072
3090
|
addItem,
|
|
3091
|
+
addItems: addItemsMutation.mutateAsync,
|
|
3073
3092
|
updateQuantity,
|
|
3074
3093
|
removeItem,
|
|
3075
3094
|
clear,
|
|
@@ -3083,7 +3102,7 @@ function useCart(options) {
|
|
|
3083
3102
|
itemCount: cart?.itemCount ?? 0,
|
|
3084
3103
|
isEmpty: !cart || cart.items.length === 0 && (cart.bundleLines?.length ?? 0) === 0,
|
|
3085
3104
|
// Mutation states
|
|
3086
|
-
isAdding: addMutation.isPending,
|
|
3105
|
+
isAdding: addMutation.isPending || addItemsMutation.isPending,
|
|
3087
3106
|
isUpdating: updateMutation.isPending,
|
|
3088
3107
|
isRemoving: removeMutation.isPending,
|
|
3089
3108
|
isUpdatingBundle: addBundleMutation.isPending || updateBundleMutation.isPending || removeBundleMutation.isPending
|
package/dist/react.mjs
CHANGED
|
@@ -1150,6 +1150,16 @@ var CartModule = class {
|
|
|
1150
1150
|
this.client.emit("cart:updated", res.data);
|
|
1151
1151
|
return res;
|
|
1152
1152
|
}
|
|
1153
|
+
/** Add the complete selection atomically. Invalid/unavailable lines leave the cart unchanged. */
|
|
1154
|
+
async addItems(input) {
|
|
1155
|
+
const res = await this.client.request("POST", "/cart/items/batch", {
|
|
1156
|
+
body: { items: input.items.map((item) => ({ productId: item.productId, quantity: item.quantity })) }
|
|
1157
|
+
});
|
|
1158
|
+
if (res.error) return res;
|
|
1159
|
+
if (res.data.newSessionToken) this.client.setCartSession(res.data.newSessionToken);
|
|
1160
|
+
this.client.emit("cart:updated", res.data);
|
|
1161
|
+
return res;
|
|
1162
|
+
}
|
|
1153
1163
|
/**
|
|
1154
1164
|
* Switch the CART currency server-side. The backend re-prices every line in
|
|
1155
1165
|
* the new currency (no FX conversion: a product must have a price configured
|
|
@@ -2829,6 +2839,14 @@ function useCart(options) {
|
|
|
2829
2839
|
await acceptCart(result);
|
|
2830
2840
|
}
|
|
2831
2841
|
});
|
|
2842
|
+
const addItemsMutation = useMutation({
|
|
2843
|
+
mutationFn: (input) => unwrap(client.cart.addItems(input)),
|
|
2844
|
+
onMutate: cancelCartRead,
|
|
2845
|
+
onSuccess: async (result) => {
|
|
2846
|
+
if (result.newSessionToken) storage.set(STORAGE_KEYS.CART_SESSION, result.newSessionToken);
|
|
2847
|
+
await acceptCart(result);
|
|
2848
|
+
}
|
|
2849
|
+
});
|
|
2832
2850
|
const updateMutation = useMutation({
|
|
2833
2851
|
mutationFn: async ({ itemId, quantity }) => {
|
|
2834
2852
|
return unwrap(client.cart.updateQuantity(itemId, quantity));
|
|
@@ -2947,6 +2965,7 @@ function useCart(options) {
|
|
|
2947
2965
|
error,
|
|
2948
2966
|
// Actions
|
|
2949
2967
|
addItem,
|
|
2968
|
+
addItems: addItemsMutation.mutateAsync,
|
|
2950
2969
|
updateQuantity,
|
|
2951
2970
|
removeItem,
|
|
2952
2971
|
clear,
|
|
@@ -2960,7 +2979,7 @@ function useCart(options) {
|
|
|
2960
2979
|
itemCount: cart?.itemCount ?? 0,
|
|
2961
2980
|
isEmpty: !cart || cart.items.length === 0 && (cart.bundleLines?.length ?? 0) === 0,
|
|
2962
2981
|
// Mutation states
|
|
2963
|
-
isAdding: addMutation.isPending,
|
|
2982
|
+
isAdding: addMutation.isPending || addItemsMutation.isPending,
|
|
2964
2983
|
isUpdating: updateMutation.isPending,
|
|
2965
2984
|
isRemoving: removeMutation.isPending,
|
|
2966
2985
|
isUpdatingBundle: addBundleMutation.isPending || updateBundleMutation.isPending || removeBundleMutation.isPending
|