Create, deploy, and see your first component live in 5 minutes
npm install -g @ollie-shop/cli && ollieshop login
ollieshop component create cart-upsell && cd cart-upsell
import { useCheckoutSession } from '@ollie-shop/sdk'; export default function CartUpsell() { const { cart, addToCart } = useCheckoutSession(); // Smart upsell: if cart has tops, show matching bottoms const upsellProduct = cart.items.some(item => item.category === 'tops') ? { id: 'jeans-001', name: 'Classic Jeans', price: 7900 } : { id: 'tshirt-001', name: 'Basic Tee', price: 2900 }; return ( <div className="p-4 border rounded-lg bg-blue-50"> <h3 className="font-semibold mb-2">Complete Your Look</h3> <div className="flex items-center gap-3"> <div className="flex-1"> <p className="font-medium">{upsellProduct.name}</p> <p className="text-lg">${(upsellProduct.price / 100).toFixed(2)}</p> </div> <button onClick={() => addToCart(upsellProduct)} className="px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700" > Add to Cart </button> </div> </div> ); }
npm run dev
http://localhost:3000
npm run build && ollieshop component deploy --slot cart_sidebar