So I am back to trying to fix the Canada Post shipping module since the developer of it hasn't bothered.
I have come up with a desired fix, but I know it's not a correct way to fix it.
Being my coding skills suck, I am looking for a little help with it from anyone.

So the problem with it is that when there is no Postal Code at checkout, I kicks out an error:

Error Server: /rs/ship/price: cvc-simple-type 1: element {http://www.canadapost.ca/ws/ship/rate-v2}postal-code of type {http://www.canadapost.ca/ws/ship/rate-v2}postalcodetype may not be empty


So my temporary fix is to change the following:

$ErrorDesc = $dom->getElementsByTagName('description')->item(0)->nodeValue;


to

$ErrorDesc = "Postal Code Required";


I think the proper way to fix this is to have:

$ErrorDesc = $dom->getElementsByTagName('description')->item(0)->nodeValue;
if ($ErrorDesc = "/rs/ship/price: cvc-simple-type 1: element {http://www.canadapost.ca/ws/ship/rate-v2}postal-code of type {http://www.canadapost.ca/ws/ship/rate-v2}postalcodetype may not be empty") {
$ErrorDesc = "Postal Code Required";


I think I am in the right direction, but thinking the issue is probably with the {} brackets.

So can someone help me out with the correct way to correct the above line?

Thanks for any help.
Wednesday, April 05 2017, 11:24 PM
Share this post:

Accepted Answer

Thursday, April 06 2017, 01:56 AM - #Permalink
NVM. I figured it out. Misplaced a bracket.

$ErrorDesc = $dom->getElementsByTagName('description')->item(0)->nodeValue;
if ($ErrorDesc == '/rs/ship/price: cvc-simple-type 1: element {http://www.canadapost.ca/ws/ship/rate-v2}postal-code of type {http://www.canadapost.ca/ws/ship/rate-v2}postalcodetype may not be empty') {
$ErrorDesc = 'Postal Code Required';
}
The reply is currently minimized Show
Responses (1)
  • Accepted Answer

    Thursday, April 06 2017, 01:58 AM - #Permalink
    I'll send the fix to Andrew.
    Like
    1
    The reply is currently minimized Show
Your Reply