Skip to content

Set price on quote item instead of base_price #36878

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

Open
wants to merge 5 commits into
base: 2.4-develop
Choose a base branch
from

Conversation

hostep
Copy link
Contributor

@hostep hostep commented Feb 16, 2023

Description (*)

For some unknown reason, a quote item's price gets incorrectly set to the base_price instead of the price.
Which means that if you have multiple currencies in one website on the frontend, both price & base_price are stored in the database in the base currency. We would expect the price to be in the other currency and not the base currency.

The comment above the changed line of code seems to indicate this was done on purpose, but I have no idea why.

The base_price is set correctly on the quote item. It's just the price itself that seems to be wrong.

Related Pull Requests

Fixed Issues (if relevant)

Manual testing scenarios (*)

  1. Have 2 storeviews
  2. Configure "Stores > Configuration > General > Currency Setup" so that one of the 2 storeviews use different currency then the "default" values
  3. Check in backoffice under "Stores > Currency > Currency Rates" that the 2 currencies aren't exactly the same rate, if they are the same, manually add some dummy exchange rate
  4. Create a new product, give it a price of 100
  5. Reindex, flush caches
  6. In frontend, visit the product on the 2 different storeviews, you should see 2 different prices and currencies if all goes well.
  7. On the storeview where the currency isn't the same as the "default" value, put the product in the cart
  8. Now inspect the database, the table quote_item, the columns price and base_price
  9. It's expected that the values aren't the same, the base_price should contain 100, the price should contain the value from the other currency.

Questions or comments

I don't have the knowledge or time and energy to add a new automated test for this scenario, so it would be appreciated if assistance can be given here for this.

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)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)

Resolved issues:

  1. resolves [Issue] Set price on quote item instead of base_price #38094: Set price on quote item instead of base_price

@m2-assistant
Copy link

m2-assistant bot commented Feb 16, 2023

Hi @hostep. Thank you for your contribution!
Here are some useful tips on 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

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here
ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

@hostep
Copy link
Contributor Author

hostep commented Feb 16, 2023

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@hostep hostep mentioned this pull request Feb 16, 2023
5 tasks
@hostep
Copy link
Contributor Author

hostep commented Feb 16, 2023

None of the failing tests seem to indicate a problem so far, they are all flaky results I think:

  • Functional Tests B2B:
    • MC-73: Admin should be able to create a cart price rule of type Buy X get Y free: Waited for 60 secs but text '-$123.00' still not found
    • MC-62: Admin should be able to create a cart price rule of type Fixed amount discount: Waited for 60 secs but text '-$20.00' still not found
  • Functional Tests CE:
    • MC-40397: Checking vat id field at account create page with 'Check Out with Multiple Addresses': element not interactable (Session info: chrome=103.0.5060.114)
  • Integration Tests:
    • Magento\Company\LoggingTest::testEditCompanyActionLogging: Failed asserting that '2023-02-16 18:26:59' contains "2023-02-16 18:27".
  • Functional Tests EE:
    • No idea, takes too long, has been running for almost 13 hours now

Just to be sure, let's try to run these again to be sure ...

@magento run Functional Tests B2B, Functional Tests CE, Integration Tests, Functional Tests EERSTE

@hostep
Copy link
Contributor Author

hostep commented Feb 17, 2023

@magento run Functional Tests B2B, Functional Tests CE, Integration Tests, Functional Tests EE

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@hostep
Copy link
Contributor Author

hostep commented Feb 17, 2023

Only Functional Tests B2B is failing now with:

Failed asserting that any element by '//*[@id='cart-totals']//tr[@class='grand totals']//td//span[@class='price']' on page /checkout/cart/
Elements: 
+ <span> $10.00
contains text '$15.00'

&

stale element reference: element is not attached to the page document
  (Session info: chrome=103.0.5060.114)

Let's try that one again

@magento run Functional Tests B2B

@hostep
Copy link
Contributor Author

