Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

CartItems must extend AbastractCartRoute otherwise the cart is not loaded from the session #3488

Merged
merged 1 commit into from Dec 3, 2020

Conversation

ettoredn
Copy link
Contributor

@ettoredn ettoredn commented Dec 1, 2020

edited by @senadir

store/cart/items endpoint returns an error because cart is not loaded at that point.
This issue happens because AbstractCartRoute loads the cart before returning, CartItems didn't extend so the cart was never loaded.

Testing instructions

1- Add items to your cart.
2- From your browser console, ping store/cart/items

await (await fetch("https://EXAMPLE/wp-json/wc/store/cart/items")).json()

3- You should see a result of the current cart items.

Changelog

Fix - Make sure cart is initialized before the CartItems route is used in the Store API.

@ettoredn ettoredn requested a review from a team as a code owner December 1, 2020 01:48
@ettoredn ettoredn requested review from opr and removed request for a team December 1, 2020 01:48
@opr
Copy link
Contributor

opr commented Dec 1, 2020

Hi @ettoredn - thank you for this pull request! Would you be able to describe the issue you're facing along with the steps to reproduce it? This will be really helpful to give us more context about your proposed changes. Thanks in advance!

@ettoredn
Copy link
Contributor Author

ettoredn commented Dec 3, 2020

Given any non empty cart:

image

the endpoint /wc/store/cart/items always returns error because, as I said, the cart is not loaded from the session (via AbstractCartRoute overrides):

image

@senadir
Copy link
Member

senadir commented Dec 3, 2020

Thank you, I noticed the issue today and your PR fixes it.

I will update your PR body and merge it.

@senadir senadir added focus: rest api Work impacting REST api routes. type: bug The issue/PR concerns a confirmed bug. labels Dec 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
focus: rest api Work impacting REST api routes. type: bug The issue/PR concerns a confirmed bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants