-
Notifications
You must be signed in to change notification settings - Fork 683
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
Use graphql to add item to cart #1987
Conversation
|
8efd829
to
cdb77c3
Compare
43bbd1f
to
d732f21
Compare
cb459c3
to
ca9023c
Compare
d732f21
to
d82ea6f
Compare
64183b4
to
4c15cd3
Compare
8471293
to
8dbfa6c
Compare
@@ -49,22 +43,6 @@ export const useMiniCart = props => { | |||
setIsEditingItem(false); | |||
}, []); | |||
|
|||
const handleUpdateItemInCart = useCallback( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this to cartOptions
where it was more appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, found it! I assume this is the remnant of a re-factor, but I would consider removing the try/catch if its not reachable (in the other file).
@@ -134,6 +145,16 @@ export const addItemToCart = (payload = {}) => { | |||
}; | |||
}; | |||
|
|||
// Returns true if the cart is invalid. | |||
function hasRetryableGqlError(error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function feels nasty. I don't like matching some string value from the API. Would rather we be able to use some error id map. GQL always returns 200 so we no longer get 404 for invalid carts. I guess it depends how resilient category
is in the graphql error response.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out that category: "graphql-no-such-entity"
is used if anything within the response is not found. To ensure we only retry on an invalid cart, and not on an invalid/oos item, we should use the message
string.
328985f
to
d1a67da
Compare
packages/peregrine/lib/talons/ProductFullDetail/useProductFullDetail.js
Outdated
Show resolved
Hide resolved
packages/peregrine/lib/talons/ProductFullDetail/useProductFullDetail.js
Outdated
Show resolved
Hide resolved
@sirugh @tjwiebell Add item to cart and place order >> now close checkout panel by clicking close icon or by clicking in greyed out area and try adding same product again. Product is not getting added to cart. |
@sirugh - Looks like the cartId check was removed, so its now possible to enter with a null Possible solutions:
Message |
method: 'POST', | ||
body: JSON.stringify({ cartItem }) | ||
const { cart } = getState(); | ||
const { cartId } = cart; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this can be null
after an order is placed, and a subsequent add
calls this with a null
cartId.
@tjwiebell suggested two options, but I think it may be better to figure out why the cart is deleted but never re-created after order. It should definitely be created every time the cartId is deleted.
@dpatil-magento I believe I "fixed" the issue :) Tried it myself and I'm able to add immediately after checkout. |
@sirugh Recent commit has broken checkout flow. After placing an order as guest/registered user, error is being displayed. |
@sirugh Dont see error anymore but after placing order for fraction of second checkout form displayed again (Slow 3G screen captured below). Also "Create an Account" button is not functional anymore and original bug has reappeared (after placing order unable to add product to cart). |
The checkout form being visible for a fraction of a second is because we ^ Turns out this is just visible because we now await a create cart call, which takes a little longer, before we show the next step. We probably don't need to await that call though, I can remove the await. As for the |
@sirugh Looks good now. Can be merged once review is approved. |
Description
Updates
addItemToCart
to pass mutations for adding different product types to the cart.Updates
updateItemInCart
to pass the necessary mutations for add item since addItem action was used as a fallback case.Updates retry logic for graphQL response in the addItem error catch.
Related Issue
Closes PWA-139.
Acceptance
Verification Stakeholders
Specification
Verification Steps
Screenshots / Screen Captures (if appropriate)
Checklist