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

Issue #31311 - Shipping Method Delimiter Conflict Fix #35134

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

Conversation

nicolasddev
Copy link

Description (*)

Fixes issues related to shipping modules having an underscore in their carrier code, which conflicts with the delimiter "_" used when concatenating the carrier code with the method code to identify a unique shipping method <carriercode>_<methodcode>. Replacing the delimiter with "::" allows for more flexibility for both the carrier codes and the method codes, while preventing conflicts.

Related Pull Requests

#21340

Fixed Issues

  1. Fixes getShippingMethod as object still suffer from "carrier underscore" bug  #31311

Manual testing scenarios (*)

  1. Create a new shipping module having an underscore in its carrier code.
  2. Use the Magento\Sales\Model\Order::getShippingMethod() to obtain both the carrier code and method code within an object.

Questions or comments

  1. It is important to allow the use of underscores in the carrier code to prevent conflicts between vendors. For example, a merchant may use modules from different vendors to connect to the very same carrier, a situation possibly resulting in a conflict if none of these vendors are using a "vendor_" prefix.
  2. Although a possible solution could have been to store the carrier code and method code values in different columns, keeping both values concatenated remains useful to find a specific method using a unique identifier.

Important

  1. A data patch should be developed to iterate over all entries present in the shipping_method columns of the sales_order and quote_address tables and the code column of the quote_shipping_rate table to convert the previous <carriercode>_<methodcode> format to the new <carriercode>::<methodcode> format by comparing each entry to all available <carriercode>_<methodcode> combinations until a match is found. As old entries from uninstalled modules may still exist, the data patch should replace the last underscore "_" of each remaining entries, by filtering any entries already containing the new delimiter "::".
  2. A warning should be issued before releasing this fix as several modules handling shipping_method string separation directly could be affected or even break. The fix is rather simple as replacing the affected explode('_', $shippingMethod); statement by preg_split('/' . Order::DELIMITER_SHIPPING_METHOD . '/', $shippingMethod); should suffice to make any module compatible.

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages (self-explanatory)
  • All new or changed code is covered with unit/integration tests (applicable unit tests have been updated)
  • 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)

@m2-assistant
Copy link

m2-assistant bot commented Feb 24, 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

@m2-community-project m2-community-project bot added Priority: P3 May be fixed according to the position in the backlog. Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround. labels Feb 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Frontend Component: Checkout Component: Quote Component: Sales Component: Shipping Priority: P3 May be fixed according to the position in the backlog. Progress: pending review Release Line: 2.4 Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround.
Projects
Status: Pending Review
Development

Successfully merging this pull request may close these issues.

getShippingMethod as object still suffer from "carrier underscore" bug
2 participants