omni-sync-sdk 0.8.1 → 0.8.2
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 +20 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -106,7 +106,14 @@ await omni.addToCart(cart.id, {
|
|
|
106
106
|
// 4. Create checkout from cart
|
|
107
107
|
const checkout = await omni.createCheckout({ cartId: cart.id });
|
|
108
108
|
|
|
109
|
-
// 5. Set
|
|
109
|
+
// 5. Set customer info (REQUIRED - email is needed for order!)
|
|
110
|
+
await omni.setCheckoutCustomer(checkout.id, {
|
|
111
|
+
email: 'customer@example.com',
|
|
112
|
+
firstName: 'John',
|
|
113
|
+
lastName: 'Doe',
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// 6. Set shipping address
|
|
110
117
|
await omni.setShippingAddress(checkout.id, {
|
|
111
118
|
firstName: 'John',
|
|
112
119
|
lastName: 'Doe',
|
|
@@ -116,11 +123,11 @@ await omni.setShippingAddress(checkout.id, {
|
|
|
116
123
|
country: 'US',
|
|
117
124
|
});
|
|
118
125
|
|
|
119
|
-
//
|
|
126
|
+
// 7. Get shipping rates and select one
|
|
120
127
|
const rates = await omni.getShippingRates(checkout.id);
|
|
121
128
|
await omni.selectShippingMethod(checkout.id, rates[0].id);
|
|
122
129
|
|
|
123
|
-
//
|
|
130
|
+
// 8. Complete checkout - order is linked to customer!
|
|
124
131
|
const { orderId } = await omni.completeCheckout(checkout.id);
|
|
125
132
|
console.log('Order created:', orderId);
|
|
126
133
|
|
|
@@ -2009,16 +2016,23 @@ export default function CheckoutPage() {
|
|
|
2009
2016
|
if (customerLoggedIn && checkoutId) {
|
|
2010
2017
|
// ===== LOGGED-IN CUSTOMER: Server Checkout =====
|
|
2011
2018
|
|
|
2012
|
-
// 1. Set
|
|
2019
|
+
// 1. Set customer info (REQUIRED - even for logged-in customers!)
|
|
2020
|
+
await omni.setCheckoutCustomer(checkoutId, {
|
|
2021
|
+
email: email, // Get from form or customer profile
|
|
2022
|
+
firstName: shippingAddress.firstName,
|
|
2023
|
+
lastName: shippingAddress.lastName,
|
|
2024
|
+
});
|
|
2025
|
+
|
|
2026
|
+
// 2. Set shipping address
|
|
2013
2027
|
await omni.setShippingAddress(checkoutId, shippingAddress);
|
|
2014
2028
|
|
|
2015
|
-
//
|
|
2029
|
+
// 3. Get and select shipping rate
|
|
2016
2030
|
const rates = await omni.getShippingRates(checkoutId);
|
|
2017
2031
|
if (rates.length > 0) {
|
|
2018
2032
|
await omni.selectShippingMethod(checkoutId, selectedRate || rates[0].id);
|
|
2019
2033
|
}
|
|
2020
2034
|
|
|
2021
|
-
//
|
|
2035
|
+
// 4. Complete checkout - ORDER IS LINKED TO CUSTOMER!
|
|
2022
2036
|
const { orderId } = await omni.completeCheckout(checkoutId);
|
|
2023
2037
|
|
|
2024
2038
|
// Clear cart ID
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omni-sync-sdk",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
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",
|