Remove from Cart
Remove an item from the cart.
Updated
On this page
Overview
Remove a specific item from the cart by its size ID.
SDK Usage
import dash from "@/lib/dash"
const { message, cart } = await dash.cart.remove("size_1g")
// message = "Item removed"
// cart = updated cart state
Clear Entire Cart
Remove all items at once:
const { message, cart } = await dash.cart.clear()
// Cart is now empty
Reset Local State
Clear the SDK's local cart reference without touching the server:
dash.cart.reset()
// Clears cartId from localStorage — next add() creates a new cart
REST API
# Remove single item
POST /storefront/cart/{cart_id}/remove/{size_id}
X-API-Key: pk_live_your_key
# Clear all items
POST /storefront/cart/{cart_id}/clear
X-API-Key: pk_live_your_key
Cart Item with Remove Button
"use client"
import dash from "@/lib/dash"
export function CartItem({ item, onUpdate }) {
async function handleRemove() {
await dash.cart.remove(item.size_id)
onUpdate()
}
return (
<div className="flex items-center justify-between">
<div>
<p>{item.product_name} — {item.size_label}</p>
<p>${item.unit_price} × {item.quantity}</p>
</div>
<button onClick={handleRemove} className="text-red-500">Remove</button>
</div>
)
}
Next Steps
- Apply Discount Code — Add a coupon to the cart
- Create Order — Proceed to checkout