mirror of
https://github.com/vercel/commerce.git
synced 2025-07-25 11:11:24 +00:00
pass pricing to addItem call for verification and update cart API URL
Signed-off-by: Loan Laux <loan@outgrow.io>
This commit is contained in:
@@ -29,9 +29,16 @@ const ProductSidebar: FC<ProductSidebarProps> = ({ product, className }) => {
|
||||
const addToCart = async () => {
|
||||
setLoading(true)
|
||||
try {
|
||||
console.log("product", product)
|
||||
console.log("variant", variant)
|
||||
|
||||
await addItem({
|
||||
productId: String(product.id),
|
||||
variantId: String(variant ? variant.id : product.variants[0].id),
|
||||
pricing: {
|
||||
amount: variant ? Number.parseFloat(variant.price) : Number.parseFloat(product.price.value),
|
||||
currencyCode: String(product.price.currencyCode),
|
||||
}
|
||||
})
|
||||
openSidebar()
|
||||
setLoading(false)
|
||||
|
Reference in New Issue
Block a user