Forums / Addon Shipping Modules / USPS Shipping (RESTful) (USPSr)

USPS Shipping (RESTful) (USPSr)

Sticky

Views: 54,963

Results 261 to 280 of 558
6 Oct 2025, 5:34 PM
#261
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

USPS Shipping (RESTful) (USPSr)

skipwater:

Zencart install was 2003 updated to 1.5.7d when it came out.

Was encapsulated or unencapsulated? Just loaded /includes/ and /admin/ folders

That's an unencapsulated install. (Which I should've realized when you mentioned 1.5.7d)

Either way, I'll double-check over everything, but it looks like it works for the most part. That initial log makes it sound like it failed to obtain a token. That's a necessary step regardless of whether the shipping estimator is used or not.

14 Oct 2025, 9:01 PM
#262
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,720
Plugin Contributions:
56

Re: USPS Shipping (RESTful) (USPSr)

If you go to modify the Zen Cart secret keys:

https://YOURSITE.com/admin/index.php?cmd=configuration&gID=6

You will get an error:

[14-Oct-2025 16:57:08 America/New_York] PHP Fatal error: Uncaught Error: Call to undefined function zen_uspsr_estimate_days() in /Users/scott/Sites/littledollhouses/admin/includes/functions/general.php:431
Stack trace:
#0 /Users/scott/Sites/littledollhouses/admin/configuration.php(137): zen_call_function('zen_uspsr_estim...', '1')
#1 /Users/scott/Sites/littledollhouses/admin/index.php(16): require('/Users/scott/Si...')
#2 {main}
thrown in /Users/scott/Sites/littledollhouses/admin/includes/functions/general.php on line 431

[14-Oct-2025 16:57:08 America/New_York] Request URI: /admin/index.php?cmd=configuration&gID=6&cID=201&action=edit, IP address: ::1
--> PHP Fatal error: Uncaught Error: Call to undefined function zen_uspsr_estimate_days() in /Users/scott/Sites/littledollhouses/admin/includes/functions/general.php:431
Stack trace:
#0 /Users/scott/Sites/littledollhouses/admin/configuration.php(137): zen_call_function('zen_uspsr_estim...', '1')
#1 /Users/scott/Sites/littledollhouses/admin/index.php(16): require('/Users/scott/Si...')
#2 {main}
thrown in /Users/scott/Sites/littledollhouses/admin/includes/functions/general.php on line 431.

[14-Oct-2025 16:57:08 America/New_York] Request URI: /admin/index.php?cmd=configuration&gID=6&cID=201&action=edit, IP address: ::1
--> PHP Fatal error: Uncaught Error: Call to undefined function zen_uspsr_estimate_days() in /Users/scott/Sites/littledollhouses/admin/includes/functions/general.php:431
Stack trace:
#0 /Users/scott/Sites/littledollhouses/admin/configuration.php(137): zen_call_function('zen_uspsr_estim...', '1')
#1 /Users/scott/Sites/littledollhouses/admin/index.php(16): require('/Users/scott/Si...')
#2 {main}
thrown in /Users/scott/Sites/littledollhouses/admin/includes/functions/general.php on line 431.

One way to fix this would be to put the function zen_uspsr_estimate_days in a separate file in includes/functions/extra_functions and then create a second file which includes this storefront file in admin/includes/functions/extra_functions.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

14 Oct 2025, 9:12 PM
#263
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Re: USPS Shipping (RESTful) (USPSr)

swguy:

If you go to modify the Zen Cart secret keys:

https://YOURSITE.com/admin/index.php?cmd=configuration&gID=6

You will get an error:

[14-Oct-2025 16:57:08 America/New_York] PHP Fatal error: Uncaught Error: Call to undefined function zen_uspsr_estimate_days() in /Users/scott/Sites/littledollhouses/admin/includes/functions/general.php:431
Stack trace:
#0 /Users/scott/Sites/littledollhouses/admin/configuration.php(137): zen_call_function('zen_uspsr_estim...', '1')
#1 /Users/scott/Sites/littledollhouses/admin/index.php(16): require('/Users/scott/Si...')
#2 {main}
thrown in /Users/scott/Sites/littledollhouses/admin/includes/functions/general.php on line 431

