Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

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


Guest

Recommended Posts

57 minutes ago, kymation said:

The returned names need to match what's in the code. If they don't match the quote won't be displayed, even if it was properly returned.

Regards

Jim

My inference is that USPS have changed the value returned by the retail first class service, but if they have started using different names for the online and retail services it's not immediately obvious how the existing module structure will cope with it.

I'm a bit puzzled by the quote request sending both First Class Parcel and First Class Package as package.

[edited for English]

Edited by BrockleyJohn

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Link to comment
Share on other sites

  • 3 weeks later...

@kymation

Jim,

I've narrowed down that MVS sessions issue to the USPS module from this addon. I used the MVS version from this addon. When installed and I try to proceed to the checkout_payment.php page, the session ends and I get redirected to the login page. The checkout_shipping.php page looks fine, it is just when I try to continue to the payment page is when the session ends.

The exact error is:

[05-Mar-2018 23:49:27 America/New_York] PHP Warning:  session_start(): Failed to decode session object. Session has been destroyed in /home/xxxxxx/public_html/dev2/includes/functions/sessions.php on line 110

When I disable or uninstall that USPS module, the problem goes away.

Could you try and test it on your end to see if this is in fact a bug? I have this set up on BS Edge with PHP7.1.7

Thanks.

 

Edited by Demitry

osCommerce: made for programmers, ...because store owners do not want to be programmers.

https://trends.google.com/trends/explore?date=all&geo=US&q=oscommerce

Link to comment
Share on other sites

I have that USPS module running on several live sites with no problems. However, those are old-style osC 2.3.4 and not Edge. It's either a conflict with Edge or with PHP 7.x.

I'll try to do some testing, but I'm really busy with other things right now, so don't hold your breath.

Regards

Jim

PS It could be the class constructor in PHP 7. Try changing this code in the usps.php module file:

