MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / addToCart

Function addToCart

apps/testbed/src/App.tsx:70–86  ·  view source on GitHub ↗
(product: Product)

Source from the content-addressed store, hash-verified

68 }
69
70 function addToCart(product: Product) {
71 setCart((prev) => {
72 const existing = prev.find((i) => i.id === product.id);
73 if (existing) {
74 return prev.map((i) =>
75 i.id === product.id ? { ...i, qty: i.qty + 1 } : i
76 );
77 }
78 return [...prev, { ...product, qty: 1 }];
79 });
80 op.track('add_to_cart', {
81 product_id: product.id,
82 product_name: product.name,
83 price: product.price,
84 category: product.category,
85 });
86 }
87
88 function removeFromCart(id: string) {
89 const item = cart.find((i) => i.id === id);

Callers

nothing calls this directly

Calls 2

mapMethod · 0.45
trackMethod · 0.45

Tested by

no test coverage detected