phpcalculatorusps

USPS API changes


I have a problem with the USPS shipping calculator.

It worked just fine until a few days back, when the international shipping rates suddenly stopped working. Also, the US domestic services contain now some strange characters.

After a few searches I managed to find that USPS changed its service names once again (it's crazy, they change their service names yearly or so).

My USPS calculator is from an older version of WP E-Commerce plugin, and I had to manually define which service types I want to allow for international quotes:

$allowed_types = array( 'First-Class Package International' => 'First-Class Package International Service<sup>™</sup>**');

I guess since the name changed the $allowed_types variable doesn't contain the right service and that's why the calculator doesn't work anymore for international queries.

As for US domestic queries, the available services look like this:

Priority Mail 2-Day<sup>™</sup>

The trademark is being displayed incorrectly but I don't know how to fix it. I tried the classic: $key = str_replace('<sup>™</sup>', "", $key); but for some reason it doesn't work. If I try to str_replace something else, like "Priority Mail", it works. It just doesn't work for the trademark sign.

Any ideas on how to replace those characters and how to find out what's the new name for the First Class Package International service?:)


Solution

  • array_push($allowed_types, "First-Class Package International Service<sup>™</sup>**");
    

    Web Tools APIs