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

Products in cart are not showing and when I click add cart button it goes blank #63

Open
Alba1020 opened this issue Sep 9, 2022 · 8 comments

Comments

@Alba1020
Copy link

Alba1020 commented Sep 9, 2022

errors

I am getting these errors in console after clicking add to cart button, strangely enough when I reload the page it will show correct updated number of products. However, I still don't see anything when I go on the cart section besides the title. Anyone had this issue or maybe have any idea what is causing it

@crimsoncreates
Copy link

I also have this same error with total_items

@kevdau03
Copy link

Same error here. Any fix OP?

@Oluwa-bunmi
Copy link

I'm having the same issue, anyone with possible solutions?

@Uwill18
Copy link

Uwill18 commented Oct 2, 2022

@Oluwa-bunmi
Copy link

Hey guys, I found the reason for the blank page.
In the App.js, make sure these async functions are written exactly like this, don't destructure the cart yet:

const handleAddToCart = async (productId, quantity) => {
const item = await commerce.cart.add(productId, quantity);
setCart(item);
};
const handleUpdateCart = async (productId, quantity) => {
const item = await commerce.cart.update(productId, { quantity });
setCart(item);
};
const handleRemoveFromCart = async (productId) => {
const item = await commerce.cart.remove(productId);
setCart(item);
};
const handleEmptyCart = async () => {
const item = await commerce.cart.empty();
setCart(item);
};

@Uwill18
Copy link

Uwill18 commented Oct 4, 2022

Thank you @Oluwa-bunmi!
That is super helpful!

@developerUmair
Copy link

@Oluwa-bunmi
Thanks buddy, saved tons of time

@Auzaiealias
Copy link

Thank you @Oluwa-bunmi :)

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

No branches or pull requests

7 participants