function usps() {

to this

function __construct() {

 

Edited by kymation
Afterthought

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

I have just installed it on Edge on 5.3 with no issues other than their changing the service names again.

It can't be the constructor as the quote works ok. It's when the shipping gets loaded into the session it clobbers it - probably dodgy characters or something along those lines. Try echoing out what it's putting in the session and exiting before the redirect to checkout_payment.

Edited by BrockleyJohn

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Link to comment
Share on other sites

@kymation

Jim,

It's not the constructor issue. That was the only thing I changed in that file. The constructor error would have come up as an on-page PHP error, and not the logged session destroyed error written to the error log file.

@BrockleyJohn

John,

I was thinking something similar,.. perhaps along the lines of conflicts with unicode utf8, however, I am not sure of how to test the session, especially when dealing with a back-end process.

Try echoing out what it's putting in the session and exiting before the redirect to checkout_payment. 

I apologize in advance as this is likely a simple and common way of testing, but I've never done it and am not sure how to do that.

Could you tell me the steps to do this? I've never looked at the contents of a session and am not sure how I can. What I've done was to determine where the session is being killed and that was at the following line in checkout_shipping.php Both the $sessiontoken and tep_session_is_registered('customer_id') came up empty after this line.

  if ( isset($_POST['action']) && ($_POST['action'] == 'process') && isset($_POST['formid']) && ($_POST['formid'] == $sessiontoken) ) {

So, after that I started checking the installed modules one-by-one and that's how I discovered that the USPS module was causing the session issue. However, I'm  now a bit stuck because I am not sure how to further test to identify the issue in this module.

 

osCommerce: made for programmers, ...because store owners do not want to be programmers.

https://trends.google.com/trends/explore?date=all&geo=US&q=oscommerce

Link to comment
Share on other sites

To see the session data, try inserting this code where you want to see the values:

print '<pre>';
var_dump ( $_SESSION );
die;

That will display all of the values in the current session. Move that code around until you find out what is destroying the variable you want.

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

@kymation

Jim, that did work and I am able to view the session output,.. but I am not sure what I'm looking for in this output, or how it will pin point where the code issue is in the usps.php module file.

 

 

 

osCommerce: made for programmers, ...because store owners do not want to be programmers.

https://trends.google.com/trends/explore?date=all&amp;geo=US&amp;q=oscommerce

Link to comment
Share on other sites

If the session is destroyed the code will show an empty array (no data). If you can find the line where the session exists and contains data, and the next line the session is empty, you have found the location of the problem. It takes a bit of trial and error to narrow it down.

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

@Demitry yes, it's inside that "if" where the action happens. I'd start with here at line 126 :

            if ( (isset($quote[0]['methods'][0]['title'])) && (isset($quote[0]['methods'][0]['cost'])) ) {
              $shipping = array('id' => $shipping,
                                'title' => (($free_shipping == true) ?  $quote[0]['methods'][0]['title'] : $quote[0]['module'] . ' (' . $quote[0]['methods'][0]['title'] . ')'),
                                'cost' => $quote[0]['methods'][0]['cost']);

              tep_redirect(tep_href_link('checkout_payment.php', '', 'SSL'));
            }

and dump out the contents of $shipping before the redirect to checkout payment.

It could be something as simple as dodgy characters in your language file. You could start by replacing it and see if that fixes the problem before code-fiddling.

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Link to comment
Share on other sites

@BrockleyJohn

John, it's actually a bit higher in the code because I am using the MVS addon. So, what I did was to comment out the redirect to the payment page and pulled the session content right before the redirect to the payment page in checkout_shipping.php By the point that this redirect is reached on that page, the session has already been destroyed. That's why as soon as the checkout_payment.php page loads, the first redirect is to the login page.

// process the selected shipping method
  if ( isset($_POST['action']) && ($_POST['action'] == 'process') && isset($_POST['formid']) && ($_POST['formid'] == $sessiontoken) ) {
    if (!tep_session_is_registered('comments')) tep_session_register('comments');
    if (tep_not_null($_POST['comments'])) {
      $comments = tep_db_prepare_input($_POST['comments']);
    }

    if (!tep_session_is_registered('shipping')) tep_session_register('shipping');

// MVS start
      if (SELECT_VENDOR_SHIPPING == 'true') {
        $total_shipping_cost = 0;
        $shipping_title = MULTIPLE_SHIP_METHODS_TITLE;
        $vendor_shipping = $cart->vendor_shipping;
        $shipping = array();

        foreach ($vendor_shipping as $vendor_id => $vendor_data) {
          $products_shipped = $_POST['products_' . $vendor_id];
          $products_array = explode ("_", $products_shipped);

          $shipping_data = $_POST['shipping_' . $vendor_id];
          $shipping_array = explode ("_", $shipping_data);
          $module = $shipping_array[0];
          $method = $shipping_array[1];
          $ship_tax = $shipping_array[2];

          if ( is_object($$module) || ($module == 'free') ) {
            if ($module == 'free') {
              $quote[0]['methods'][0]['title'] = FREE_SHIPPING_TITLE;
              $quote[0]['methods'][0]['cost'] = '0';
            } else {
              $total_weight = $vendor_shipping[$vendor_id]['weight'];
              $shipping_weight = $total_weight;
              $cost = $vendor_shipping[$vendor_id]['cost'];
              $total_count = $vendor_shipping[$vendor_id]['qty'];
              $quote = $shipping_modules->quote($method, $module, $vendor_id);

            }
            if (isset($quote['error'])) {
              tep_session_unregister('shipping');
            } else {
              if ( (isset($quote[0]['methods'][0]['title'])) && (isset($quote[0]['methods'][0]['cost'])) ) {
                $output[$vendor_id] = array('id' => $module . '_' . $method,
                                            'title' => $quote[0]['methods'][0]['title'],
                                            'ship_tax' => $ship_tax,
                                            'products' => $products_array,
                                            'cost' => $quote[0]['methods'][0]['cost']
                                           );
                $total_ship_tax += $ship_tax;
                $total_shipping_cost += $quote[0]['methods'][0]['cost'];
              }//if isset
            }//if isset
          }//if is_object
        }//foreach
        if ($free_shipping == true) {
          $shipping_title = $quote[0]['module'];
        } elseif (count($output) < 2) {
          $shipping_title = $quote[0]['methods'][0]['title'];
        }
//MVS
        $shipping = array('id' => $_SESSION['shipping'],
                          'title' => $shipping_title,
                          'cost' => $total_shipping_cost,
                          'shipping_tax_total' => $total_ship_tax,
                          'vendor' => $output
                         );
print '<pre>';
var_dump($_SESSION);
die;
        //tep_redirect(tep_href_link('checkout_payment.php', '', 'SSL'));
      } else { // MVS if (SELECT_VENDOR_SHIPPING == 'true')
// MVS end

    if ( (tep_count_shipping_modules() > 0) || ($free_shipping == true) ) {
      if ( (isset($_POST['shipping'])) && (strpos($_POST['shipping'], '_')) ) {
        $shipping = $_POST['shipping'];

        list($module, $method) = explode('_', $shipping);
        if ( is_object($$module) || ($shipping == 'free_free') ) {
          if ($shipping == 'free_free') {
            $quote[0]['methods'][0]['title'] = FREE_SHIPPING_TITLE;
            $quote[0]['methods'][0]['cost'] = '0';
          } else {
            $quote = $shipping_modules->quote($method, $module);
          }
          if (isset($quote['error'])) {
            tep_session_unregister('shipping');
          } else {
            if ( (isset($quote[0]['methods'][0]['title'])) && (isset($quote[0]['methods'][0]['cost'])) ) {
              $shipping = array('id' => $shipping,
                                'title' => (($free_shipping == true) ? $quote[0]['methods'][0]['title'] : $quote[0]['module'] . ' (' . $quote[0]['methods'][0]['title'] . ')'),
                                'cost' => $quote[0]['methods'][0]['cost']);

              tep_redirect(tep_href_link('checkout_payment.php', '', 'SSL'));
            }
          }
        } else {
          tep_session_unregister('shipping');
        }
      }
    } else {
      if ( defined('SHIPPING_ALLOW_UNDEFINED_ZONES') && (SHIPPING_ALLOW_UNDEFINED_ZONES == 'False') ) {
          tep_session_unregister('shipping');
      } else {
          $shipping = false;
          tep_redirect(tep_href_link('checkout_payment.php', '', 'SSL'));
      }
    } // if ( (tep_count_shipping_modules() > 0)
   } // MVS if (SELECT_VENDOR_SHIPPING == 'true') 
  } // if ( isset($_POST['action']) &&

However, what I think I should be doing is testing the session output in the actual USPS module file. Am I right on that?

 

Regarding the language file and replacing it. I assume you mean the /admin/language.php file, but replace it with what? My BS Edge version is from last August. I'm not sure if there is a more updated version out or if that file was updated since the release I have installed. Is that what you meant?

 

 

 

 

Edited by Demitry

osCommerce: made for programmers, ...because store owners do not want to be programmers.

https://trends.google.com/trends/explore?date=all&amp;geo=US&amp;q=oscommerce

Link to comment
Share on other sites

no I mean the language file of the USPS shipping module in catalog/includes/languages/english/modules/shipping/

Is MVS compatible with USPS? USPS is a module that uses all the features of osc shipping, returning multiple 'ways' for a single 'method'

I am asking because I have little experience in USPS and none in MVS, and won't have time to look properly at the code until this evening (UK time)

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Link to comment
Share on other sites

@BrockleyJohn

thanks, I checked that language file and other than a url link for one of the definitions and <br /> instead of a <br> there are no special characters that would trigger this session kill.

There is a USPS module in the MVS addon, so it is supposed to work with it. However, I used the one form this contribution, which is a more detailed and better module. This addon also has a version specifically for the MVS module and that is the one I am working with.

I'll keep testing for the session break to see what code in this USPS module with require adjustment.

 

 

osCommerce: made for programmers, ...because store owners do not want to be programmers.

https://trends.google.com/trends/explore?date=all&amp;geo=US&amp;q=oscommerce

Link to comment
Share on other sites

@Demitry you don't need to dump what's in the session you should be dumping what's in the shipping array with and without USPS. However my gut feel is that the problem does not lie with USPS but with MVS. Specifically, I don't like the look of this line at all:

        $shipping = array('id' => $_SESSION['shipping'],

I don't see what it's trying to do and setting the shipping id to a value that could easily be an array seems like a very bad idea to me.

I suspect your problems with USPS included may be coincidental. How many other enabled shipping methods are there?

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Link to comment
Share on other sites

@BrockleyJohn

That line was added for MVS v1.3 (latest though not for BS Edge) by @drillsar here is the link to it. And @kymation Jim says that it's necessary just below that first post.

Here is the same line in my MVS install for an older version of osC (MS2.2) and one that does not have this sessions issue. However, that site is running on PHP5.3

$shipping = array('id' => $shipping,

I've tested this line by switching to the one without the session variable, but it made no difference.

I have the following modules enabled (USPS, FedEx Web Services, Table, UPS ), however, none of the other ones cause a problem with the session. I had remove them all and added them one by one while testing the checkout with each add. The one that caused the issue is the USPS module. If I disable it or remove it, I can get to the checkout_payment.php page. With it enabled I get the login.php page.

I appreciate your help John.

 

Edited by Demitry

osCommerce: made for programmers, ...because store owners do not want to be programmers.

https://trends.google.com/trends/explore?date=all&amp;geo=US&amp;q=oscommerce

Link to comment
Share on other sites

@Demitry if you dump out $vendor_shipping before this line

        foreach ($vendor_shipping as $vendor_id => $vendor_data) {

what do you get?

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Link to comment
Share on other sites

@BrockleyJohn

For that var_dump of $vendor_shipping right before the line you mentioned I get the following:

array(2) {
  [1]=>
  array(6) {
    ["weight"]=>
    float(7)
    ["cost"]=>
    float(35.99)
    ["qty"]=>
    int(1)
    ["ship_cost"]=>
    float(0)
    ["products_id"]=>
    array(1) {
      [0]=>
      int(8)
    }
    ["products_qty"]=>
    array(1) {
      [8]=>
      string(1) "1"
    }
  }
  [2]=>
  array(6) {
    ["weight"]=>
    float(7)
    ["cost"]=>
    float(39.99)
    ["qty"]=>
    int(1)
    ["ship_cost"]=>
    float(0)
    ["products_id"]=>
    array(1) {
      [0]=>
      int(17)
    }
    ["products_qty"]=>
    array(1) {
      [17]=>
      string(1) "1"
    }
  }
}

And I forgot to include Flat Rate as one of the shipping options I have for the current testing scenario. Here is a screenshot of the shipping options as I have them. USPS in the first vendor's product is not the cheapest method, but I selected it to display related testing data. The other modules really do nothing in relation to this sessions issue. I could just as well remove them all and just have USPS for both vendor products.

checkout-screenshot.thumb.png.8860e0ce277a45c54e44f5424e1872d2.png

osCommerce: made for programmers, ...because store owners do not want to be programmers.

https://trends.google.com/trends/explore?date=all&amp;geo=US&amp;q=oscommerce

Link to comment
Share on other sites

  • 1 month later...
3 minutes ago, [email protected] said:

65 pages deep, I just dont have time to read it. can anyone tell me what the three letters N S H under extra services, what do they mean?

need sense of humour

Contact me for work on updating existing stores - whether to Phoenix or the new osC when it's released.

Looking for a payment or shipping module? Maybe I've already done it.

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Link to comment
Share on other sites

Quote

Extra Services (Domestic)
Certified MailRM, N, Insurance, S, Adult Signature Restricted Delivery, N, Registered without Insurance, N, Registered MailTM, N, Collect on Delivery, N, Return Receipt for Merchandise, N, Return Receipt, N, Certificate of Mailing, N, Express Mail Insurance, N, Delivery ConfirmationTM, N, Signature ConfirmationTM, N

Extra Services (International)
Registered Mail, N, Insurance, S, Return Receipt, N, Restricted Delivery, N, Pick-Up, N, Certificate of Mailing, N

I have everything as N except for Insurance is S. When I make a test purchase the insurance is not being added nor is it displayed. Am I doing something wrong?

Edited by [email protected]
to add info
Link to comment
Share on other sites

USPS Priority and Priority Express allow insurance.

Quote

Shipping Methods (Domestic and International)
0, 70, 0.00, 0, 70, 0.00, 0, 70, 0.00, 0, 70, 0.00, 0, 70, 0.00, 0, 70, 0.00, 0, 70, 0.00, Priority MailTM, 0, 70, 0.00, 0, 70, 0.00, 0, 70, 0.00, 0, 70, 0.00, 0, 70, 0.00, 0, 70, 0.00, 0, 70, 0.00, 0, 70, 0.00, 0, 70, 0.00, Priority Mail ExpressTM, 0, 70, 0.00, 0, 70, 0.00, 0, 70, 0.00, 0, 70, 0.00, 0, 70, 0.00, 0, 70, 0.00, Priority Mail InternationalRM, 0, 70, 0.00, 0, 70, 0.00, 0, 70, 0.00, 0, 70, 0.00, 0, 70, 0.00, Priority Mail Express InternationalTM, 0, 70, 0.00, 0, 70, 0.00, 0, 70, 0.00, 0, 70, 0.00

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...