forked from crowetic/commerce
* Remove duplicated css rules. (#185) * Fix typo in the Marquee component (#176) Co-authored-by: Hugo Lopes <hugo.lopes@present-technologies.com> * Remove duplicated css rules. Fix invalid JSX props. Co-authored-by: Hugo Lopes <hugo.lopes@present-technologies.com> * Fix the body scroll when the sidebar is open (#184) * Fix typo in the Marquee component (#176) Co-authored-by: Hugo Lopes <hugo.lopes@present-technologies.com> * Fix the body scroll when the sidebar is open Co-authored-by: Hugo Lopes <hugo.lopes@present-technologies.com> * Remove duplicate class in the I18nWidget comp (#183) * Fix typo in the Marquee component (#176) Co-authored-by: Hugo Lopes <hugo.lopes@present-technologies.com> * Remove duplicate class name in the I18nWidget comp This PR removes a duplicate class name in the I18nWidget component. Co-authored-by: Hugo Lopes <hugo.rodrigues.lopes@gmail.com> Co-authored-by: Hugo Lopes <hugo.lopes@present-technologies.com> * add horizontal margin to pages when mobile screen (#180) * Add cart item options like color and size (#177) Co-authored-by: hlopes <hugo.lopes@present-technologies.com> * Changes Co-authored-by: Hugo Lopes <hugo.rodrigues.lopes@gmail.com> Co-authored-by: Hugo Lopes <hugo.lopes@present-technologies.com> Co-authored-by: Jamie Isaksen <jamie@jamie.no> Co-authored-by: Vinicius Zucatti <51221635+vczb@users.noreply.github.com>
37 lines
891 B
TypeScript
37 lines
891 B
TypeScript
import { parseCartItem } from '../../utils/parse-item'
|
|
import getCartCookie from '../../utils/get-cart-cookie'
|
|
import type { CartHandlers } from '..'
|
|
|
|
// Return current cart info
|
|
const updateItem: CartHandlers['updateItem'] = async ({
|
|
res,
|
|
body: { cartId, itemId, item },
|
|
config,
|
|
}) => {
|
|
if (!cartId || !itemId || !item) {
|
|
return res.status(400).json({
|
|
data: null,
|
|
errors: [{ message: 'Invalid request' }],
|
|
})
|
|
}
|
|
|
|
const { data } = await config.storeApiFetch(
|
|
`/v3/carts/${cartId}/items/${itemId}?include=line_items.physical_items.options`,
|
|
{
|
|
method: 'PUT',
|
|
body: JSON.stringify({
|
|
line_item: parseCartItem(item),
|
|
}),
|
|
}
|
|
)
|
|
|
|
// Update the cart cookie
|
|
res.setHeader(
|
|
'Set-Cookie',
|
|
getCartCookie(config.cartCookie, cartId, config.cartCookieMaxAge)
|
|
)
|
|
res.status(200).json({ data })
|
|
}
|
|
|
|
export default updateItem
|