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

#26622 - Check quote item for parentItem instead of parentItemId #26623

Conversation

aligent-lturner
Copy link
Contributor

@aligent-lturner aligent-lturner commented Feb 1, 2020

Description (*)

This PR fixes issue #26622 - a "fixed amount for whole cart" discount is calculated incorrectly when a configurable product is first added to the cart. This change is to use getParentItem instead of getParentItemId from the quote item when determining if it should be skipped. This is because parentItem is set when the quote item is created, but parentItemId is only set in its beforeSave function.

Fixed Issues (if relevant)

  1. Fixed cart discount calculated incorrectly when product first added to cart. #26622: Fixed cart discount calculated incorrectly when product first added to cart

Manual testing scenarios (*)

  1. Create fixed amount discount for whole cart of $1 with no conditions/restrictions
  2. Navigate to PDP of configurable product
  3. Choose configurable product options and add to cart
  4. Confirm that discount is correct ($1) in minicart and/or database.

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

…Id, as the latter is only set in beforeSave function.
@m2-assistant
Copy link

m2-assistant bot commented Feb 1, 2020

Hi @aligent-lturner. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Guide documentation.

@ghost ghost assigned ihor-sviziev Feb 4, 2020
@aligent-lturner
Copy link
Contributor Author

@ihor-sviziev changes made as requested. Modified existing test case in ValidatorTest class to handle additional quote items with differing combinations of parentItemId and parentItem

@aligent-lturner
Copy link
Contributor Author

@ihor-sviziev I had to move the functionality into a separate function to reduce the cyclomatic complexity.
Some functional tests are failing, but they appear to be completely unrelated to my changes.

@ihor-sviziev ihor-sviziev added Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Award: bug fix labels Feb 7, 2020
@magento-engcom-team
Copy link
Contributor

Hi @ihor-sviziev, thank you for the review.
ENGCOM-6824 has been created to process this Pull Request

@engcom-Bravo engcom-Bravo self-assigned this Feb 7, 2020
@engcom-Bravo
Copy link
Contributor

✔️ QA Passed

After switching to PR, the discount amount became 1$ instead of 0.50$
discount_ammount1

@m2-assistant
Copy link

m2-assistant bot commented Feb 9, 2020

Hi @aligent-lturner, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@sdzhepa sdzhepa mentioned this pull request May 9, 2022
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.

5 participants