[14-Oct-2025 16:57:08 America/New_York] Request URI: /admin/index.php?cmd=configuration&gID=6&cID=201&action=edit, IP address: ::1
--> PHP Fatal error: Uncaught Error: Call to undefined function zen_uspsr_estimate_days() in /Users/scott/Sites/littledollhouses/admin/includes/functions/general.php:431
Stack trace:
#0 /Users/scott/Sites/littledollhouses/admin/configuration.php(137): zen_call_function('zen_uspsr_estim...', '1')
#1 /Users/scott/Sites/littledollhouses/admin/index.php(16): require('/Users/scott/Si...')
#2 {main}
thrown in /Users/scott/Sites/littledollhouses/admin/includes/functions/general.php on line 431.

[14-Oct-2025 16:57:08 America/New_York] Request URI: /admin/index.php?cmd=configuration&gID=6&cID=201&action=edit, IP address: ::1
--> PHP Fatal error: Uncaught Error: Call to undefined function zen_uspsr_estimate_days() in /Users/scott/Sites/littledollhouses/admin/includes/functions/general.php:431
Stack trace:
#0 /Users/scott/Sites/littledollhouses/admin/configuration.php(137): zen_call_function('zen_uspsr_estim...', '1')
#1 /Users/scott/Sites/littledollhouses/admin/index.php(16): require('/Users/scott/Si...')
#2 {main}
thrown in /Users/scott/Sites/littledollhouses/admin/includes/functions/general.php on line 431.

One way to fix this would be to put the function zen_uspsr_estimate_days in a separate file in includes/functions/extra_functions and then create a second file which includes this storefront file in admin/includes/functions/extra_functions.

Dang it, I thought I got all of these. I'll double everything in a bit and make another push later tonight.

14 Oct 2025, 11:17 PM
#264
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Re: USPS Shipping (RESTful) (USPSr)

swguy:

If you go to modify the Zen Cart secret keys:

https://YOURSITE.com/admin/index.php?cmd=configuration&gID=6

You will get an error:

[14-Oct-2025 16:57:08 America/New_York] PHP Fatal error: Uncaught Error: Call to undefined function zen_uspsr_estimate_days() in /Users/scott/Sites/littledollhouses/admin/includes/functions/general.php:431
Stack trace:
#0 /Users/scott/Sites/littledollhouses/admin/configuration.php(137): zen_call_function('zen_uspsr_estim...', '1')
#1 /Users/scott/Sites/littledollhouses/admin/index.php(16): require('/Users/scott/Si...')
#2 {main}
thrown in /Users/scott/Sites/littledollhouses/admin/includes/functions/general.php on line 431

[14-Oct-2025 16:57:08 America/New_York] Request URI: /admin/index.php?cmd=configuration&gID=6&cID=201&action=edit, IP address: ::1
--> PHP Fatal error: Uncaught Error: Call to undefined function zen_uspsr_estimate_days() in /Users/scott/Sites/littledollhouses/admin/includes/functions/general.php:431
Stack trace:
#0 /Users/scott/Sites/littledollhouses/admin/configuration.php(137): zen_call_function('zen_uspsr_estim...', '1')
#1 /Users/scott/Sites/littledollhouses/admin/index.php(16): require('/Users/scott/Si...')
#2 {main}
thrown in /Users/scott/Sites/littledollhouses/admin/includes/functions/general.php on line 431.

