@putiikkipalvelu/storefront-sdk 0.2.4 → 0.3.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/index.cjs +183 -196
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +106 -108
- package/dist/index.d.ts +106 -108
- package/dist/index.js +176 -189
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -507,21 +507,6 @@ interface CalculatedCartItem {
|
|
|
507
507
|
/** Total quantity in cart */
|
|
508
508
|
totalQuantity: number;
|
|
509
509
|
}
|
|
510
|
-
/**
|
|
511
|
-
* Free shipping eligibility status
|
|
512
|
-
*/
|
|
513
|
-
interface FreeShippingStatus {
|
|
514
|
-
/** Whether the cart qualifies for free shipping */
|
|
515
|
-
isEligible: boolean;
|
|
516
|
-
/** Minimum spend required for free shipping (in cents) */
|
|
517
|
-
minimumSpend: number;
|
|
518
|
-
/** Amount remaining to qualify for free shipping (in cents) */
|
|
519
|
-
remainingAmount: number;
|
|
520
|
-
/** Name of the free shipping campaign */
|
|
521
|
-
campaignName?: string;
|
|
522
|
-
/** IDs of shipment methods eligible for free shipping (when isEligible is true) */
|
|
523
|
-
eligibleShipmentMethodIds?: string[];
|
|
524
|
-
}
|
|
525
510
|
/**
|
|
526
511
|
* Result of cart calculation with campaigns applied
|
|
527
512
|
*/
|
|
@@ -534,21 +519,18 @@ interface CartCalculationResult {
|
|
|
534
519
|
originalTotal: number;
|
|
535
520
|
/** Total savings from campaigns (in cents) */
|
|
536
521
|
totalSavings: number;
|
|
537
|
-
/** Free shipping eligibility status */
|
|
538
|
-
freeShipping: FreeShippingStatus;
|
|
539
522
|
}
|
|
540
523
|
|
|
541
524
|
/**
|
|
542
525
|
* Shipping Types
|
|
543
526
|
*
|
|
544
527
|
* Types for shipment methods and pickup locations.
|
|
545
|
-
*
|
|
528
|
+
* Uses unified response format that works with any provider (Shipit, custom, future integrations).
|
|
546
529
|
*/
|
|
547
|
-
|
|
548
530
|
/**
|
|
549
531
|
* Opening hours for a pickup location
|
|
550
532
|
*/
|
|
551
|
-
interface
|
|
533
|
+
interface OpeningHours {
|
|
552
534
|
monday: string[];
|
|
553
535
|
tuesday: string[];
|
|
554
536
|
wednesday: string[];
|
|
@@ -559,63 +541,82 @@ interface PickupLocationOpeningHours {
|
|
|
559
541
|
exceptions: string[];
|
|
560
542
|
}
|
|
561
543
|
/**
|
|
562
|
-
* A
|
|
563
|
-
* Returned from Shipit API with merchant pricing added
|
|
544
|
+
* A home delivery option (works for any provider)
|
|
564
545
|
*/
|
|
565
|
-
interface
|
|
566
|
-
/**
|
|
546
|
+
interface HomeDeliveryOption {
|
|
547
|
+
/** ShipmentMethods.id - unique identifier for this method */
|
|
567
548
|
id: string;
|
|
568
|
-
/**
|
|
549
|
+
/** Display name (e.g., "Posti Kotipaketti") */
|
|
550
|
+
name: string;
|
|
551
|
+
/** Optional description */
|
|
552
|
+
description: string | null;
|
|
553
|
+
/** Price in cents (0 if free shipping applies) */
|
|
554
|
+
price: number;
|
|
555
|
+
/** Original price in cents (always the base price before free shipping) */
|
|
556
|
+
originalPrice: number;
|
|
557
|
+
/** Free shipping threshold in cents, null = no free shipping available for this method */
|
|
558
|
+
freeShippingThreshold: number | null;
|
|
559
|
+
/** Carrier logo URL */
|
|
560
|
+
logo: string | null;
|
|
561
|
+
/** Provider type */
|
|
562
|
+
provider: "shipit" | "custom";
|
|
563
|
+
/** Carrier name (e.g., "Posti", "Matkahuolto") - null for custom methods */
|
|
564
|
+
carrier: string | null;
|
|
565
|
+
/** Estimated delivery time (e.g., "1-3") - null if not available */
|
|
566
|
+
estimatedDelivery: string | null;
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* A pickup point option (parcel locker, service point, etc.)
|
|
570
|
+
* Works for any provider that supports pickup locations.
|
|
571
|
+
*/
|
|
572
|
+
interface PickupPointOption {
|
|
573
|
+
/** Unique pickup point ID from carrier */
|
|
574
|
+
id: string;
|
|
575
|
+
/** ShipmentMethods.id - needed for checkout */
|
|
576
|
+
shipmentMethodId: string;
|
|
577
|
+
/** Shipit service ID - needed for checkout and shipment creation */
|
|
569
578
|
serviceId: string;
|
|
570
|
-
/** Location name */
|
|
579
|
+
/** Location name (e.g., "Lidl Graniittitalo") */
|
|
571
580
|
name: string;
|
|
572
581
|
/** Street address */
|
|
573
|
-
|
|
582
|
+
address: string;
|
|
574
583
|
/** City */
|
|
575
584
|
city: string;
|
|
576
585
|
/** Postal code */
|
|
577
|
-
|
|
578
|
-
/**
|
|
579
|
-
|
|
580
|
-
/**
|
|
581
|
-
|
|
586
|
+
postalCode: string;
|
|
587
|
+
/** Price in cents (0 if free shipping applies) */
|
|
588
|
+
price: number;
|
|
589
|
+
/** Original price in cents (always the base price before free shipping) */
|
|
590
|
+
originalPrice: number;
|
|
591
|
+
/** Free shipping threshold in cents, null = no free shipping available for this method */
|
|
592
|
+
freeShippingThreshold: number | null;
|
|
582
593
|
/** Carrier logo URL */
|
|
583
|
-
|
|
584
|
-
/**
|
|
585
|
-
|
|
586
|
-
/**
|
|
587
|
-
|
|
588
|
-
/** Distance from postal code in meters */
|
|
589
|
-
|
|
590
|
-
/** Distance from postal code in kilometers */
|
|
591
|
-
distanceInKilometers: number;
|
|
592
|
-
/** Location type */
|
|
593
|
-
type?: string;
|
|
594
|
+
logo: string | null;
|
|
595
|
+
/** Provider type */
|
|
596
|
+
provider: "shipit" | "custom";
|
|
597
|
+
/** Carrier name (e.g., "Posti", "Matkahuolto") */
|
|
598
|
+
carrier: string | null;
|
|
599
|
+
/** Distance from customer's postal code in meters */
|
|
600
|
+
distance: number | null;
|
|
594
601
|
/** Structured opening hours */
|
|
595
|
-
openingHours
|
|
596
|
-
/**
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
merchantPrice: number | null;
|
|
602
|
-
}
|
|
603
|
-
/**
|
|
604
|
-
* Response from GET /shipment-methods
|
|
605
|
-
*/
|
|
606
|
-
interface ShipmentMethodsResponse {
|
|
607
|
-
/** Available shipment methods */
|
|
608
|
-
shipmentMethods: ShipmentMethod[];
|
|
602
|
+
openingHours: OpeningHours | null;
|
|
603
|
+
/** GPS coordinates */
|
|
604
|
+
coordinates: {
|
|
605
|
+
lat: number;
|
|
606
|
+
lng: number;
|
|
607
|
+
} | null;
|
|
609
608
|
}
|
|
610
609
|
/**
|
|
611
610
|
* Response from GET /shipment-methods/[postalCode]
|
|
612
|
-
*
|
|
611
|
+
*
|
|
612
|
+
* Returns unified shipping options regardless of provider.
|
|
613
|
+
* Pickup points are sorted by distance, home delivery by price.
|
|
613
614
|
*/
|
|
614
|
-
interface
|
|
615
|
-
/**
|
|
616
|
-
|
|
617
|
-
/** Pickup
|
|
618
|
-
|
|
615
|
+
interface ShipmentMethodsResponse {
|
|
616
|
+
/** Home delivery options (sorted by price) */
|
|
617
|
+
homeDelivery: HomeDeliveryOption[];
|
|
618
|
+
/** Pickup point options (sorted by distance) */
|
|
619
|
+
pickupPoints: PickupPointOption[];
|
|
619
620
|
}
|
|
620
621
|
|
|
621
622
|
/**
|
|
@@ -1132,6 +1133,8 @@ interface CheckoutShipmentMethod {
|
|
|
1132
1133
|
shipmentMethodId: string;
|
|
1133
1134
|
/** ID of pickup point (for pickup delivery methods) */
|
|
1134
1135
|
pickupId: string | null;
|
|
1136
|
+
/** Shipit service ID (for Shipit pickup points) */
|
|
1137
|
+
serviceId: string | null;
|
|
1135
1138
|
}
|
|
1136
1139
|
/**
|
|
1137
1140
|
* Parameters for creating a checkout session
|
|
@@ -1692,71 +1695,69 @@ type CartResource = ReturnType<typeof createCartResource>;
|
|
|
1692
1695
|
/**
|
|
1693
1696
|
* Options for fetching shipment methods with weight-based filtering
|
|
1694
1697
|
*/
|
|
1695
|
-
interface
|
|
1696
|
-
/** Cart items - weight will be calculated automatically */
|
|
1698
|
+
interface GetShippingOptionsParams extends FetchOptions {
|
|
1699
|
+
/** Cart items - weight and total will be calculated automatically */
|
|
1697
1700
|
cartItems?: CartItem[];
|
|
1701
|
+
/** Active campaigns - used to calculate cart total with discounts for free shipping */
|
|
1702
|
+
campaigns?: Campaign[];
|
|
1703
|
+
/** Country code (default: "FI") */
|
|
1704
|
+
country?: string;
|
|
1698
1705
|
}
|
|
1699
1706
|
/**
|
|
1700
1707
|
* Shipping resource for fetching shipment methods and pickup locations
|
|
1701
1708
|
*/
|
|
1702
1709
|
declare function createShippingResource(fetcher: Fetcher): {
|
|
1703
1710
|
/**
|
|
1704
|
-
* Get
|
|
1705
|
-
* Returns
|
|
1711
|
+
* Get shipping options for a specific postal code.
|
|
1712
|
+
* Returns pickup points and home delivery options in a unified format.
|
|
1713
|
+
*
|
|
1714
|
+
* **Pickup points are returned first** as they are more popular in Finland.
|
|
1706
1715
|
*
|
|
1716
|
+
* @param postalCode - Customer's postal code (e.g., "00100")
|
|
1707
1717
|
* @param options - Fetch options including optional cartItems for weight-based filtering
|
|
1708
|
-
* @returns
|
|
1718
|
+
* @returns Unified shipping options (pickupPoints sorted by distance, homeDelivery sorted by price)
|
|
1709
1719
|
*
|
|
1710
1720
|
* @example
|
|
1711
1721
|
* ```typescript
|
|
1712
|
-
* const {
|
|
1722
|
+
* const { pickupPoints, homeDelivery } = await client.shipping.getOptions("00100");
|
|
1723
|
+
*
|
|
1724
|
+
* // Show pickup points (more popular in Finland)
|
|
1725
|
+
* pickupPoints.forEach(point => {
|
|
1726
|
+
* console.log(`${point.name} - ${point.carrier}`);
|
|
1727
|
+
* console.log(` ${point.address}, ${point.city}`);
|
|
1728
|
+
* console.log(` ${(point.distance! / 1000).toFixed(1)} km away`);
|
|
1729
|
+
* console.log(` Price: ${point.price / 100}€`);
|
|
1730
|
+
* });
|
|
1713
1731
|
*
|
|
1714
|
-
*
|
|
1715
|
-
*
|
|
1732
|
+
* // Show home delivery options
|
|
1733
|
+
* homeDelivery.forEach(option => {
|
|
1734
|
+
* console.log(`${option.name}: ${option.price / 100}€`);
|
|
1735
|
+
* if (option.estimatedDelivery) {
|
|
1736
|
+
* console.log(` Delivery: ${option.estimatedDelivery} days`);
|
|
1737
|
+
* }
|
|
1716
1738
|
* });
|
|
1717
1739
|
* ```
|
|
1718
1740
|
*
|
|
1719
1741
|
* @example Weight-based filtering
|
|
1720
1742
|
* ```typescript
|
|
1721
|
-
*
|
|
1722
|
-
* const { shipmentMethods } = await client.shipping.getMethods({
|
|
1743
|
+
* const options = await client.shipping.getOptions("00100", {
|
|
1723
1744
|
* cartItems: cartItems
|
|
1724
1745
|
* });
|
|
1746
|
+
* // Only shows methods that support the cart's total weight
|
|
1725
1747
|
* ```
|
|
1726
|
-
*/
|
|
1727
|
-
getMethods(options?: GetMethodsOptions): Promise<ShipmentMethodsResponse>;
|
|
1728
|
-
/**
|
|
1729
|
-
* Get shipment methods with pickup locations for a specific postal code.
|
|
1730
|
-
* Calls the Shipit API to fetch nearby pickup points (parcel lockers, etc.)
|
|
1731
1748
|
*
|
|
1732
|
-
* @
|
|
1733
|
-
* @param options - Fetch options including optional cartItems for weight-based filtering
|
|
1734
|
-
* @returns Shipment methods and nearby pickup locations with pricing
|
|
1735
|
-
*
|
|
1736
|
-
* @example
|
|
1749
|
+
* @example International shipping
|
|
1737
1750
|
* ```typescript
|
|
1738
|
-
* const
|
|
1739
|
-
*
|
|
1740
|
-
* // Show pickup locations
|
|
1741
|
-
* pricedLocations.forEach(location => {
|
|
1742
|
-
* console.log(`${location.name} - ${location.carrier}`);
|
|
1743
|
-
* console.log(` ${location.address1}, ${location.city}`);
|
|
1744
|
-
* console.log(` ${location.distanceInKilometers.toFixed(1)} km away`);
|
|
1745
|
-
* console.log(` Price: ${(location.merchantPrice ?? 0) / 100}€`);
|
|
1751
|
+
* const options = await client.shipping.getOptions("112 22", {
|
|
1752
|
+
* country: "SE"
|
|
1746
1753
|
* });
|
|
1747
1754
|
* ```
|
|
1748
|
-
*
|
|
1749
|
-
* @example Weight-based filtering with postal code
|
|
1750
|
-
* ```typescript
|
|
1751
|
-
* const { shipmentMethods, pricedLocations } = await client.shipping.getWithLocations(
|
|
1752
|
-
* "00100",
|
|
1753
|
-
* { cartItems: cartItems }
|
|
1754
|
-
* );
|
|
1755
|
-
*
|
|
1756
|
-
* // Only shows methods that support the cart's total weight
|
|
1757
|
-
* ```
|
|
1758
1755
|
*/
|
|
1759
|
-
|
|
1756
|
+
getOptions(postalCode: string, options?: GetShippingOptionsParams): Promise<ShipmentMethodsResponse>;
|
|
1757
|
+
/**
|
|
1758
|
+
* @deprecated Use getOptions() instead. This method is kept for backwards compatibility.
|
|
1759
|
+
*/
|
|
1760
|
+
getWithLocations(postalCode: string, options?: GetShippingOptionsParams): Promise<ShipmentMethodsResponse>;
|
|
1760
1761
|
};
|
|
1761
1762
|
/**
|
|
1762
1763
|
* Type for the shipping resource
|
|
@@ -2405,13 +2406,11 @@ declare function getPriceInfo(product: ProductDetail, variation?: ProductVariati
|
|
|
2405
2406
|
/**
|
|
2406
2407
|
* Calculate cart totals with campaign discounts applied.
|
|
2407
2408
|
*
|
|
2408
|
-
* Supports
|
|
2409
|
-
* - **FREE_SHIPPING**: Free shipping when cart total exceeds minimum spend
|
|
2410
|
-
* - **BUY_X_PAY_Y**: Buy X items, pay for Y (e.g., Buy 3 Pay 2 = 1 free item)
|
|
2409
|
+
* Supports BUY_X_PAY_Y campaigns: Buy X items, pay for Y (e.g., Buy 3 Pay 2 = 1 free item)
|
|
2411
2410
|
*
|
|
2412
2411
|
* @param items - Cart items to calculate
|
|
2413
2412
|
* @param campaigns - Active campaigns to apply
|
|
2414
|
-
* @returns Calculation result with totals
|
|
2413
|
+
* @returns Calculation result with totals and savings
|
|
2415
2414
|
*
|
|
2416
2415
|
* @example
|
|
2417
2416
|
* ```typescript
|
|
@@ -2419,7 +2418,6 @@ declare function getPriceInfo(product: ProductDetail, variation?: ProductVariati
|
|
|
2419
2418
|
*
|
|
2420
2419
|
* console.log(result.cartTotal); // 4990 (cents)
|
|
2421
2420
|
* console.log(result.totalSavings); // 1990 (cents)
|
|
2422
|
-
* console.log(result.freeShipping.isEligible); // true
|
|
2423
2421
|
*
|
|
2424
2422
|
* // Render calculated items
|
|
2425
2423
|
* result.calculatedItems.forEach(({ item, paidQuantity, freeQuantity }) => {
|
|
@@ -2472,4 +2470,4 @@ declare class VerificationRequiredError extends StorefrontError {
|
|
|
2472
2470
|
constructor(message: string, customerId: string);
|
|
2473
2471
|
}
|
|
2474
2472
|
|
|
2475
|
-
export { type AddToCartParams, type AddToWishlistResponse, AuthError, type BuyXPayYCampaign, type CalculatedCartItem, type Campaign, type CampaignType, type CartCalculationResult, type CartItem, type CartResponse, type CartSessionOptions, type CartValidationChanges, type CartValidationResponse, type Category, type CategoryReference, type CategoryResponse, type CheckoutCustomerData, type CheckoutErrorCode, type CheckoutErrorDetails, type CheckoutOptions, type CheckoutParams, type CheckoutShipmentMethod, type ConfirmationItemType, type ConfirmationOrderCustomerData, type ConfirmationOrderLineItem, type ConfirmationOrderShipmentMethod, type Customer, type CustomerOrder, type DeleteAccountResponse, type FeatureFlags, type FetchOptions, type ForgotPasswordResponse, type
|
|
2473
|
+
export { type AddToCartParams, type AddToWishlistResponse, AuthError, type BuyXPayYCampaign, type CalculatedCartItem, type Campaign, type CampaignType, type CartCalculationResult, type CartItem, type CartResponse, type CartSessionOptions, type CartValidationChanges, type CartValidationResponse, type Category, type CategoryReference, type CategoryResponse, type CheckoutCustomerData, type CheckoutErrorCode, type CheckoutErrorDetails, type CheckoutOptions, type CheckoutParams, type CheckoutShipmentMethod, type ConfirmationItemType, type ConfirmationOrderCustomerData, type ConfirmationOrderLineItem, type ConfirmationOrderShipmentMethod, type Customer, type CustomerOrder, type DeleteAccountResponse, type FeatureFlags, type FetchOptions, type ForgotPasswordResponse, type GetOrdersResponse, type GetUserResponse, type HomeDeliveryOption, type LoginOptions, type LoginResponse, type LoginVerificationRequiredResponse, type LogoutResponse, NotFoundError, type OpeningHours, type Order, type OrderLineItem, type OrderProductInfo, type OrderShipmentMethod, type OrderStatus, type PaymentConfig, type PaytrailCheckoutResponse, type PaytrailGroup, type PaytrailProvider, type PickupPointOption, type PriceInfo, type Product, type ProductCountResponse, type ProductDetail, type ProductListParams, type ProductListResponse, type ProductSortOption, type ProductVariation, type ProductVariationListing, RateLimitError, type RegisterData, type RegisterResponse, type RemoveFromCartParams, type RemoveFromWishlistResponse, type ResendVerificationResponse, type ResetPasswordResponse, type ShipitShippingMethod, type ShipmentMethod, type ShipmentMethodsResponse, type StoreConfig, type StoreInfo, type StoreSeo, type StorefrontClient, type StorefrontClientConfig, StorefrontError, type StripeCheckoutResponse, type UpdateCartQuantityParams, type UpdateProfileData, type UpdateProfileResponse, ValidationError, type VariationOption, VerificationRequiredError, type VerifyEmailResponse, type WishlistItem, type WishlistProduct, type WishlistResponse, type WishlistVariation, type WishlistVariationOption, calculateCartWithCampaigns, createStorefrontClient, getPriceInfo, isSaleActive };
|
package/dist/index.d.ts
CHANGED
|
@@ -507,21 +507,6 @@ interface CalculatedCartItem {
|
|
|
507
507
|
/** Total quantity in cart */
|
|
508
508
|
totalQuantity: number;
|
|
509
509
|
}
|
|
510
|
-
/**
|
|
511
|
-
* Free shipping eligibility status
|
|
512
|
-
*/
|
|
513
|
-
interface FreeShippingStatus {
|
|
514
|
-
/** Whether the cart qualifies for free shipping */
|
|
515
|
-
isEligible: boolean;
|
|
516
|
-
/** Minimum spend required for free shipping (in cents) */
|
|
517
|
-
minimumSpend: number;
|
|
518
|
-
/** Amount remaining to qualify for free shipping (in cents) */
|
|
519
|
-
remainingAmount: number;
|
|
520
|
-
/** Name of the free shipping campaign */
|
|
521
|
-
campaignName?: string;
|
|
522
|
-
/** IDs of shipment methods eligible for free shipping (when isEligible is true) */
|
|
523
|
-
eligibleShipmentMethodIds?: string[];
|
|
524
|
-
}
|
|
525
510
|
/**
|
|
526
511
|
* Result of cart calculation with campaigns applied
|
|
527
512
|
*/
|
|
@@ -534,21 +519,18 @@ interface CartCalculationResult {
|
|
|
534
519
|
originalTotal: number;
|
|
535
520
|
/** Total savings from campaigns (in cents) */
|
|
536
521
|
totalSavings: number;
|
|
537
|
-
/** Free shipping eligibility status */
|
|
538
|
-
freeShipping: FreeShippingStatus;
|
|
539
522
|
}
|
|
540
523
|
|
|
541
524
|
/**
|
|
542
525
|
* Shipping Types
|
|
543
526
|
*
|
|
544
527
|
* Types for shipment methods and pickup locations.
|
|
545
|
-
*
|
|
528
|
+
* Uses unified response format that works with any provider (Shipit, custom, future integrations).
|
|
546
529
|
*/
|
|
547
|
-
|
|
548
530
|
/**
|
|
549
531
|
* Opening hours for a pickup location
|
|
550
532
|
*/
|
|
551
|
-
interface
|
|
533
|
+
interface OpeningHours {
|
|
552
534
|
monday: string[];
|
|
553
535
|
tuesday: string[];
|
|
554
536
|
wednesday: string[];
|
|
@@ -559,63 +541,82 @@ interface PickupLocationOpeningHours {
|
|
|
559
541
|
exceptions: string[];
|
|
560
542
|
}
|
|
561
543
|
/**
|
|
562
|
-
* A
|
|
563
|
-
* Returned from Shipit API with merchant pricing added
|
|
544
|
+
* A home delivery option (works for any provider)
|
|
564
545
|
*/
|
|
565
|
-
interface
|
|
566
|
-
/**
|
|
546
|
+
interface HomeDeliveryOption {
|
|
547
|
+
/** ShipmentMethods.id - unique identifier for this method */
|
|
567
548
|
id: string;
|
|
568
|
-
/**
|
|
549
|
+
/** Display name (e.g., "Posti Kotipaketti") */
|
|
550
|
+
name: string;
|
|
551
|
+
/** Optional description */
|
|
552
|
+
description: string | null;
|
|
553
|
+
/** Price in cents (0 if free shipping applies) */
|
|
554
|
+
price: number;
|
|
555
|
+
/** Original price in cents (always the base price before free shipping) */
|
|
556
|
+
originalPrice: number;
|
|
557
|
+
/** Free shipping threshold in cents, null = no free shipping available for this method */
|
|
558
|
+
freeShippingThreshold: number | null;
|
|
559
|
+
/** Carrier logo URL */
|
|
560
|
+
logo: string | null;
|
|
561
|
+
/** Provider type */
|
|
562
|
+
provider: "shipit" | "custom";
|
|
563
|
+
/** Carrier name (e.g., "Posti", "Matkahuolto") - null for custom methods */
|
|
564
|
+
carrier: string | null;
|
|
565
|
+
/** Estimated delivery time (e.g., "1-3") - null if not available */
|
|
566
|
+
estimatedDelivery: string | null;
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* A pickup point option (parcel locker, service point, etc.)
|
|
570
|
+
* Works for any provider that supports pickup locations.
|
|
571
|
+
*/
|
|
572
|
+
interface PickupPointOption {
|
|
573
|
+
/** Unique pickup point ID from carrier */
|
|
574
|
+
id: string;
|
|
575
|
+
/** ShipmentMethods.id - needed for checkout */
|
|
576
|
+
shipmentMethodId: string;
|
|
577
|
+
/** Shipit service ID - needed for checkout and shipment creation */
|
|
569
578
|
serviceId: string;
|
|
570
|
-
/** Location name */
|
|
579
|
+
/** Location name (e.g., "Lidl Graniittitalo") */
|
|
571
580
|
name: string;
|
|
572
581
|
/** Street address */
|
|
573
|
-
|
|
582
|
+
address: string;
|
|
574
583
|
/** City */
|
|
575
584
|
city: string;
|
|
576
585
|
/** Postal code */
|
|
577
|
-
|
|
578
|
-
/**
|
|
579
|
-
|
|
580
|
-
/**
|
|
581
|
-
|
|
586
|
+
postalCode: string;
|
|
587
|
+
/** Price in cents (0 if free shipping applies) */
|
|
588
|
+
price: number;
|
|
589
|
+
/** Original price in cents (always the base price before free shipping) */
|
|
590
|
+
originalPrice: number;
|
|
591
|
+
/** Free shipping threshold in cents, null = no free shipping available for this method */
|
|
592
|
+
freeShippingThreshold: number | null;
|
|
582
593
|
/** Carrier logo URL */
|
|
583
|
-
|
|
584
|
-
/**
|
|
585
|
-
|
|
586
|
-
/**
|
|
587
|
-
|
|
588
|
-
/** Distance from postal code in meters */
|
|
589
|
-
|
|
590
|
-
/** Distance from postal code in kilometers */
|
|
591
|
-
distanceInKilometers: number;
|
|
592
|
-
/** Location type */
|
|
593
|
-
type?: string;
|
|
594
|
+
logo: string | null;
|
|
595
|
+
/** Provider type */
|
|
596
|
+
provider: "shipit" | "custom";
|
|
597
|
+
/** Carrier name (e.g., "Posti", "Matkahuolto") */
|
|
598
|
+
carrier: string | null;
|
|
599
|
+
/** Distance from customer's postal code in meters */
|
|
600
|
+
distance: number | null;
|
|
594
601
|
/** Structured opening hours */
|
|
595
|
-
openingHours
|
|
596
|
-
/**
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
merchantPrice: number | null;
|
|
602
|
-
}
|
|
603
|
-
/**
|
|
604
|
-
* Response from GET /shipment-methods
|
|
605
|
-
*/
|
|
606
|
-
interface ShipmentMethodsResponse {
|
|
607
|
-
/** Available shipment methods */
|
|
608
|
-
shipmentMethods: ShipmentMethod[];
|
|
602
|
+
openingHours: OpeningHours | null;
|
|
603
|
+
/** GPS coordinates */
|
|
604
|
+
coordinates: {
|
|
605
|
+
lat: number;
|
|
606
|
+
lng: number;
|
|
607
|
+
} | null;
|
|
609
608
|
}
|
|
610
609
|
/**
|
|
611
610
|
* Response from GET /shipment-methods/[postalCode]
|
|
612
|
-
*
|
|
611
|
+
*
|
|
612
|
+
* Returns unified shipping options regardless of provider.
|
|
613
|
+
* Pickup points are sorted by distance, home delivery by price.
|
|
613
614
|
*/
|
|
614
|
-
interface
|
|
615
|
-
/**
|
|
616
|
-
|
|
617
|
-
/** Pickup
|
|
618
|
-
|
|
615
|
+
interface ShipmentMethodsResponse {
|
|
616
|
+
/** Home delivery options (sorted by price) */
|
|
617
|
+
homeDelivery: HomeDeliveryOption[];
|
|
618
|
+
/** Pickup point options (sorted by distance) */
|
|
619
|
+
pickupPoints: PickupPointOption[];
|
|
619
620
|
}
|
|
620
621
|
|
|
621
622
|
/**
|
|
@@ -1132,6 +1133,8 @@ interface CheckoutShipmentMethod {
|
|
|
1132
1133
|
shipmentMethodId: string;
|
|
1133
1134
|
/** ID of pickup point (for pickup delivery methods) */
|
|
1134
1135
|
pickupId: string | null;
|
|
1136
|
+
/** Shipit service ID (for Shipit pickup points) */
|
|
1137
|
+
serviceId: string | null;
|
|
1135
1138
|
}
|
|
1136
1139
|
/**
|
|
1137
1140
|
* Parameters for creating a checkout session
|
|
@@ -1692,71 +1695,69 @@ type CartResource = ReturnType<typeof createCartResource>;
|
|
|
1692
1695
|
/**
|
|
1693
1696
|
* Options for fetching shipment methods with weight-based filtering
|
|
1694
1697
|
*/
|
|
1695
|
-
interface
|
|
1696
|
-
/** Cart items - weight will be calculated automatically */
|
|
1698
|
+
interface GetShippingOptionsParams extends FetchOptions {
|
|
1699
|
+
/** Cart items - weight and total will be calculated automatically */
|
|
1697
1700
|
cartItems?: CartItem[];
|
|
1701
|
+
/** Active campaigns - used to calculate cart total with discounts for free shipping */
|
|
1702
|
+
campaigns?: Campaign[];
|
|
1703
|
+
/** Country code (default: "FI") */
|
|
1704
|
+
country?: string;
|
|
1698
1705
|
}
|
|
1699
1706
|
/**
|
|
1700
1707
|
* Shipping resource for fetching shipment methods and pickup locations
|
|
1701
1708
|
*/
|
|
1702
1709
|
declare function createShippingResource(fetcher: Fetcher): {
|
|
1703
1710
|
/**
|
|
1704
|
-
* Get
|
|
1705
|
-
* Returns
|
|
1711
|
+
* Get shipping options for a specific postal code.
|
|
1712
|
+
* Returns pickup points and home delivery options in a unified format.
|
|
1713
|
+
*
|
|
1714
|
+
* **Pickup points are returned first** as they are more popular in Finland.
|
|
1706
1715
|
*
|
|
1716
|
+
* @param postalCode - Customer's postal code (e.g., "00100")
|
|
1707
1717
|
* @param options - Fetch options including optional cartItems for weight-based filtering
|
|
1708
|
-
* @returns
|
|
1718
|
+
* @returns Unified shipping options (pickupPoints sorted by distance, homeDelivery sorted by price)
|
|
1709
1719
|
*
|
|
1710
1720
|
* @example
|
|
1711
1721
|
* ```typescript
|
|
1712
|
-
* const {
|
|
1722
|
+
* const { pickupPoints, homeDelivery } = await client.shipping.getOptions("00100");
|
|
1723
|
+
*
|
|
1724
|
+
* // Show pickup points (more popular in Finland)
|
|
1725
|
+
* pickupPoints.forEach(point => {
|
|
1726
|
+
* console.log(`${point.name} - ${point.carrier}`);
|
|
1727
|
+
* console.log(` ${point.address}, ${point.city}`);
|
|
1728
|
+
* console.log(` ${(point.distance! / 1000).toFixed(1)} km away`);
|
|
1729
|
+
* console.log(` Price: ${point.price / 100}€`);
|
|
1730
|
+
* });
|
|
1713
1731
|
*
|
|
1714
|
-
*
|
|
1715
|
-
*
|
|
1732
|
+
* // Show home delivery options
|
|
1733
|
+
* homeDelivery.forEach(option => {
|
|
1734
|
+
* console.log(`${option.name}: ${option.price / 100}€`);
|
|
1735
|
+
* if (option.estimatedDelivery) {
|
|
1736
|
+
* console.log(` Delivery: ${option.estimatedDelivery} days`);
|
|
1737
|
+
* }
|
|
1716
1738
|
* });
|
|
1717
1739
|
* ```
|
|
1718
1740
|
*
|
|
1719
1741
|
* @example Weight-based filtering
|
|
1720
1742
|
* ```typescript
|
|
1721
|
-
*
|
|
1722
|
-
* const { shipmentMethods } = await client.shipping.getMethods({
|
|
1743
|
+
* const options = await client.shipping.getOptions("00100", {
|
|
1723
1744
|
* cartItems: cartItems
|
|
1724
1745
|
* });
|
|
1746
|
+
* // Only shows methods that support the cart's total weight
|
|
1725
1747
|
* ```
|
|
1726
|
-
*/
|
|
1727
|
-
getMethods(options?: GetMethodsOptions): Promise<ShipmentMethodsResponse>;
|
|
1728
|
-
/**
|
|
1729
|
-
* Get shipment methods with pickup locations for a specific postal code.
|
|
1730
|
-
* Calls the Shipit API to fetch nearby pickup points (parcel lockers, etc.)
|
|
1731
1748
|
*
|
|
1732
|
-
* @
|
|
1733
|
-
* @param options - Fetch options including optional cartItems for weight-based filtering
|
|
1734
|
-
* @returns Shipment methods and nearby pickup locations with pricing
|
|
1735
|
-
*
|
|
1736
|
-
* @example
|
|
1749
|
+
* @example International shipping
|
|
1737
1750
|
* ```typescript
|
|
1738
|
-
* const
|
|
1739
|
-
*
|
|
1740
|
-
* // Show pickup locations
|
|
1741
|
-
* pricedLocations.forEach(location => {
|
|
1742
|
-
* console.log(`${location.name} - ${location.carrier}`);
|
|
1743
|
-
* console.log(` ${location.address1}, ${location.city}`);
|
|
1744
|
-
* console.log(` ${location.distanceInKilometers.toFixed(1)} km away`);
|
|
1745
|
-
* console.log(` Price: ${(location.merchantPrice ?? 0) / 100}€`);
|
|
1751
|
+
* const options = await client.shipping.getOptions("112 22", {
|
|
1752
|
+
* country: "SE"
|
|
1746
1753
|
* });
|
|
1747
1754
|
* ```
|
|
1748
|
-
*
|
|
1749
|
-
* @example Weight-based filtering with postal code
|
|
1750
|
-
* ```typescript
|
|
1751
|
-
* const { shipmentMethods, pricedLocations } = await client.shipping.getWithLocations(
|
|
1752
|
-
* "00100",
|
|
1753
|
-
* { cartItems: cartItems }
|
|
1754
|
-
* );
|
|
1755
|
-
*
|
|
1756
|
-
* // Only shows methods that support the cart's total weight
|
|
1757
|
-
* ```
|
|
1758
1755
|
*/
|
|
1759
|
-
|
|
1756
|
+
getOptions(postalCode: string, options?: GetShippingOptionsParams): Promise<ShipmentMethodsResponse>;
|
|
1757
|
+
/**
|
|
1758
|
+
* @deprecated Use getOptions() instead. This method is kept for backwards compatibility.
|
|
1759
|
+
*/
|
|
1760
|
+
getWithLocations(postalCode: string, options?: GetShippingOptionsParams): Promise<ShipmentMethodsResponse>;
|
|
1760
1761
|
};
|
|
1761
1762
|
/**
|
|
1762
1763
|
* Type for the shipping resource
|
|
@@ -2405,13 +2406,11 @@ declare function getPriceInfo(product: ProductDetail, variation?: ProductVariati
|
|
|
2405
2406
|
/**
|
|
2406
2407
|
* Calculate cart totals with campaign discounts applied.
|
|
2407
2408
|
*
|
|
2408
|
-
* Supports
|
|
2409
|
-
* - **FREE_SHIPPING**: Free shipping when cart total exceeds minimum spend
|
|
2410
|
-
* - **BUY_X_PAY_Y**: Buy X items, pay for Y (e.g., Buy 3 Pay 2 = 1 free item)
|
|
2409
|
+
* Supports BUY_X_PAY_Y campaigns: Buy X items, pay for Y (e.g., Buy 3 Pay 2 = 1 free item)
|
|
2411
2410
|
*
|
|
2412
2411
|
* @param items - Cart items to calculate
|
|
2413
2412
|
* @param campaigns - Active campaigns to apply
|
|
2414
|
-
* @returns Calculation result with totals
|
|
2413
|
+
* @returns Calculation result with totals and savings
|
|
2415
2414
|
*
|
|
2416
2415
|
* @example
|
|
2417
2416
|
* ```typescript
|
|
@@ -2419,7 +2418,6 @@ declare function getPriceInfo(product: ProductDetail, variation?: ProductVariati
|
|
|
2419
2418
|
*
|
|
2420
2419
|
* console.log(result.cartTotal); // 4990 (cents)
|
|
2421
2420
|
* console.log(result.totalSavings); // 1990 (cents)
|
|
2422
|
-
* console.log(result.freeShipping.isEligible); // true
|
|
2423
2421
|
*
|
|
2424
2422
|
* // Render calculated items
|
|
2425
2423
|
* result.calculatedItems.forEach(({ item, paidQuantity, freeQuantity }) => {
|
|
@@ -2472,4 +2470,4 @@ declare class VerificationRequiredError extends StorefrontError {
|
|
|
2472
2470
|
constructor(message: string, customerId: string);
|
|
2473
2471
|
}
|
|
2474
2472
|
|
|
2475
|
-
export { type AddToCartParams, type AddToWishlistResponse, AuthError, type BuyXPayYCampaign, type CalculatedCartItem, type Campaign, type CampaignType, type CartCalculationResult, type CartItem, type CartResponse, type CartSessionOptions, type CartValidationChanges, type CartValidationResponse, type Category, type CategoryReference, type CategoryResponse, type CheckoutCustomerData, type CheckoutErrorCode, type CheckoutErrorDetails, type CheckoutOptions, type CheckoutParams, type CheckoutShipmentMethod, type ConfirmationItemType, type ConfirmationOrderCustomerData, type ConfirmationOrderLineItem, type ConfirmationOrderShipmentMethod, type Customer, type CustomerOrder, type DeleteAccountResponse, type FeatureFlags, type FetchOptions, type ForgotPasswordResponse, type
|
|
2473
|
+
export { type AddToCartParams, type AddToWishlistResponse, AuthError, type BuyXPayYCampaign, type CalculatedCartItem, type Campaign, type CampaignType, type CartCalculationResult, type CartItem, type CartResponse, type CartSessionOptions, type CartValidationChanges, type CartValidationResponse, type Category, type CategoryReference, type CategoryResponse, type CheckoutCustomerData, type CheckoutErrorCode, type CheckoutErrorDetails, type CheckoutOptions, type CheckoutParams, type CheckoutShipmentMethod, type ConfirmationItemType, type ConfirmationOrderCustomerData, type ConfirmationOrderLineItem, type ConfirmationOrderShipmentMethod, type Customer, type CustomerOrder, type DeleteAccountResponse, type FeatureFlags, type FetchOptions, type ForgotPasswordResponse, type GetOrdersResponse, type GetUserResponse, type HomeDeliveryOption, type LoginOptions, type LoginResponse, type LoginVerificationRequiredResponse, type LogoutResponse, NotFoundError, type OpeningHours, type Order, type OrderLineItem, type OrderProductInfo, type OrderShipmentMethod, type OrderStatus, type PaymentConfig, type PaytrailCheckoutResponse, type PaytrailGroup, type PaytrailProvider, type PickupPointOption, type PriceInfo, type Product, type ProductCountResponse, type ProductDetail, type ProductListParams, type ProductListResponse, type ProductSortOption, type ProductVariation, type ProductVariationListing, RateLimitError, type RegisterData, type RegisterResponse, type RemoveFromCartParams, type RemoveFromWishlistResponse, type ResendVerificationResponse, type ResetPasswordResponse, type ShipitShippingMethod, type ShipmentMethod, type ShipmentMethodsResponse, type StoreConfig, type StoreInfo, type StoreSeo, type StorefrontClient, type StorefrontClientConfig, StorefrontError, type StripeCheckoutResponse, type UpdateCartQuantityParams, type UpdateProfileData, type UpdateProfileResponse, ValidationError, type VariationOption, VerificationRequiredError, type VerifyEmailResponse, type WishlistItem, type WishlistProduct, type WishlistResponse, type WishlistVariation, type WishlistVariationOption, calculateCartWithCampaigns, createStorefrontClient, getPriceInfo, isSaleActive };
|