APIv4 changes for Jan 22

Created on 23 January 2023, almost 2 years ago
Updated 29 February 2024, 10 months ago

Problem/Motivation

As of Jan 22 any commercial service (Media Mail in my client's case) will return "0.00" for the shipping rate. The USPS API only returns the rate in the CommercialRate tag. It looks like the 8.x version of the module is already handling this case.

See https://www.usps.com/business/web-tools-apis/2023-web-tools-release-note...

Proposed resolution

Backport changes from 8.x around commercial services.

🐛 Bug report
Status

Closed: duplicate

Version

2.0

Component

Code

Created by

🇺🇸United States karlshea Minneapolis 🇺🇸

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @karlshea
  • 🇺🇸United States jsimonis

    We're having the same issue. Other rates are coming through, but media mail is $0.

  • 🇺🇸United States karlshea Minneapolis 🇺🇸

    I may have some time in the next week or two to get a proper patch ready for 7.x, but in the meantime this is the quick fix that I used.

    In includes/commerce_usps.xml.inc, function commerce_usps_rate_v4_request:

    // Make sure that the package service is registered.
    if (!empty($usps_service['machine_name'])) {
      $rate = $package->Postage->Rate;
      $commercial_rate = $package->Postage->CommercialRate;
    
      $rate = floatval($rate) ? $rate : $commercial_rate;
    
      $rates[$usps_service['machine_name']] = array(
        'amount' => commerce_currency_decimal_to_amount((string) $rate, commerce_default_currency()),
        'currency_code' => commerce_default_currency(),
        'data' => array(),
      );
    }
    

    You can see how 8.x is handling this here: https://git.drupalcode.org/project/commerce_usps/-/blob/8.x-1.x/src/USPS...

    I'm guessing a patch for 7.x would need to add a rate_class key to the services in commerce_usps_service_list, and do something similar when handling the response.

  • Status changed to Closed: duplicate 10 months ago
  • 🇮🇱Israel jsacksick

    This was fixed as a separate issue.

Production build 0.71.5 2024