[14-Oct-2025 16:57:08 America/New_York] Request URI: /admin/index.php?cmd=configuration&gID=6&cID=201&action=edit, IP address: ::1
--> PHP Fatal error: Uncaught Error: Call to undefined function zen_uspsr_estimate_days() in /Users/scott/Sites/littledollhouses/admin/includes/functions/general.php:431
Stack trace:
#0 /Users/scott/Sites/littledollhouses/admin/configuration.php(137): zen_call_function('zen_uspsr_estim...', '1')
#1 /Users/scott/Sites/littledollhouses/admin/index.php(16): require('/Users/scott/Si...')
#2 {main}
thrown in /Users/scott/Sites/littledollhouses/admin/includes/functions/general.php on line 431.

One way to fix this would be to put the function zen_uspsr_estimate_days in a separate file in includes/functions/extra_functions and then create a second file which includes this storefront file in admin/includes/functions/extra_functions.

So this function already exists in /admin/includes/functions/extra_functions/usps.extra_functions.php as of v1.5.0. Which version of the module is being used?

15 Oct 2025, 9:26 AM
#265
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,720
Plugin Contributions:
56

Re: USPS Shipping (RESTful) (USPSr)

Ah 1.4.0, and I see you've fixed it in 1.5.0. Thanks.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

15 Oct 2025, 9:33 AM
#266
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,720
Plugin Contributions:
56

Re: USPS Shipping (RESTful) (USPSr)

It would be much better to make

./admin/includes/functions/extra_functions/usps.extra_functions.php

Just

<?php require DIR_FS_CATALOG . DIR_WS_FUNCTIONS . '/extra_functions/usps.extra_functions.php'; By duplicating the code you're running a risk that you could accidentally fix something in one place and not the other.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

15 Oct 2025, 10:10 AM
#267
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Re: USPS Shipping (RESTful) (USPSr)

swguy:

It would be much better to make

./admin/includes/functions/extra_functions/usps.extra_functions.php

Just

<?php require DIR_FS_CATALOG . DIR_WS_FUNCTIONS . '/extra_functions/usps.extra_functions.php'; By duplicating the code you're running a risk that you could accidentally fix something in one place and not the other.

Aha that's what I was looking for! Thanks.

15 Oct 2025, 12:17 PM
#268
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Re: USPS Shipping (RESTful) (USPSr)

retched:

Aha that's what I was looking for! Thanks.

