Fixing Magento USPS API issue with First-Class Mail Parcel

Fixing Magento USPS API issue with First-Class Mail Parcel

Critical changes to Magento USPS API!

On September 1st 2017 USPS announced a number of changes to take place, including the reclassification of their “First-Class Mail Parcel” Service to “First-Class Package Service – Retail”. This results in Magento Shipping Methods service being affected. For those of you who are experiencing troubles getting proper shipping rates for USPS on their Magento websites – please follow the easy steps below to rectify the issue:

To resolve the issue, you will need to update your USPS implementation to utilize the new Shipping Method Name.

Important: It is not recommended to update your Magento core files directly. Hopefully Magento Inc will come up with the patch soon.

Fix for Magento 1.x.x

1. In your server, locate the file:

app/code/local/Mage/Usa/Model/Shipping/Carrier/Usps.php

2. Copy this file to the path:

app/code/local/Mage/USA/Model/Shipping/Carrier/Usps.php

3. Look for “method_to_code”.

4. Locate the following part of the code:

// Added because USPS has different services but with same CLASSID value, which is "0"
'method_to_code' => array(
'First-Class Mail Large Envelope' => '0_FCLE',
'First-Class Mail Letter' => '0_FCL',
'First-Class Mail Parcel' => '0_FCP',
),

5. Replace the ‘First-Class Mail Parcel’ with ‘First-Class Package Service – Retail’ (single dash). Make sure the spelling is correct, otherwise Magento will not be able to handle the new naming.

// Added because USPS has different services but with same CLASSID value, which is "0"
'method_to_code' => array(
'First-Class Mail Large Envelope' => '0_FCLE',
'First-Class Mail Letter' => '0_FCL',
'First-Class Package Service - Retail' => '0_FCP',
),

6. Double check if there are no more occurrences of ’First-Class Mail Parcel’. If found, make sure to replace these with ‘First-Class Package Service - Retail’ .

7. Optionally, you can also rename Shipping method name. Look for ‘0_FCP’ and change ‘First-Class Mail Parcel’ to ‘First-Class Package Service - Retail’

Fix For Magento 2.x.x

Since you should not edit core Magento 2 files – you need to create the extension that overrides the model “Magento\Usps\Model\Carrier”.

The steps below will outline where is the problem in Magento 2 core files.

1. In your server, locate the file:

vendor/magento/module-usps/Model/Carrier.php

2. Look for “method_to_code”.

3. Locate the following part of the code:

// Added because USPS has different services but with same CLASSID value, which is "0"
'method_to_code' => array(
'First-Class Mail Large Envelope' => '0_FCLE',
'First-Class Mail Letter' => '0_FCL',
'First-Class Mail Parcel' => '0_FCP',
),

4. Replace the ‘First-Class Mail Parcel’ with ‘First-Class Package Service - Retail’ (single dash). Make sure the spelling is correct, otherwise Magento will not be able to handle the new naming.

// Added because USPS has different services but with same CLASSID value, which is "0"
'method_to_code' => array(
'First-Class Mail Large Envelope' => '0_FCLE',
'First-Class Mail Letter' => '0_FCL',
'First-Class Package Service - Retail' => '0_FCP',
),

5. Reminder: Make sure not to edit core Magento 2 files. Instead you need to create the extension that overrides the model “Magento\Usps\Model\Carrier”. To learn more on how to override model file please read here.

Follow Us on Social Media

 

Share:

  • Jake Lancaster

    Nice!
    You guys really saved my time. I was looking everywhere for the reason ’cause some shipping methods don’t work on my site. Now we know why.
    Thanks for digging into this for us!

  • Frank

    I have Magento 1.7.0.2 and my Usps.php file doesn’t look anything like what is listed here. I did change all instances of First-Class Mail Parcel to First-Class Package Service – Retail. I also changed the config.xml but nothing really happened… Any help would be much appreciated as all customers abandon the cart as soon as they see the Priority mail rates for a small item

    • Plumrocket

      Hello Frank,
      Thank you for outlining your concern. Please be advised
      that Magento released the official patch SUPEE-10336 for Magento 1.x :
      goo.gl/CwRFAp

      You’re welcome to try the patch, it should resolve your issue.
      Optionally, if it does not – you could try contacting our Help Desk:
      https://store.plumrocket.com/contacts/
      Please outline your issue and our friendly support will do their best to help you in no time!

      Best Regards,
      Plumrocket Team