Move to Cart API
MoveToCartView
Overview
The MoveToCartView is an API view for moving products from the user's wishlist to their shopping cart. It checks stock availability, ensures variants are available, and creates cart items for valid products.
Action
post(self, request)
Endpoint: api/v1/wishlist/move-to-cart/
Method: GET
Permissions: IsAuthenticated
- POST: This action moves the selected wishlist items to the user's cart.
- Request Body: A list of product IDs to be moved.
{
"product_ids": [1, 2]
}
Response: - Returns a message with the results of the operation. - Indicates which products were successfully moved to the cart, which were already in the cart, and which had stock issues.
{
"message": "Items moved to cart",
"moved_items": [1, 2],
"already_in_cart": [3],
"stock_unavailable": [4]
}
Example Usage
{
"product_ids": [1, 2]
}