Jump to content
Latest News: (loading..)

batchtech

Members
  • Content count

    4
  • Joined

  • Last visited

  1. USPS Rate V4, Intl Rate V2 (official support thread)

    Ok, yet another update that should work a bit more universally. As we are applying the temporary fix to many of our client's shops that all have different USPS modules, the code needed to be a bit more variable for closing the tags up at the end after weeding out the garbage in the USPS response XML. FIRST BACKUP YOUR includes/modules/shipping/usps.php file. Before this line: return json_decode(json_encode(simplexml_load_string($body)),TRUE); Add the following code: //BOF Code fix for USPS problems starting on 11/9/2013 by batchtech.com preg_match('/\<.*\>.?\<.*\>/', $body, $matches); $body = implode($matches); if (strpos($body, '<?xml version="1.0" encoding="UTF-8"?>') === false) $body = '<?xml version="1.0" encoding="UTF-8"?>' . $body; $tagsArray = array('MailService', 'Postage', 'Package', 'RateV4Response'); for ($i=0; $i<sizeof($tagsArray); $i++) { if (strrpos($body, '<' . $tagsArray[$i]) > strrpos($body, '</' . $tagsArray[$i] . '>')) { $body .= '</' . $tagsArray[$i] . '>'; } } //EOF Code fix for USPS problems starting on 11/9/2013 by batchtech.com Hopefully this will at least fix domestic for you until USPS gets the situation resolved. -David
  2. USPS Rate V4, Intl Rate V2 (official support thread)

    Update to the code above. I don't believe I'll be able to get international working. USPS has to fix all the garbage in their response. This is just a hack to fix domestic which should work even after USPS takes the garbage out. FIRST BACKUP YOUR includes/modules/shipping/usps.php file. Before this line: return json_decode(json_encode(simplexml_load_string($body)),TRUE); Add the following code: //BOF Code fix for USPS problems starting on 11/9/2013 by batchtech.com preg_match('/\<.*\>.?\<.*\>/', $body, $matches); $body = implode($matches); if (strpos($body, '<?xml version="1.0" encoding="UTF-8"?>') === false) $body = '<?xml version="1.0" encoding="UTF-8"?>' . $body; if (strpos($body, '</Package>') === false) $body .= '</Package>'; if (strpos($body, '</RateV4Response>') === false) $body .= '</RateV4Response>'; //EOF Code fix for USPS problems starting on 11/9/2013 by batchtech.com Hopefully this will at least fix domestic for you until USPS gets the situation resolved. -David
  3. USPS Rate V4, Intl Rate V2 (official support thread)

    I should mention for the above code that it will only fix Domestic right now. I'm working on international. -David
  4. USPS Rate V4, Intl Rate V2 (official support thread)

    For anyone having the simplexml errors, please try this solution, it worked for me). FIRST BACKUP YOUR includes/modules/shipping/usps.php file. Before this line: return json_decode(json_encode(simplexml_load_string($body)),TRUE); Add the following code: //BOF Code fix for USPS problems starting on 11/9/2013 by batchtech.com preg_match('/\<.*\>.?\<.*\>/', $body, $matches); $body = '<?xml version="1.0" encoding="UTF-8"?>'; $body .= implode($matches); $body .= '</Package></RateV4Response>'; //EOF Code fix for USPS problems starting on 11/9/2013 by batchtech.com Most likely this is not the best solution but it cleans up the extra garbage that USPS supplies in the quotes and allows you to get your rates if you were having the same simplexml errors that many of our clients are having. -David
×