Skip to content

Shipping Method Estimator not working with custom address attributes #27505

Closed
@SamJUK

Description

@SamJUK

Preconditions (*)

  1. Magento 2.3.4 with Sample data
  2. A module that declares a custom attribute for as per instructions from dev docs (https://devdocs.magento.com/guides/v2.3/howdoi/checkout/checkout_new_field.html#add)

Steps to reproduce (*)

  1. Install a module that adds a custom address attribute (either follow the dev docs to create your own or install the module below)
    1. https://github.com/SamJUK/m2-custom-attribute-bug
  2. Enable and Redeploy site
  3. Add item to cart and proceed to shipping step of checkout
  4. Fill out shipping information (custom attribute + address data)
  5. Select a shipping rate
  6. Navigate back to your cart
  7. Trigger a estimate shipping event
    1. Either try to use shipping estimator on the cart with a new postcode
    2. Or continue back to checkout and change postcode

Expected result (*)

  1. Pull through shipping rates for the new postcode

Actual result (*)

  1. https://www.youtube.com/watch?v=cy3gQqQZ0fs
  2. Estimate shipping methods request returns a 400 bad request with the following error message
    {"message":"Error occurred during \"custom_attributes\" processing. A custom attribute is specified with a missing attribute code. Verify the code and try again."}

Due to strange nesting within the custom_attribute property. Originally while its working the address payload is of the following format

custom_attributes: [{
    "attribute_code": "custom_field", 
    "value": "123" 
}]

Where was when we are getting 400 errors the custom attributes looks like so

custom_attributes: [{
    "attribute_code": "0", 
    "value": {
        "attribute_code": "custom_field", 
        "value": "123" 
    }
}]

Currently using the following Hotfix to allow for checkout
https://gist.github.com/SamJUK/479ca3f108b8091fbf512695f97363fb

Additional information

#27505 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: CustomerFixed in 2.3.xThe issue has been fixed in 2.3 release lineFixed in 2.4.xThe issue has been fixed in 2.4-develop branchIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: doneReported on 2.3.4Indicates original Magento version for the Issue report.Reproduced on 2.3.xThe issue has been reproduced on latest 2.3 releaseSeverity: S1Affects critical data or functionality and forces users to employ a workaround.Triage: DoneHas been reviewed and prioritized during Triage with Product Managers

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions