fullcart
Version:
Add stripe checkout to any website
15 lines (12 loc) • 487 B
text/typescript
import type { Product } from '../schemas/productSchema'
import { customer } from '../stores/customer'
import { updateQuantity } from './updateQuantity'
export const addItem = async (productId: Product['id']) => {
const $customer = customer.get()
const found = $customer.lines.find((line) => line.productId === productId)
if (found) updateQuantity(productId, 1)
else {
const added = [...$customer.lines, { productId, quantity: 1 }]
customer.setKey('lines', added)
}
}