fontis / australia-mage2

Fontis Australia extension for Magento 2
Open Software License 3.0
11 stars 18 forks source link

Checkout Page (to post_code null) throws error #20

Open Tw0bit opened 5 years ago

Tw0bit commented 5 years ago

When a user gets to the checkout page without a postcode for ship to, the following error occurs:

The logged error: https://digitalapi.auspost.com.au/postage/parcel/domestic/service?from_postcode=4000&to_postcode=0&length=30&width=30&height=20&weight=0.1 at vendor/guzzle/guzzle/src/Guzzle/Http/Exception/BadResponseException.php:43)"} []

So the AusPost API is erroring out with a null postcode. How can we prevent the system fetching rates when no postcode?

chnorton commented 5 years ago

This isn't a situation we've come across, as postcodes are typically required before reaching the carrier selection. In what situations is a customer able to select Auspost shipping without having had to enter a postcode?

Have you come across any other carriers that handle this? If so, it would be good to take a look at what they're doing.

Tw0bit commented 4 years ago

Hi Chris,

Sorry its been a while since I got onto this issue... The issue is occuring on the "Estimate Shipping and Tax" portion of the website when viewing the cart.

The workflow for our customer is:

  1. They enter the website and add a product to cart.
  2. They head to the cart page and have a look at it (does not enter anything into estimate part)
  3. When they return to the website and everytime they try add a product they get an error "We can't add this item to your shopping cart right now." if the postcode is blank on the cart estimate area
  4. Adding a postcode to the shipping estimate on the cart page fixes this issue; also if they do not view the cart page at all until checkout it doesnt occur.

The error in the magento exception.log is: 2019-10-31 01:39:56] main.CRITICAL: Client error response [status code] 404 [reason phrase] Not Found [url] https://digitalapi.auspost.com.au/postage/parcel/domestic/service?from_postcode=4000&to_postcode=0&length=30&width=30&height=20&weight=0.4 {"exception":"[object] (Guzzle\Http\Exception\ClientErrorResponseException(code: 0): Client error response [status code] 404 [reason phrase] Not Found [url] https://digitalapi.auspost.com.au/postage/parcel/domestic/service?from_postcode=4000&to_postcode=0&length=30&width=30&height=20&weight=0.4 at /home/account/public_html/vendor/guzzle/guzzle/src/Guzzle/Http/Exception/BadResponseException.php:43)"} []

Tw0bit commented 4 years ago

The "fix" I put in:

Line 447 of /australia-mage2/Model/Shipping/Carrier/AustraliaPost.php if ((int)$config['to_postcode'] == 0 || ($config['to_postcode'] == null)) { return $rateResult; }

xeontcs commented 4 years ago

@Tw0bit Thank you! You saved lots of my time