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

NEXT-00000 - Do not add promotion when cart price is zero #3704

Conversation

jasperP98
Copy link
Contributor

1. Why is this change necessary?

When a promotion is added to a cart with a total price of zero, there will be an error thrown. This error is thrown for auto promotions or regular promotions.

2. What does this change do, exactly?

This change adds an extra check and does not process the discounts when the total price of the cart is zero.

3. Describe each step to reproduce the issue or behaviour.

  1. Add a product with price 0
  2. Add discount via auto promo or via normal promo code
  3. A 500 error is thrown

4. Please link to the relevant issues (if any).

/

5. Checklist

  • I have rebased my changes to remove merge conflicts
  • I have written tests and verified that they fail without my change
  • I have created a changelog file with all necessary information about my changes
  • I have written or adjusted the documentation according to my changes
  • This change has comments for package types, values, functions, and non-obvious lines of code
  • I have read the contribution requirements and fulfil them.

Copy link

github-actions bot commented May 8, 2024

Warnings
⚠️ Please be kind and add unit tests for your new code in these files:
src/Core/Checkout/Promotion/Cart/Error/PromotionsOnCartPriceZeroError.php
If you are sure everything is fine with your changes, you can resolve this warning.
You can run `composer make:coverage` to generate dummy unit tests for files that are not covered

@jasperP98 jasperP98 force-pushed the do-not-add-promotion-when-cart-price-is-zero branch from 6e669b6 to 89c46b3 Compare May 8, 2024 13:01
@AydinHassan
Copy link
Contributor

hey @jasperP98 how does it work when you refresh? Does the error keep persisting? Or are the items removed?

@jasperP98
Copy link
Contributor Author

Hi @AydinHassan The items can not be persisted to the cart for auto promotions since the recalculation progress will throw a 500 error. When you try to add a discount code, this will throw an error when adding the discount, so after refresh the line item will still be in the cart. I made a quick video to show the behavior: https://drive.google.com/drive/folders/1D5l2eI9d4HKAo_K-jzHx6uvxPZIjTQpe?usp=sharing

@AydinHassan
Copy link
Contributor

@jasperP98 got it, thanks! Makes sense to me. The assigned team will take care of the PR soon :)

@marcelbrode marcelbrode self-assigned this May 15, 2024
@shopware-github-importer
Copy link

Hello,

thank you for creating this pull request.
I have opened an issue on our Issue Tracker for you. See the issue link: https://issues.shopware.com/issues/NEXT-36151

Please use this issue to track the state of your pull request.

@jasperP98
Copy link
Contributor Author

Hi @marcelbrode! I see that i missed a translation for my cart error. I will add this ASAP

@marcelbrode
Copy link
Contributor

Hi @marcelbrode! I see that i missed a translation for my cart error. I will add this ASAP

Hey @jasperP98! Nice catch! Lookin forward to your push 👍

@marcelbrode
Copy link
Contributor

Oh, @jasperP98 and when, you're at it: A Unit test would be great 😄

@jasperP98 jasperP98 force-pushed the do-not-add-promotion-when-cart-price-is-zero branch from d040ec8 to 132abcd Compare May 15, 2024 14:21
@jasperP98 jasperP98 force-pushed the do-not-add-promotion-when-cart-price-is-zero branch from 132abcd to 1638428 Compare May 15, 2024 14:44
@marcelbrode
Copy link
Contributor

Your Pull Request has been merged! 🎉
Thanks for your contribution! 💙

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

Successfully merging this pull request may close these issues.

None yet

3 participants