omni-sync-sdk 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -16
- package/dist/index.d.mts +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.js +28 -4
- package/dist/index.mjs +28 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -449,6 +449,8 @@ console.log(order.message); // 'Order created successfully'
|
|
|
449
449
|
// Cart is automatically cleared after successful order
|
|
450
450
|
```
|
|
451
451
|
|
|
452
|
+
> **🔄 Automatic Tracking:** If "Track Guest Checkouts" is enabled in your connection settings (OmniSync Admin), `submitGuestOrder()` will automatically create a tracked checkout session before placing the order. This allows you to see abandoned carts and checkout sessions in your admin dashboard - **no code changes needed!**
|
|
453
|
+
|
|
452
454
|
#### Keep Cart After Order
|
|
453
455
|
|
|
454
456
|
```typescript
|
|
@@ -498,31 +500,26 @@ interface GuestOrderResponse {
|
|
|
498
500
|
|
|
499
501
|
---
|
|
500
502
|
|
|
501
|
-
### Tracked Guest Checkout (
|
|
503
|
+
### Tracked Guest Checkout (Automatic)
|
|
504
|
+
|
|
505
|
+
> **Note:** As of SDK v0.7.1, `submitGuestOrder()` automatically handles tracking. You don't need to use these methods unless you want explicit control over the checkout flow.
|
|
502
506
|
|
|
503
|
-
|
|
507
|
+
When **"Track Guest Checkouts"** is enabled in your connection settings, checkout sessions are automatically created on the server, allowing:
|
|
504
508
|
|
|
505
|
-
When enabled, checkout sessions are created on the server, allowing:
|
|
506
509
|
- Visibility of checkout sessions in admin dashboard
|
|
507
510
|
- Abandoned cart tracking
|
|
508
511
|
- Future: abandoned cart recovery emails
|
|
509
512
|
|
|
510
|
-
####
|
|
513
|
+
#### How to Enable
|
|
511
514
|
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
+
1. Go to OmniSync Admin → Integrations → Vibe-Coded Sites
|
|
516
|
+
2. Click on your connection → Settings
|
|
517
|
+
3. Enable "Track Guest Checkouts"
|
|
518
|
+
4. Save - that's it! No code changes needed.
|
|
515
519
|
|
|
516
|
-
|
|
517
|
-
// Tracking is enabled - use tracked flow
|
|
518
|
-
console.log('Checkout session created:', result.checkoutId);
|
|
519
|
-
} else {
|
|
520
|
-
// Tracking not enabled - use regular flow
|
|
521
|
-
console.log('Using local-only checkout');
|
|
522
|
-
}
|
|
523
|
-
```
|
|
520
|
+
#### Advanced: Manual Tracking Control
|
|
524
521
|
|
|
525
|
-
|
|
522
|
+
If you need explicit control over the tracking flow (e.g., to track checkout steps before the user places an order):
|
|
526
523
|
|
|
527
524
|
```typescript
|
|
528
525
|
// 1. Start tracked checkout (sends cart items to server)
|
package/dist/index.d.mts
CHANGED
|
@@ -1983,7 +1983,10 @@ declare class OmniSyncClient {
|
|
|
1983
1983
|
/**
|
|
1984
1984
|
* Create order directly from local cart (guest checkout)
|
|
1985
1985
|
* This is the main checkout method for vibe-coded sites!
|
|
1986
|
-
*
|
|
1986
|
+
*
|
|
1987
|
+
* **Automatic Tracking:** If "Track Guest Checkouts" is enabled in the connection
|
|
1988
|
+
* settings, this method will automatically create a tracked checkout session
|
|
1989
|
+
* (visible in admin) before creating the order. No code changes needed!
|
|
1987
1990
|
*
|
|
1988
1991
|
* @example
|
|
1989
1992
|
* ```typescript
|
|
@@ -1992,12 +1995,11 @@ declare class OmniSyncClient {
|
|
|
1992
1995
|
* omni.setLocalCartCustomer({ email: 'john@example.com', firstName: 'John' });
|
|
1993
1996
|
* omni.setLocalCartShippingAddress({ ... });
|
|
1994
1997
|
*
|
|
1995
|
-
* // Then submit the order
|
|
1998
|
+
* // Then submit the order - tracking is automatic if enabled in admin!
|
|
1996
1999
|
* const result = await omni.submitGuestOrder();
|
|
1997
2000
|
* console.log('Order created:', result.orderId);
|
|
1998
2001
|
*
|
|
1999
|
-
* //
|
|
2000
|
-
* omni.clearLocalCart();
|
|
2002
|
+
* // Cart is automatically cleared on success
|
|
2001
2003
|
* ```
|
|
2002
2004
|
*/
|
|
2003
2005
|
submitGuestOrder(options?: {
|
package/dist/index.d.ts
CHANGED
|
@@ -1983,7 +1983,10 @@ declare class OmniSyncClient {
|
|
|
1983
1983
|
/**
|
|
1984
1984
|
* Create order directly from local cart (guest checkout)
|
|
1985
1985
|
* This is the main checkout method for vibe-coded sites!
|
|
1986
|
-
*
|
|
1986
|
+
*
|
|
1987
|
+
* **Automatic Tracking:** If "Track Guest Checkouts" is enabled in the connection
|
|
1988
|
+
* settings, this method will automatically create a tracked checkout session
|
|
1989
|
+
* (visible in admin) before creating the order. No code changes needed!
|
|
1987
1990
|
*
|
|
1988
1991
|
* @example
|
|
1989
1992
|
* ```typescript
|
|
@@ -1992,12 +1995,11 @@ declare class OmniSyncClient {
|
|
|
1992
1995
|
* omni.setLocalCartCustomer({ email: 'john@example.com', firstName: 'John' });
|
|
1993
1996
|
* omni.setLocalCartShippingAddress({ ... });
|
|
1994
1997
|
*
|
|
1995
|
-
* // Then submit the order
|
|
1998
|
+
* // Then submit the order - tracking is automatic if enabled in admin!
|
|
1996
1999
|
* const result = await omni.submitGuestOrder();
|
|
1997
2000
|
* console.log('Order created:', result.orderId);
|
|
1998
2001
|
*
|
|
1999
|
-
* //
|
|
2000
|
-
* omni.clearLocalCart();
|
|
2002
|
+
* // Cart is automatically cleared on success
|
|
2001
2003
|
* ```
|
|
2002
2004
|
*/
|
|
2003
2005
|
submitGuestOrder(options?: {
|
package/dist/index.js
CHANGED
|
@@ -1705,7 +1705,10 @@ var OmniSyncClient = class {
|
|
|
1705
1705
|
/**
|
|
1706
1706
|
* Create order directly from local cart (guest checkout)
|
|
1707
1707
|
* This is the main checkout method for vibe-coded sites!
|
|
1708
|
-
*
|
|
1708
|
+
*
|
|
1709
|
+
* **Automatic Tracking:** If "Track Guest Checkouts" is enabled in the connection
|
|
1710
|
+
* settings, this method will automatically create a tracked checkout session
|
|
1711
|
+
* (visible in admin) before creating the order. No code changes needed!
|
|
1709
1712
|
*
|
|
1710
1713
|
* @example
|
|
1711
1714
|
* ```typescript
|
|
@@ -1714,12 +1717,11 @@ var OmniSyncClient = class {
|
|
|
1714
1717
|
* omni.setLocalCartCustomer({ email: 'john@example.com', firstName: 'John' });
|
|
1715
1718
|
* omni.setLocalCartShippingAddress({ ... });
|
|
1716
1719
|
*
|
|
1717
|
-
* // Then submit the order
|
|
1720
|
+
* // Then submit the order - tracking is automatic if enabled in admin!
|
|
1718
1721
|
* const result = await omni.submitGuestOrder();
|
|
1719
1722
|
* console.log('Order created:', result.orderId);
|
|
1720
1723
|
*
|
|
1721
|
-
* //
|
|
1722
|
-
* omni.clearLocalCart();
|
|
1724
|
+
* // Cart is automatically cleared on success
|
|
1723
1725
|
* ```
|
|
1724
1726
|
*/
|
|
1725
1727
|
async submitGuestOrder(options) {
|
|
@@ -1733,6 +1735,28 @@ var OmniSyncClient = class {
|
|
|
1733
1735
|
if (!cart.shippingAddress) {
|
|
1734
1736
|
throw new OmniSyncError("Shipping address is required", 400);
|
|
1735
1737
|
}
|
|
1738
|
+
try {
|
|
1739
|
+
const trackingResult = await this.startGuestCheckout();
|
|
1740
|
+
if (trackingResult.tracked) {
|
|
1741
|
+
await this.updateGuestCheckoutAddress(trackingResult.checkoutId, {
|
|
1742
|
+
shippingAddress: cart.shippingAddress,
|
|
1743
|
+
billingAddress: cart.billingAddress
|
|
1744
|
+
});
|
|
1745
|
+
const orderResult = await this.completeGuestCheckout(trackingResult.checkoutId, {
|
|
1746
|
+
clearCartOnSuccess: options?.clearCartOnSuccess
|
|
1747
|
+
});
|
|
1748
|
+
return {
|
|
1749
|
+
orderId: orderResult.orderId,
|
|
1750
|
+
orderNumber: orderResult.orderId,
|
|
1751
|
+
// Will be overwritten by actual order number if returned
|
|
1752
|
+
status: "pending",
|
|
1753
|
+
total: 0,
|
|
1754
|
+
// Actual total comes from server
|
|
1755
|
+
message: "Order created successfully (tracked)"
|
|
1756
|
+
};
|
|
1757
|
+
}
|
|
1758
|
+
} catch {
|
|
1759
|
+
}
|
|
1736
1760
|
const orderData = {
|
|
1737
1761
|
items: cart.items.map((item) => ({
|
|
1738
1762
|
productId: item.productId,
|
package/dist/index.mjs
CHANGED
|
@@ -1680,7 +1680,10 @@ var OmniSyncClient = class {
|
|
|
1680
1680
|
/**
|
|
1681
1681
|
* Create order directly from local cart (guest checkout)
|
|
1682
1682
|
* This is the main checkout method for vibe-coded sites!
|
|
1683
|
-
*
|
|
1683
|
+
*
|
|
1684
|
+
* **Automatic Tracking:** If "Track Guest Checkouts" is enabled in the connection
|
|
1685
|
+
* settings, this method will automatically create a tracked checkout session
|
|
1686
|
+
* (visible in admin) before creating the order. No code changes needed!
|
|
1684
1687
|
*
|
|
1685
1688
|
* @example
|
|
1686
1689
|
* ```typescript
|
|
@@ -1689,12 +1692,11 @@ var OmniSyncClient = class {
|
|
|
1689
1692
|
* omni.setLocalCartCustomer({ email: 'john@example.com', firstName: 'John' });
|
|
1690
1693
|
* omni.setLocalCartShippingAddress({ ... });
|
|
1691
1694
|
*
|
|
1692
|
-
* // Then submit the order
|
|
1695
|
+
* // Then submit the order - tracking is automatic if enabled in admin!
|
|
1693
1696
|
* const result = await omni.submitGuestOrder();
|
|
1694
1697
|
* console.log('Order created:', result.orderId);
|
|
1695
1698
|
*
|
|
1696
|
-
* //
|
|
1697
|
-
* omni.clearLocalCart();
|
|
1699
|
+
* // Cart is automatically cleared on success
|
|
1698
1700
|
* ```
|
|
1699
1701
|
*/
|
|
1700
1702
|
async submitGuestOrder(options) {
|
|
@@ -1708,6 +1710,28 @@ var OmniSyncClient = class {
|
|
|
1708
1710
|
if (!cart.shippingAddress) {
|
|
1709
1711
|
throw new OmniSyncError("Shipping address is required", 400);
|
|
1710
1712
|
}
|
|
1713
|
+
try {
|
|
1714
|
+
const trackingResult = await this.startGuestCheckout();
|
|
1715
|
+
if (trackingResult.tracked) {
|
|
1716
|
+
await this.updateGuestCheckoutAddress(trackingResult.checkoutId, {
|
|
1717
|
+
shippingAddress: cart.shippingAddress,
|
|
1718
|
+
billingAddress: cart.billingAddress
|
|
1719
|
+
});
|
|
1720
|
+
const orderResult = await this.completeGuestCheckout(trackingResult.checkoutId, {
|
|
1721
|
+
clearCartOnSuccess: options?.clearCartOnSuccess
|
|
1722
|
+
});
|
|
1723
|
+
return {
|
|
1724
|
+
orderId: orderResult.orderId,
|
|
1725
|
+
orderNumber: orderResult.orderId,
|
|
1726
|
+
// Will be overwritten by actual order number if returned
|
|
1727
|
+
status: "pending",
|
|
1728
|
+
total: 0,
|
|
1729
|
+
// Actual total comes from server
|
|
1730
|
+
message: "Order created successfully (tracked)"
|
|
1731
|
+
};
|
|
1732
|
+
}
|
|
1733
|
+
} catch {
|
|
1734
|
+
}
|
|
1711
1735
|
const orderData = {
|
|
1712
1736
|
items: cart.items.map((item) => ({
|
|
1713
1737
|
productId: item.productId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omni-sync-sdk",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Official SDK for building e-commerce storefronts with OmniSync Platform. Perfect for vibe-coded sites, AI-built stores (Cursor, Lovable, v0), and custom storefronts.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|