So I had to expand upon this in a way (still trying to make sense of the PluginManager and FileSystem modules... came up with this instead:

// This should load the Front/Catalog version of this file
if (file_exists(DIR_FS_CATALOG . DIR_WS_FUNCTIONS . '/extra_functions/usps.extra_functions.php')) { // Are we in an encapsulate file?
    require DIR_FS_CATALOG . DIR_WS_FUNCTIONS . '/extra_functions/usps.extra_functions.php';
} else {
    // This is likely an encapsulated install... So we have to go the long way of including the original file
    require __DIR__ . '/../../../../catalog/includes/functions/extra_functions/usps.extra_functions.php';
}

I'm 99% sure there is a neater way to do this for encapsulated installs.

15 Oct 2025, 3:25 PM
#269
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,110
Plugin Contributions:
56

Re: USPS Shipping (RESTful) (USPSr)

retched:

So I had to expand upon this in a way (still trying to make sense of the PluginManager and FileSystem modules... came up with this instead:

// This should load the Front/Catalog version of this file
if (file_exists(DIR_FS_CATALOG . DIR_WS_FUNCTIONS . '/extra_functions/usps.extra_functions.php')) { // Are we in an encapsulate file?
require DIR_FS_CATALOG . DIR_WS_FUNCTIONS . '/extra_functions/usps.extra_functions.php';
} else {
// This is likely an encapsulated install... So we have to go the long way of including the original file
require DIR . '/../../../../catalog/includes/functions/extra_functions/usps.extra_functions.php';
}

> 
> I'm 99% sure there is a neater way to do this for encapsulated installs.
It depends on the Zen Cart version(s) being supported by your encapsulated plugin.

For POSM/6.1.1 (in core), see the following link for a bit more abbreviated processing:

 <https://github.com/zencart/zencart/blob/03d523bf6f62bb8fe42b404a9888fd31302f0e75/zc_plugins/POSM/v6.1.1/catalog/includes/classes/observers/class.products_options_stock_observer.php#L54-L63>

Note that the two classes used for that processing have been around since zc158.
15 Oct 2025, 3:31 PM
#270
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Re: USPS Shipping (RESTful) (USPSr)

lat9:

It depends on the Zen Cart version(s) being supported by your encapsulated plugin.

For POSM/6.1.1 (in core), see the following link for a bit more abbreviated processing:

https://github.com/zencart/zencart/blob/03d523bf6f62bb8fe42b404a9888fd31302f0e75/zc_plugins/POSM/v6.1.1/catalog/includes/classes/observers/class.products_options_stock_observer.php#L54-L63

Note that the two classes used for that processing have been around since zc158.

Currently, it's ZenCart 2.1.0 that has support for encapsulation. ZC 2.0.0 needs changes I believe since this is a front-side module.

16 Oct 2025, 5:53 PM
#272
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,720
Plugin Contributions:
56

Re: USPS Shipping (RESTful) (USPSr)

Version 1.5.0, non encapsulated. Maybe just change line 470 to check for no rates returned:

        foreach (($uspsQuote['rateOptions'] ?? []) as $opt) {

here's the log when this happens:

[16-Oct-2025 13:38:17 America/New_York] Request URI: /client/index.php?main_page=checkout_shipping, IP address: 50.247.14.209, Language id 1
#0 /home/thatsoft3/public_html/client/includes/modules/shipping/uspsr.php(470): zen_debug_error_handler()
#1 /home/thatsoft3/public_html/client/includes/classes/shipping.php(257): uspsr->quote()
#2 /home/thatsoft3/public_html/client/includes/modules/pages/checkout_shipping/header_php.php(185): shipping->quote()
#3 /home/thatsoft3/public_html/client/index.php(35): require('/home/thatsoft3...')
--> PHP Warning: Undefined array key "rateOptions" in /home/thatsoft3/public_html/client/includes/modules/shipping/uspsr.php on line 470.

[16-Oct-2025 13:38:17 America/New_York] Request URI: /client/index.php?main_page=checkout_shipping, IP address: 50.247.14.209, Language id 1
#0 /home/thatsoft3/public_html/client/includes/modules/shipping/uspsr.php(470): zen_debug_error_handler()
#1 /home/thatsoft3/public_html/client/includes/classes/shipping.php(257): uspsr->quote()
#2 /home/thatsoft3/public_html/client/includes/modules/pages/checkout_shipping/header_php.php(185): shipping->quote()
#3 /home/thatsoft3/public_html/client/index.php(35): require('/home/thatsoft3...')
--> PHP Warning: foreach() argument must be of type array|object, null given in /home/thatsoft3/public_html/client/includes/modules/shipping/uspsr.php on line 470.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

16 Oct 2025, 6:03 PM
#273
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,720
Plugin Contributions:
56

Re: USPS Shipping (RESTful) (USPSr)

(In the case I was testing, the order was too large/heavy to get quotes from USPS, had to use UPS.)

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

16 Oct 2025, 6:45 PM
#274
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Re: USPS Shipping (RESTful) (USPSr)

swguy:

Version 1.5.0, non encapsulated. Maybe just change line 470 to check for no rates returned:

        foreach (($uspsQuote['rateOptions'] ?? []) as $opt) {

here's the log when this happens:

[16-Oct-2025 13:38:17 America/New_York] Request URI: /client/index.php?main_page=checkout_shipping, IP address: 50.247.14.209, Language id 1
#0 /home/thatsoft3/public_html/client/includes/modules/shipping/uspsr.php(470): zen_debug_error_handler()
#1 /home/thatsoft3/public_html/client/includes/classes/shipping.php(257): uspsr->quote()
#2 /home/thatsoft3/public_html/client/includes/modules/pages/checkout_shipping/header_php.php(185): shipping->quote()
#3 /home/thatsoft3/public_html/client/index.php(35): require('/home/thatsoft3...')
--> PHP Warning: Undefined array key "rateOptions" in /home/thatsoft3/public_html/client/includes/modules/shipping/uspsr.php on line 470.

[16-Oct-2025 13:38:17 America/New_York] Request URI: /client/index.php?main_page=checkout_shipping, IP address: 50.247.14.209, Language id 1
#0 /home/thatsoft3/public_html/client/includes/modules/shipping/uspsr.php(470): zen_debug_error_handler()
#1 /home/thatsoft3/public_html/client/includes/classes/shipping.php(257): uspsr->quote()
#2 /home/thatsoft3/public_html/client/includes/modules/pages/checkout_shipping/header_php.php(185): shipping->quote()
#3 /home/thatsoft3/public_html/client/index.php(35): require('/home/thatsoft3...')
--> PHP Warning: foreach() argument must be of type array|object, null given in /home/thatsoft3/public_html/client/includes/modules/shipping/uspsr.php on line 470.

Noted and logged. I'll try to have a fix for this by the end of the afternoon.

17 Oct 2025, 10:25 AM
#275
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,720
Plugin Contributions:
56

Re: USPS Shipping (RESTful) (USPSr)

Two more suggested checks (line numbers per current github):

line 1630, change
$selectedState = $_POST['state'];
to
$selectedState = $_POST['state'] ?? '';

line 1643, change

                $selected_state_id = $zone_id->fields['zone_id'];

to
$selected_state_id = $zone_id->fields['zone_id'] ?? 0;

(note this is already done on line 1631).

This is to suppress logs arising from this array index not being set.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

17 Oct 2025, 12:21 PM
#276
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Re: USPS Shipping (RESTful) (USPSr)

swguy:

Two more suggested checks (line numbers per current github):

line 1630, change
$selectedState = $_POST['state'];
to
$selectedState = $_POST['state'] ?? '';

line 1643, change

                $selected_state_id = $zone_id->fields['zone_id'];

to
$selected_state_id = $zone_id->fields['zone_id'] ?? 0;

(note this is already done on line 1631).

This is to suppress logs arising from this array index not being set.

Got that too. I also ended up going about fixing the earlier warning by just checking to see if there are rates in the first place. It should generate an "error" condition and only display when it's an array of options (it shouldn't be a scalar value anyway):

if (isset($uspsQuote['rateOptions']) && is_array($uspsQuote['rateOptions'])) {

There's a bit more involved in the code change, so I don't suggest anyone just slap this in and call it a day. A full patch will be out shortly for people to use.

17 Oct 2025, 6:24 PM
#277
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Re: USPS Shipping (RESTful) (USPSr)

marcopolo:

Has anyone integrated this module with Shipping Boxes Manager?

Coming back to this, looking at the changes that were needed for the most recent Shipping Boxes Manager and the changes made in that usps.php: there's not much for me to do.

The only changes made to work with USPS' WebTools and Shipping Boxes Manager is that the following:

      // shipping boxes manager
      if (MODULE_SHIPPING_BOXES_MANAGER_STATUS == 'true') {
        global $packed_boxes, $total_weight;
        if (is_array($packed_boxes) && sizeof($packed_boxes) && $total_weight > 0) {
          //$shipping_num_boxes = sizeof($packed_boxes);
          //$shipping_weight = round(($total_weight / $shipping_num_boxes), 2); // use our number of packages rather than Zen Cart's calculation, package weight will still have to be an average since we don't know which products are in the box.
          $width = $height = $length = 0;
          foreach ($packed_boxes as $packed_box) {
            if ($packed_box['width'] > $width) $this->dimensions['width'] = $packed_box['width'];
            if ($packed_box['height'] > $height) $this->dimensions['height'] = $packed_box['height'];
            if ($packed_box['length'] > $length) $this->dimensions['length'] = $packed_box['length'];
          }                                                                                                                                
          $usps_shipping_weight = $shipping_weight;
        }
      }

The two commented out lines changes the "number of boxes" to the total size of the array of packed boxes. Additionally, the module would loop through each "box" and set each dimension to the largest of each box and send that out to the quote request. (Looking at this line... I'm not sure how that came up... but anyway.)

The next blocks: called for the calculation of "girth" but the USPS API seems to remove that. Specifically blocks like this:

        if (MODULE_SHIPPING_BOXES_MANAGER_STATUS == 'true' && $this->dimensions['width'] > 0 && $this->dimensions['length'] > 0 && $this->dimensions['height' > 0]) {


               $width = $this->dimensions['width'];
               $length = $this->dimensions['length'];
               $height = $this->dimensions['height'];
               $girth = 0;


                         $SBM_additonal_size = '<Size>REGULAR</Size>';
                        if($width >= 12){
                            $SBM_additonal_size = '<Size>LARGE</Size>';
                            $girth = $width + $width + $length + $length;
                            $ground_servs = '<GroundOnly>true</GroundOnly>';
                        }


              $SBM_additonal_dem = '';
              $SBM_additonal_dem = '<Width>' . $width . '</Width>' .
              '<Length>' . $length . '</Length>' .
              '<Height>' . $height . '</Height>' .
              '<Girth>' . $girth . '</Girth>';
        } else {
            $SBM_additonal_dem = '';
            $SBM_additonal_size = '<Size>REGULAR</Size>';
        }

The USPS REST API doesn't allow for the girth field to be used. (I'm assuming it's calculated on the API side and not so much locally.) So this is kind of moot.

Instead of forcing this, I'm going to expand the notifier/observer for NOTIFY_SHIPPING_USPS_BEFORE_GETQUOTE to include a way to modify the dimensions (which are now stored in an array). Additionally that same notifier/observer will also allow you to modify the number of shipping boxes and the weight of the package as well by this:

$this->notify('NOTIFY_SHIPPING_USPS_BEFORE_GETQUOTE', [], $order, $this->quote_weight, $shipping_num_boxes, $this->dimensions);

Using that notifier, it will be triggered immediately before the quote log is started and the quote is dispatched to the USPS server. If there's something I'm missing, by all means, let me know.

17 Oct 2025, 7:13 PM
#278
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,720
Plugin Contributions:
56

Re: USPS Shipping (RESTful) (USPSr)

Got that too.

Lines 1660 and 1662 also need null coalesce.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

17 Oct 2025, 8:12 PM
#279
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Re: USPS Shipping (RESTful) (USPSr)

swguy:

Got that too.

Lines 1660 and 1662 also need null coalesce.

My code might have shifted but I believe I covered those?

if (!zen_is_logged_in() && ($_GET['main_page'] === 'shopping_cart' || $_GET['main_page'] === 'popup_shipping_estimator')) {


    $selectedState = $_POST['state'] ?? "";
    $selected_state_id = $_POST['zone_id'] ?? 0;


    if (!zen_not_null($selectedState) || $selected_state_id < 1) {
        // If there is no number
        $zone_id = $db->Execute(
            "SELECT zone_id
                FROM ". TABLE_ZONES . "
                WHERE
                zone_name LIKE '" . $_POST['state']  . "'
                OR
                zone_code LIKE '" . $_POST['state'] .  "'");


        $selected_state_id = $zone_id->fields['zone_id'] ?? 0;
    }


    if (zen_not_null($selected_state_id)) { // No $zone_id, don't check the result list.
        // Reset $check
        $check->rewind();
        while(!$check->EOF) {
            if ($selected_state_id == $check->fields['zone_id']) {
                $check_flag = true;
                break;
            }
            $check->MoveNext();
        }
    }


}
17 Oct 2025, 8:44 PM
#280
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,720
Plugin Contributions:
56

Re: USPS Shipping (RESTful) (USPSr)

Look at the query. It still uses $_POST['state']. Perhaps change to $selectedState or add null coalesce.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.