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

fix(cms-base): push errors from add to cart API call #795

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

florianliebig
Copy link
Contributor

@florianliebig florianliebig commented Mar 23, 2024

Description

closes #782

Type of change

Bug fix (non-breaking change that fixes an issue)

ToDo's

  • E2E-Tests added/updated

Screenshots (if applicable)

2024-03-23 at 19 06

Additional context

Copy link

vercel bot commented Mar 23, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
shopware-frontends-docs ✅ Ready (Inspect) Visit Preview Mar 24, 2024 5:09pm

Copy link

codspeed-hq bot commented Mar 25, 2024

CodSpeed Performance Report

Merging #795 will not alter performance

Comparing florianliebig:fix/show-add-to-cart-errors (ad46199) with main (782ef4d)

Summary

✅ 9 untouched benchmarks

@mdanilowicz mdanilowicz self-requested a review March 25, 2024 09:52
@@ -33,7 +33,15 @@ const { product } = toRefs(props);
const { addToCart, quantity } = useAddToCart(product);

const addToCartProxy = async () => {
await addToCart();
const res = await addToCart();
const errors = Object.values(res.errors);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cart errors should be transformed and translated. Please check how it's done in the demo store

https://github.com/shopware/frontends/blob/main/templates/vue-demo-store/components/product/ProductAddToCart.vue#L12

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah nice thanks! Do we also need to handle any translations or can we rely that the API Response is already translated?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello 👋

I have created a new Branch from your PR, and changed the part @mdanilowicz mentioned.

Look here: d8e28c8

But to be honest I do not like the part about the quantity. Currently, we would need to search in the line items for the quantity that was added to the cart. Maybe a more generic error message would be easier.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah nice thanks! Do we also need to handle any translations or can we rely that the API Response is already translated?

Unfortunately, all API errors are in English, even if the context language is different. So, we have to translate it "locally"

Copy link
Collaborator

@mdanilowicz mdanilowicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Successfully merging this pull request may close these issues.

[BUG] errors during adding a product to cart aren't displayed
3 participants