import { AIStoreStorefront, AIStoreApiError } from "@ab-ecosystem/aistore-storefront";
const store = new AIStoreStorefront({
baseUrl: "https://api.your-domain.com",
origin: "https://shop.your-domain.com",
accessToken: saved?.access_token,
refreshToken: saved?.refresh_token,
onTokensChanged: (tokens) => save(tokens),
});
const { data: products } = await store.products.fetch({ status: "publish", page: 1, size: 24 });
const results = await store.search.fuzzy({ q: "blue shirt", limit: 10 });
await store.customers.login({ phone_no: "919876543210", password: "secret" });
const me = await store.customers.me();
await store.cart.batch({
operations: [{ action: "add", product_id, variant_id, quantity: 2 }],
});
const cart = await store.cart.populate();
const order = await store.orders.create({
userType: "logged_in",
personalDetails: { fullname: "Asha", email: "[email protected]", phone: "919876543210" },
shipping: { address_1: "12 MG Road", city: "Bengaluru", state: "KA", zipCode: "560001", country: "IN" },
summary: { total: 1298, tax: 0, shipping_charge: 0, currency: "INR" },
items: [{ product_id, variant_id, quantity: 2, price: 649 }],
payment: { method: "cod" },
});