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 added to cart with REST API give total prices equal to zero #11458

Merged
merged 4 commits into from
Oct 31, 2017

Conversation

peterjaap
Copy link
Contributor

@peterjaap peterjaap commented Oct 14, 2017

Products added to cart with REST API give total prices equal to zero

Description

When adding a product trough the (web) API to an empty cart, the product gets a price of zero.

To quote @degaray in #2991 (comment), "The problem is here: Magento\Quote\Model\Quote\TotalsCollector::collect because all totals are set to zero and then all totals are calculated per address set. Since no address is set, then no totals are calculated, and as result, it does not calculate any total."

Adding these collect shipping method calls will set a blank address, and cause the price to show up correctly.

Fixed Issues (if relevant)

  1. Products added to cart with REST API give total prices equal to zero #2991: Products added to cart with REST API give total prices equal to zero

Related Issues

  1. Virtual products not showing totals in cart #4532 Virtual products not showing totals in cart (PR)

Manual testing scenarios

  1. See Products added to cart with REST API give total prices equal to zero #2991 (comment)

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 on Travis CI are green)

(sorry for the commits mess, apparently I suck at rebasing)

…nable getting a correct price through the (web) API after adding a product to an empty cart
…nable getting a correct price through the (web) API after adding a product to an empty cart
…hod does not exist for a billing address. Also removed getBillingAddress() call because the empty address is already created 3 lines above.
@okorshenko okorshenko self-assigned this Oct 16, 2017
@okorshenko okorshenko added this to the October 2017 milestone Oct 16, 2017
@okorshenko
Copy link
Contributor

Hi @peterjaap
Could you please look at broken unit tests?

@okorshenko okorshenko added 2.2.x bug report bugfix Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Component: Sales labels Oct 16, 2017
@peterjaap
Copy link
Contributor Author

@okorshenko I have no idea why the unit test fails; the address is created 2 lines right above where the setCollectShippingRates() is called...

@okorshenko
Copy link
Contributor

I will fix the tests

@magento-team magento-team merged commit 846f117 into magento:2.2-develop Oct 31, 2017
magento-team pushed a commit that referenced this pull request Oct 31, 2017
magento-team pushed a commit that referenced this pull request Oct 31, 2017
magento-team pushed a commit that referenced this pull request Oct 31, 2017
[EngCom] Public Pull Requests - 2.2-develop
 - MAGETWO-82955: [Backport 2.2-develop] FIX show visual swatches in admin - product attribute #11747
 - MAGETWO-82943: Magetwo 70954: Remove the component.clear from the custom options type. This causes the 'elem' array to become out of sync with the recordData #11824
 - MAGETWO-82710: Fix issue #10032 - Download back-up .tgz always takes the latest that's created (2.2-develop) #11595
 - MAGETWO-81994: Products added to cart with REST API give total prices equal to zero #11458
 - MAGETWO-81422: #11211 Fix Store View switcher #11337
@peterjaap peterjaap deleted the fix-for-issue-2991 branch November 7, 2017 19:49
@ghost
Copy link

ghost commented Mar 29, 2018

@peterjaap I experienced the same bug with a logged in customer. In that case it uses the "createEmptyCartForCustomer" method. Your fix also works for that method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report bugfix Component: Sales Progress: needs update Release Line: 2.2 Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants