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

Address formatting issue in request when street address is empty #36

Closed
lstellway opened this issue Dec 15, 2017 · 4 comments
Closed

Address formatting issue in request when street address is empty #36

lstellway opened this issue Dec 15, 2017 · 4 comments

Comments

@lstellway
Copy link

lstellway commented Dec 15, 2017

I was receiving issues of a "malformatted" request error when requesting shipping methods using only the postal code from the following method:

\ShipperHQ\Shipper\Model\Carrier\Shipper::setRequest()

The error I received:

Could not read document: Can not deserialize instance of java.lang.String out of START_ARRAY token

The error while in debug mode:

Malformed Request. The request was not formed correctly.

I was able to trace the issue down to the destination address being passed in the request. The issue was that the destination street passed from the quote address was an empty array.

To mediate the issue, I created an event to observe the shipperhq_carrier_set_request event and turn the destination street into a string.

public function execute(Observer $observer)
{
    $request = $observer->getData('request');
    if (is_array($request->getDestStreet())) {
        $request->setDestStreet(implode(' ', $request->getDestStreet()));
    }
}

The observer works, but not sure if you have a better idea?

Thanks!

@wsagen
Copy link
Contributor

wsagen commented Dec 19, 2017

Hi - thanks for the contribution. We are currently looking at this. Could you let me know what version of Magento you are running?

@lstellway
Copy link
Author

I am currently on Magento 2.1.9

@wsajason
Copy link
Contributor

wsajason commented Jan 3, 2018

Hi - This was addressed in the latest version of the extension, 20.12.0. Updating to that version should resolve.

@wsajason wsajason closed this as completed Jan 3, 2018
@lstellway
Copy link
Author

Great, thank you!

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

No branches or pull requests

3 participants