Skip to content

Bugfix/shipping rates result incorrect cost value #35202

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 8 commits into
base: 2.4-develop
Choose a base branch
from

Conversation

nicolasddev
Copy link

Description (*)

Please refer to the issue #35146

Fixed Issues (if relevant)

  1. Fixes Inaccurate Shipping Cost for Multiple Packages #35146

Manual testing scenarios (*)

  1. Call the Magento\Shipping\Model\Shipping::collectRates() function passing all required parameters.
  2. Call the Magento\Shipping\Model\Shipping::getResult() function.
  3. Call the asArray() function on the Magento\Shipping\Model\Rate\Result class object returned.
  4. The array returned now contains cost values that are accurate.

Alternative testing scenario:

  1. Add items to the shopping cart from the frontend.
  2. Visit the shopping cart page.
  3. Add "var_dump($this->getResult()->asArray()); exit;" right before the "return $this;" line of the Magento\Shipping\Model\Shipping::collectCarrierRates() function.
  4. Open the developer tools on the Network tab.
  5. Use the "Estimate Shipping and Tax function to request rates.
  6. Look for the presence and accuracy of the cost and cost_formatted values in the response for the request made to the following URL: /rest/en_ca/V1/guest-carts/<quote_id>/estimate-shipping-methods

Questions or comments

The cost values are important as, although not currently used on the frontend, these can be useful for recording accurate shipping estimates as a reference in the case where the price displayed on the frontend is inflated.

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)

nicolasddev and others added 4 commits February 25, 2022 18:23
The shipping cost wasn't accurate when a shipment contained multiple packages as only the prices from the different packages were compiled, while the cost remained the one returned for a first package.
Related to commit #5327ddc4b706de9dc573194acf3481dfc8e33cb5 (magento@5327ddc)

The shipping cost wasn't accurate when a shipment contained multiple packages as only the prices from the different packages were compiled, while the cost remained the one returned for a first package. (One request mode)
The cost values are missing when calling the Magento\Shipping\Model\Rate\Result::asArray() function, which is commonly called through Magento\Shipping\Model\Shipping::getResult().
@m2-assistant
Copy link

m2-assistant bot commented Mar 16, 2022

Hi @nicolasddev. Thank you for your contribution
Here are 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

❗ 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 Magento Contributor Guide documentation.

⚠️ According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@nicolasddev
Copy link
Author

@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.

@nicolasddev
Copy link
Author

@magento run Functional Tests B2B
@magento run Functional Tests CE
@magento run Functional Tests EE
@magento run Integration 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.

@nicolasddev
Copy link
Author

@magento run all tests

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.

@nicolasddev
Copy link
Author

Hi @engcom-Hotel,

I would appreciate if you could take a moment to review these changes, as they were never merged and we must still use a patch to compensate for this discrepency.

Please refer to my response dating back from April 2022 for more details; #35146 (comment).

While no Magento feature currently uses these variables, a developer should be able to confirm that they should be present in order to maintain consistency with the various shipping modules.

@nicolasddev
Copy link
Author

@magento run all tests

@nicolasddev
Copy link
Author

@magento run Functional Tests B2B
@magento run Functional Tests EE
@magento run WebAPI Tests

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

Successfully merging this pull request may close these issues.

Inaccurate Shipping Cost for Multiple Packages
3 participants