hostep commented Feb 17, 2023

@magento run Functional Tests B2B

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@hostep
Copy link
Contributor Author

hostep commented Feb 17, 2023

Since all tests passed, can we assume that nothing broke by doing this change?
Or does it mean that there were no tests specific for this and there can be issues after this change?

@hostep hostep force-pushed the set-correct-price-on-quote-item branch from 3ac1153 to 68a92b3 Compare October 12, 2023 19:17
@hostep
Copy link
Contributor Author

hostep commented Oct 12, 2023

Rebased on latest 2.4-develop, tested and verified, updated description with how to test. I'm unable to figure out how to write a quick unit test for this in less than 10 minutes. So if somebody could give some pointers or be of assistance or add a test to the PR themselves, feel free to do so.

@hostep hostep marked this pull request as ready for review October 12, 2023 19:33
@hostep hostep changed the title [WIP] Set price on quote item instead of base_price Set price on quote item instead of base_price Oct 12, 2023
@hostep
Copy link
Contributor Author

hostep commented Oct 12, 2023

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues.

@engcom-Hotel
Copy link
Contributor

@magento create issue

@engcom-Hotel engcom-Hotel added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Oct 17, 2023
@engcom-Charlie engcom-Charlie added the Project: Community Picked PRs upvoted by the community label May 13, 2025
@engcom-Charlie engcom-Charlie moved this to Pending Review in Community Dashboard May 13, 2025
@engcom-Hotel
Copy link
Contributor

@magento run all tests

Copy link
Contributor

@engcom-Hotel engcom-Hotel left a comment

Choose a reason for hiding this comment

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

Thanks @hostep for the contribution!

The PR changes looks good to me.

For automated test, let me ask the internal team member to add the same. @engcom-Dash please do the needful.

Thanks

@engcom-Hotel engcom-Hotel moved this from Pending Review to Changes Requested in Community Dashboard May 19, 2025
@engcom-Dash
Copy link
Contributor

@magento run all tests

@engcom-Dash
Copy link
Contributor

@magento run all tests

1 similar comment
@engcom-Dash
Copy link
Contributor

@magento run all tests

Copy link

Failed to run the builds. Please try to re-run them later.

@engcom-Dash
Copy link
Contributor

@magento run Database Compare

@hostep
Copy link
Contributor Author

hostep commented May 21, 2025

If anyone wonders about the changes from this commit, here's some context:

Screenshot 2025-05-21 at 12 51 52

@engcom-Dash
Copy link
Contributor

Helllo @hostep & @engcom-Hotel,

As discussed in the slack chat, I have added commit to address the minicart item price issue.

Also @engcom-Hotel I can see a Unit Test has been already added for the updateItemTaxInfo() in the app/code/Magento/Tax/Test/Unit/Model/Sales/Total/Quote/CommonTaxCollectorTest.php. let me know anything more needed from my side.

I feel the failing tests are not related to the changes done in this PR. Could you please review the PR. ?

@ct-prd-projects-boards-automation ct-prd-projects-boards-automation bot moved this from Review in Progress to Ready for Testing in Community Dashboard May 22, 2025
@engcom-Bravo engcom-Bravo moved this from Ready for Testing to Testing in Progress in Community Dashboard May 23, 2025
@engcom-Bravo
Copy link
Contributor

Hi @hostep,

Thanks for the collaboration & contribution!

✔️ QA Passed

Preconditions:

  • Install fresh Magento 2.4-develop

Steps to reproduce

  • Have 2 storeviews
  • Configure "Stores > Configuration > General > Currency Setup" so that one of the 2 storeviews use different currency then the "default" values
  • Check in backoffice under "Stores > Currency > Currency Rates" that the 2 currencies aren't exactly the same rate, if they are the same, manually add some dummy exchange rate
  • Create a new product, give it a price of 100
  • Reindex, flush caches
  • In frontend, visit the product on the 2 different storeviews, you should see 2 different prices and currencies if all goes well.
  • On the storeview where the currency isn't the same as the "default" value, put the product in the cart
  • Now inspect the database, the table quote_item, the columns price and base_price
  • It's expected that the values aren't the same, the base_price should contain 100, the price should contain the value from the other currency.

Before: ✖️

Screenshot 2025-05-23 at 2 24 15 pm Screenshot 2025-05-23 at 2 24 39 pm

After: ✔️

Screenshot 2025-05-23 at 2 33 44 pm Screenshot 2025-05-23 at 2 34 04 pm

Builds are failed. Hence, moving this PR to Extended Testing.

Thanks.

@engcom-Bravo engcom-Bravo moved this from Testing in Progress to Extended testing (optional) in Community Dashboard May 23, 2025
@engcom-Dash engcom-Dash self-assigned this May 23, 2025
@engcom-Dash
Copy link
Contributor

@magento run all tests

@engcom-Dash
Copy link
Contributor

@magento run Functional Tests B2B, Functional Tests CE, Functional Tests EE, Unit Tests

@engcom-Dash
Copy link
Contributor

The consistent test failures for Functional B2B are known Issues and JIRA is raised for them. other failures are inconsistent. They neither part of PR nor failing because of the PR changes

Build 1: https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/36878/e4bde7874855d027f9d8c4220c73fc02/Functional/allure-report-b2b/index.html#categories/8fb3a91ba5aaf9de24cc8a92edc82b5d

image

Build 2: https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/36878/da1f67b4887c0adaa8bd6017295705a3/Functional/allure-report-b2b/index.html#categories/8fb3a91ba5aaf9de24cc8a92edc82b5d

image

Known Issues:
EnablePaypalExpressCheckoutAndSubmitAnOrderUsingPaypalExpressCheckoutTest : ACQE-8007
StoreFrontSimpleProductWithSpecialAndTierDiscountPriceTest : ACQE-7971
OrderWithMultipleConfigurableProductsAdditionalStockTest : ACQE-8060

The consistent test failures for Functional CE is known Issues and JIRA is raised for the same. Other failures are inconsistent and seems to be flaky. They neither part of PR nor failing because of the PR changes.

Build 1: https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/36878/5527c791ed8bf06538803928839a79ad/Functional/allure-report-ce/index.html#categories/8fb3a91ba5aaf9de24cc8a92edc82b5d

image

Build 2: https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/36878/3e031a592b5e8d8c57cfe0d958a15ad4/Functional/allure-report-ce/index.html#categories/8fb3a91ba5aaf9de24cc8a92edc82b5d

Screenshot 2025-05-26 at 4 54 42 PM

Known Issues:
EnablePaypalExpressCheckoutAndSubmitAnOrderUsingPaypalExpressCheckoutTest : ACQE-8007

The consistent test failure for Functional EE is known Issues and JIRA is raised for the same. Other failures are inconsistent and seems to be flaky. They neither part of PR nor failing because of the PR changes.

Build 1: https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/36878/255e35f84ceff7356b9c9eb88d46cd09/Functional/allure-report-ee/index.html#categories/8fb3a91ba5aaf9de24cc8a92edc82b5d

image

Build 2: https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/36878/3c029fbe3b815bb56edca9ba9a4350c7/Functional/allure-report-ee/index.html#categories/8fb3a91ba5aaf9de24cc8a92edc82b5d

image

Known Issues:
EnablePaypalExpressCheckoutAndSubmitAnOrderUsingPaypalExpressCheckoutTest : ACQE-8007

Hence moving this PR in Merge In Progress.

@engcom-Dash engcom-Dash moved this from Extended testing (optional) to Merge in Progress in Community Dashboard May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Project: Community Picked PRs upvoted by the community
Projects
Status: Merge in Progress
Development

Successfully merging this pull request may close these issues.

[Issue] Set price on quote item instead of base_price
5 participants