Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request:Remove all or single product item from basket #269

Open
mohdizzy opened this issue Oct 23, 2019 · 2 comments
Open

Request:Remove all or single product item from basket #269

mohdizzy opened this issue Oct 23, 2019 · 2 comments

Comments

@mohdizzy
Copy link

mohdizzy commented Oct 23, 2019

Description

Great wagtail integration! Was trying to figure out on how to remove all items from the basket or a single product item. The current API allows subtracting the quantity of the product but not remove the product by itself.

@mohdizzy
Copy link
Author

mohdizzy commented Oct 24, 2019

For now, I just used the destroy_basket function from utils to get this done with an ajax call. I think may be making this as a separate API would be better.

@JamesRamm
Copy link
Collaborator

Is the destroy function (https://github.com/JamesRamm/longclaw/blob/master/longclaw/basket/api.py) not enough to meet your needs? This would let you delete a single item:
DELETE /basket/<variant_id>

I think you can delete the whole basket by sending a PUT request with an empty array in the body to the basket endpoint:
something like

fetch(
`${host}/basket`,
{ method: 'PUT', body: JSON.stringify([]) }
)

Although I agree an explicit 'DELETE' endpoint would be more intuitive

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants