Hooks
Ez az oldal még csak angolul érhető el.
The hooks of @poltura/theme-sdk/cart.
Ezen az oldalon
import { … } from '@poltura/theme-sdk/cart';useCart
The cart with its actions, usable anywhere on the storefront.
useCart(): CartStateMutations run on the host; removing a line emits the remove-from-cart event and checkout the begin-checkout event.
Returns: The cart, its status and the actions that change it.
Example
import { useCart } from '@poltura/theme-sdk/cart';
export function CartCount() {
const { cart } = useCart();
return <span>{cart?.itemCount ?? 0}</span>;
}useCartPage
What the cart page shows beside the cart: recommendations, the minimum order and a changed bundle price.
useCartPage(): CartPageViewReturns: The page extras; recommendations are empty outside the cart page.
Example
import { MinimumOrderNotice, useCartPage } from '@poltura/theme-sdk/cart';
export function CartMinimum() {
const { minimumOrder } = useCartPage();
return minimumOrder === null ? null : <MinimumOrderNotice minimum={minimumOrder} />;
}