Carts
Cart and cart item collections
Carts
carts
Stores shopping cart information. Supports the cart-to-order conversion flow.
| Field | Type | Description | Required |
|---|---|---|---|
customer | relationship | Customer reference (customers) | |
status | select | Status: active, completed, abandoned (default: active) | |
shippingAddress | group | Shipping address | |
discountCode | text | Discount code | |
itemsTotal | number | Items subtotal (read-only) | |
shippingFee | number | Shipping fee (default: 0) | |
discountAmount | number | Discount amount (default: 0) | |
totalAmount | number | Total amount (read-only) | |
expiresAt | date | Expiration date | |
items | join | Cart items (cart-items) |
Shipping Address (shippingAddress):
| Field | Type | Description | Required |
|---|---|---|---|
recipientName | text | Recipient name | |
phone | text | Phone number | |
postalCode | text | Postal code | |
address1 | text | Address | |
address2 | text | Detailed address | |
deliveryMessage | text | Delivery message |
// Get active cart
const response = await client.from('carts').find({
where: {
customer: { equals: customerId },
status: { equals: 'active' }
}
})cart-items
Stores items in a shopping cart.
| Field | Type | Description | Required |
|---|---|---|---|
cart | relationship | Cart reference (carts) | ✓ |
product | relationship | Product reference (products) | ✓ |
variant | relationship | Variant reference (product-variants) | |
option | relationship | Option reference (product-options) | |
quantity | number | Quantity (min: 1) | ✓ |
unitPrice | number | Unit price (min: 0) | ✓ |
// Add item to cart
const item = await client.from('cart-items').create({
cart: cartId,
product: productId,
variant: variantId,
quantity: 2,
unitPrice: 15000
})
// Get cart items
const response = await client.from('cart-items').find({
where: { cart: { equals: cartId } }
})