Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

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


Guest

Recommended Posts

This is another incompatibility issue in recent versions of Edge. Compare your includes/configure.php with the stock osCommerce 2.3.4 version and add back the missing defines.

 

Regards

Jim

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

Link to comment
Share on other sites

  • 1 month later...

How can I change the name of various services? Instead of Standard Post for example I wish to change to Standard Ground.

I was looking in the languages file but it doesn't seem well laid out.

Thank you

Edited by kieran_mullen
Link to comment
Share on other sites

Don't do this. Those service names are trademarks of the USPS. Changing them violates the agreement you signed when you opened a USPS Web Services account. You risk losing your account, and the ability to get quotes as a result.

Regards

Jim

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

Link to comment
Share on other sites

  • 1 month later...

As others have reported here before, I am also getting the following warning for SOME countries:

Warning: Invalid argument supplied for foreach() in xxxxx\catalog-m3\includes\modules\shipping\usps.php on line 123

But, the post office DOES return a postage rate, even for the countries that produce this warning.

I've not tested EVERY country, but of the handful that I have tested ...

Afghanistan: warning
Cambodia: warning
Canada: no warning
Denmark: no warning
Netherlands: no warning
Turkey: no warning
UK: warning
United States (with or without ZIP code): no warning

I enabled the debugging email, but can not see any commonality in the emails between those countries that produce the warning, and/or those that do not. I can post them here, if anyone wishes.

Has anyone found a solution for this?

TIA

Malcolm

Link to comment
Share on other sites

I believe that there were issues with the country name that is stored in the database being incompatible with what the USPS expects. You might compare the entries that you have for the problem countries with the table from the latest osC release, or you may need to get the list from the USPS.

Regards

Jim

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

Link to comment
Share on other sites

@kymation

Thanks, Jim.

I just looked through the USPS debug emails. All of the requests have the country in mixed caps (ex: Canada), and the reply has it in all caps (ex: CANADA). This is the same for both the countries that produce the warning, and the countries that don't.

Besides the case, the country requested and the country replied are the same. Besides, if the country name requested (ie: in the database) is different than what the USPS is expecting, how is it that the USPS does return a postage cost?

Malcolm

Edited by ArtcoInc
Link to comment
Share on other sites

Ok, I found this list of countries on the USPS website ...

https://pe.usps.com/text/imm/ab_toc.htm

And I compared it to my database. There were some differences (some countries on one list but not the other), but for the three warning countries I listed above ...

Afghanistan: warning <--- The countries were the same in both
Cambodia: warning <--- The countries were the same in both
UK: warning <--- The USPS has it as 'Great Britain and Northern Ireland' and osC has it as 'United Kingdom'

The USPS debug email for the UK says ...

Request:
API=IntlRateV2&XML=<IntlRateV2Request USERID="************">
  <Revision>2</Revision>
  <Package ID="0">
    <Pounds>5</Pounds>
    <Ounces>1.6</Ounces>
    <MailType>All</MailType>
    <GXG>
      <POBoxFlag>N</POBoxFlag>
      <GiftFlag>N</GiftFlag>
    </GXG>
    <ValueOfContents>0</ValueOfContents>
    <Country>United Kingdom</Country>
    <Container>RECTANGULAR</Container>
    <Size>LARGE</Size>
    <Width>0.2</Width>
    <Length>0.2</Length>
    <Height>0.2</Height>
    <Girth>0</Girth>
    <OriginZip>95112</OriginZip>
    <CommercialFlag>Y</CommercialFlag>
    <ExtraServices>
      <ExtraService>0</ExtraService>
      <ExtraService>1</ExtraService>
      <ExtraService>2</ExtraService>
      <ExtraService>3</ExtraService>
      <ExtraService>6</ExtraService>
      <ExtraService>9</ExtraService>
    </ExtraServices>
  </Package>
</IntlRateV2Request>


Response:
<?xml version="1.0" encoding="UTF-8"?>
<IntlRateV2Response>
  <Package ID="0">
    <Prohibitions>Aerosols. Ammunition, except lead pellets. Animals, live (including reptiles). Arms and parts of arms, or any component classified as munitions of war; imitations and antiques; paint-ball or toy guns; taser guns; air rifles, air pistols, components of firearms, and all other items similar to or resembling the foregoing. Articles, goods infringing British trademarks or copyright laws. Asbestos items of any kind. Christmas crackers (holiday popper). Clinical and medical waste (e.g., contaminated dressings, bandages, and needles). Coins; platinum, gold, or silver (manufactured or not); precious
stones; jewels; and other valuable articles. Counterfeit currency, bank notes, and postage stamps. Dies and equipment for making imitations, etc., of any current postage stamp for denoting any rate of postage. Fish, live. Frozen food. Frozen water (including bags of ice). Goods made in foreign prisons, except those imported for a noncommercial purpose or of a kind not manufactured in the United Kingdom. Human and animal cremated remains (ashes). Indecent and obscene prints, paintings, books, cards, lithographs, and other engravings, films, video tapes, or any other indecent or obscene articles. Lead acid batteries (e.g., car batteries) and sealed lead acid batteries. Lottery tickets and related advertisements for illegal lotteries. Medicines classified as flammable or toxic. Radioactive materials and samples that are classified as radioactive using Table 2-12 of the latest edition of the International Civil Aviation organization''s Technical Instructions - e.g., fissile material (uranium 235, etc.), radioactive waste material, thorium, or uranium ores and luminous dials from aircraft. Soil. Soiled clothes and rags. Stun gun, electric. Switchblade knives (also knows as flick knives) and gravity knives. Waste, dirt, filth, or refuse, including household waste or rubbish.
    </Prohibitions>
    <Restrictions>A consignment of live bees must contain only queen bees and their attendant workers; colonies are not permitted. Each consignment must be accompanied by an import license issued by the Dept. of Agriculture (DEFRA) and a health
certificate issued by the country of origin. Caterpillars, cockroaches, crickets, destroyers of noxious pests, earthworms, fish fry and eggs, flies of the family Drosophilidae, leeches, lugworms, maggots, mealworms, pupae and chrysalides, rag worms, silkworms, spiders, and stick insects are admissible only for biomedical research (see license requirement for bees). Medicines and drugs when sent for scientific purposes must be sent by a practitioner, registered dental practitioner, veterinary surgeon, registered nurse, or recognized laboratory or institution. Plants and parts of plants require an
import permit issued by the appropriate Agricultural Department in the United Kingdom. Vaccines may be sent only by, or at the specific request of, a qualified medical practitioner, registered dental practitioner, veterinary surgeon, registered nurse, or recognized laboratory or institution.</Restrictions>
    <Observations>1. The following is a list of the names of the counties and city names in Northern Ireland. The County names are in capital letters. The geographic identifiers should be used in addressing mail to Northern Ireland:

ANTRIM:
Antrim
Ballymena
Belfast
Carrickfergus
Larne
Lisburn
Portrush
Toomebridge
Whitehead

ARMAGH:
Armagh
Lurgan
Portsdown

DOWN:
Banbridge
Bangor
Downpatrick
Kilkeel
Newcastle
Newry
Newtownards

LONDONDERRY:
Coleraine
Kilrea
Limavady
Londonderry
Magherafelt
Portstewart

TYRONE:
Cookstown
Dugannon
Moy
Omagh
Strabane

FERMANAGH:
Enniskillen

2. Many types of merchandise, unless sent as unsolicited gifts, require import licenses
that the addressees must obtain from the British Board of Trade. Before mailing commercial
shipments, senders should be assured that the addressees can obtain licenses if needed. 3.
All goods sent to the UK are liable to customs duty and Value Added Tax on importation
whether or not the package is marked as a "gift." Packages are admitted free of customs
charges, however, if they meet the following conditions: (a) Gift packages of small value
provided they do not contain any tobacco goods, spirits or wine; (b) Gift packages
containing only well-worn clothing (excluding garments of high value), limited quantities
of foodstuffs (other than caviar), soap or consumable medical supplies. 4. Postal packages
without a customs declaration that contain goods liable to customs duty or control may be
seized by the customs authorities. 5. Firearms that are intended for sporting purposes are
mailable to Great Britain, provided the prospective addressee has obtained the required
import license. 6. Great Britain limits the weight of M-bags to 20 kg. (44 lbs.).
    </Observations>
    <CustomsForms>First-Class Mail International items and Priority Mail International Flat Rate Envelopes and Small Flat Rate Boxes: PS Form 2976 (see 123.61) Priority Mail International parcels: PS Form 2976-A inside 2976-E (envelope)
    </CustomsForms>
    <ExpressMail>Country Code:  GB  

Reciprocal Service Name:  
Datapost  

Required Customs Form/Endorsement   
1. Business correspondence, commercial papers, and documents.
PS Form 2976-B placed inside PS Form 2976-E (plastic envelope). Endorse item clearly next
to mailing label as BUSINESS PAPERS.

2. Merchandise samples without commercial value.
PS Form 2976-B placed inside PS Form 2976-E (plastic envelope).

3. Merchandise and all articles subject to customs duty.
PS Form 2976-B placed inside PS Form 2976-E (plastic envelope).


Note:
1. Coins; banknotes; currency notes, including paper money; securities of any kind payable
to bearer; traveler's checks; platinum, gold, and silver; precious stones; jewelry;
watches; and other valuable articles are prohibited in Priority Mail Express International
shipments to Great Britain and Northern Ireland. 2. Priority Mail Express International
With Guarantee service - which offers a date-certain, postage-refund guarantee - is
available to Great Britain and Northern Ireland.

Areas Served:

All points in England, Scotland, Wales, Northern Ireland, Guernsey, Jersey, Alderney, Sark, and the Isle of Man.
    </ExpressMail>
    <AreasServed>Please reference Express Mail for Areas Served.</AreasServed>
    <AdditionalRestrictions>No Additional Restrictions Data found.</AdditionalRestrictions>
    <Service ID="4">
      <Pounds>5</Pounds>
      <Ounces>1.6</Ounces>
      <MailType>All</MailType>
      <GXG>
        <POBoxFlag>N</POBoxFlag>
        <GiftFlag>N</GiftFlag>
      </GXG>
      <Container>RECTANGULAR</Container>
      <Size>LARGE</Size>
      <Width>0.2</Width>
      <Length>0.2</Length>
      <Height>0.2</Height>
      <Girth>0</Girth>
      <Country>UNITED KINGDOM</Country>
      <Postage>124.50</Postage>
      <CommercialPostage>118.28</CommercialPostage>
      <ExtraServices>
        <ExtraService>
          <ServiceID>1</ServiceID>
          <ServiceName>Insurance</ServiceName>
          <Available>True</Available>
          <OnlineAvailable>True</OnlineAvailable>
          <Price>0.00</Price>
          <PriceOnline>0.00</PriceOnline>
          <DeclaredValueRequired>True</DeclaredValueRequired>
        </ExtraService>
      </ExtraServices>
      <SvcCommitments>1 - 3 business days to many major markets</SvcCommitments>
      <SvcDescription>Global Express Guaranteed&lt;sup&gt;&#174;&lt;/sup&gt; (GXG)</SvcDescription>
      <MaxDimensions>Max. length 46", width 35", height 46" and max. length plus girth combined 108"</MaxDimensions>
      <MaxWeight>70</MaxWeight>
      <GXGLocations>
        <PostOffice>
          <Name>COLONNADE</Name>
          <Address>200 S 3RD ST</Address>
          <City>SAN JOSE</City>
          <State>CA</State>
          <ZipCode>95112</ZipCode>
          <RetailGXGCutOffTime>3:00 PM</RetailGXGCutOffTime>
          <SaturDayCutOffTime>12:00 PM</SaturDayCutOffTime>
        </PostOffice>
        <PostOffice>
          <Name>SPARTAN SHOPS INC</Name>
          <Address>1125 N 7TH ST</Address>
          <City>SAN JOSE</City>
          <State>CA</State>
          <ZipCode>95112</ZipCode>
          <RetailGXGCutOffTime>12:00 AM</RetailGXGCutOffTime>
          <SaturDayCutOffTime>12:00 AM</SaturDayCutOffTime>
        </PostOffice>
        <PostOffice>
          <Name>SENTER VIDEO CPU</Name>
          <Address>2360 SENTER RD</Address>
          <City>SAN JOSE</City>
          <State>CA</State>
          <ZipCode>95112</ZipCode>
          <RetailGXGCutOffTime>5:00 PM</RetailGXGCutOffTime>
          <SaturDayCutOffTime>2:00 PM</SaturDayCutOffTime>
        </PostOffice>
      </GXGLocations>
    </Service>
    <Service ID=

Errors:

(I reformatted it for clarity)

So, the Request was for "United Kingdom", and the Response was "UNITED KINGDOM".

Thoughts? TIA!

Malcolm

Link to comment
Share on other sites

@kymation

*** UPDATE ***

This is a new shop I am developing. I wanted to see if the problem could be caused by any of the add-ons or changes I had already made. So, I installed a clean copy of EDGE (dated 5/11/17), and installed the USPS Rate module. I then entered an order with an UK address. BAM ...

5980dc9e90d33_ScreenCapture-08-01-2017.JPG.ec16cbf05922bdd3f5d3c09d355b0c5c.JPG

Yes, I'm developing the shop on an in-house WAMP box. So, I then wanted to see if somehow the problem was due to my in-house box. I created a temporary directory on one of my hosted shops, installed a clean copy of EDGE, and again installed the USPS Rates module. I ran an order through the shop with an UK address, and It worked! No warnings!

So, I took the shop I have been developing, and moved it up to my host (I already had the domain name registered, and a preliminary site started).

BAM ... the site crashed. All I got was the background color. I was able to log into the admin site, but the store was empty. Debug showed me an "500 internal server error". Geez, that's helpful ... :angry:

So ... I logged into my host, and started examining the error logs. For some reason, one module in the navbar wasn't finding it's template. Everything was there, but it was being fussy. So, I "temporarily" moved the contents of the template file into the navbar module itself, and the shop came back to life! Still puzzled about that one ...:huh:

Anyway, the shop was up. I ran an order through the shop with an UK address, and no warnings! :rolleyes:

So, was this a case of "Why you should develop on your real host, and not on an in-house box" ?

Nope...

While I was looking through the error logs on my host, I noticed many, many instances of the same PHP warning, both for the new site I'm working on, but also for my existing shops that also use the USPS Rates module ..

[01-Aug-2017 12:39:42 America/Los_Angeles] PHP Warning: Invalid argument supplied for foreach() in /XXXXX/XXXXX/XXXX/XXXXX/catalog/includes/modules/shipping/usps.php on line 123 

So, I've been getting these warning all along! But, I'm guessing that I have the warning set off in the live sites, but set on in the ones I am working on here in-house.

Like I said above, the USPS was passing back the proper rates.

So, the module does work, but there is an issue in the code that is generating these warnings. We can hide the warnings, but that doesn't really solve the problem.

Thanks for letting me vent a bit :ph34r:

Malcolm

Link to comment
Share on other sites

@ArtcoInc  The line that you are seeing the error on is Line 124 in my copy. Please check that you are using the latest version of the Addon.

I think the error is probably this one. The posted solution may work, or you may need to add the braces and enclose the whole foreach() statement. Or I could be wrong again.

Regards

Jim

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

Link to comment
Share on other sites

  • 5 weeks later...

Curiosity question - Does anyone know if the Postal Service is changing their APIs and if so will USPS Methods Rates V4 Intl Rates V2 will be updated to interface?

I ask since the USPS service seems to be working ON THEIR SITE which last week it was not when this problem presented itself.  The module apparently can calculate the International rates  BUT Domestic rates are not being returned.

Any input would be appreciated.

BJ

Link to comment
Share on other sites

7 minutes ago, Chadduck said:

Curiosity question - Does anyone know if the Postal Service is changing their APIs and if so will USPS Methods Rates V4 Intl Rates V2 will be updated to interface?

I ask since the USPS service seems to be working ON THEIR SITE which last week it was not when this problem presented itself.  The module apparently can calculate the International rates  BUT Domestic rates are not being returned.

Any input would be appreciated.

BJ

yes, it seems that the did update it to a degree.  All rates are returning for me except of First Class Mail.  I believe they changed the name of the First class parcel from:

First-Class Mail Parcel    

to:

First-Class Package Service - Retail<sup>™</sup>

Anyone that knows how to update this I would love some guidance.

 

Link to comment
Share on other sites

37 minutes ago, Chadduck said:

I am not getting PRIORITY MAIL nor FIRST CLASS

ok, I have solved my issue...just wanted to give you an update:

UPDATE: you must uninstall and re-install after the changes below are made.

I had/have installed the latest version of theUSPS Methods Rates V4 Intl Rates V2 uploaded by a.forever in 2016.

It looks like USPS did update the name of first class parcel mail from there server.

You need to update line 522  with the following:

Change from:

        \'First-Class MailRM Parcel\', 

Replace with:

        \'First-Class Package Service - RetailTM\',

Now all of the rates are returning for me again.

Hope this helps someone.

Evan

Edited by dsolutions
forgot to add that you have to uninstall and re-install addon for change to take effect
Link to comment
Share on other sites

1 hour ago, dsolutions said:

ok, I have solved my issue...just wanted to give you an update:

UPDATE: you must uninstall and re-install after the changes below are made.

I had/have installed the latest version of theUSPS Methods Rates V4 Intl Rates V2 uploaded by a.forever in 2016.

It looks like USPS did update the name of first class parcel mail from there server.

You need to update line 522  with the following:

Change from:

        \'First-Class MailRM Parcel\', 

Replace with:

        \'First-Class Package Service - RetailTM\',

Now all of the rates are returning for me again.

Hope this helps someone.

Evan

THANK YOU MAN!!!!

I almost forgot the UNINSTALL REINSTALL BUT it all seems to be working again!

THANKS AGAIN!!!

 

Link to comment
Share on other sites

The following was received from USPS Web Tools support:

Quote

Web Tools API integrators – Web Tools database maintenance will result in an API outage affecting all secure/HTTPS requests.

 

Timing and duration: 3 hours on September 17, 2017 from 7:00 – 10:00 PM EDT.

 

APIs impacted: Any API accessed through the secure URL (https://secure.shippingapis.com/shippingapi.dll). For example:

- All Label APIs, including: eVS, Domestic Labels, International Labels and Customs Forms, SCAN Form, Hold For Pickup, Open and Distribute

- All Web Tools 2.0 APIs: Commercial Package Intercept, Delivery Instructions/Redelivery Availability, Schedule Redelivery, Forever Prepaid

- Package Pickup APIs (e.g. CarrierPickupSchedule)

- PTS APIs (e.g. PTSGetPackageInfo, PTSEmail)

- Certain non-secure/HTTP APIs are also available via HTTPS and would be impacted if requests made through the secure/HTTPS URL. These include but are not limited to: RateV4, IntlRateV2, TrackV2, Verify, POLocatorV2

This includes the API used by this module.

Regards

Jim

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

Link to comment
Share on other sites

2 hours ago, dsolutions said:

ok, I have solved my issue...just wanted to give you an update:

UPDATE: you must uninstall and re-install after the changes below are made.

I had/have installed the latest version of theUSPS Methods Rates V4 Intl Rates V2 uploaded by a.forever in 2016.

It looks like USPS did update the name of first class parcel mail from there server.

You need to update line 522  with the following:

Change from:

        \'First-Class MailRM Parcel\', 

Replace with:

        \'First-Class Package Service - RetailTM\',

Now all of the rates are returning for me again.

Hope this helps someone.

Evan

OK. I did the change as quoted above and now I am getting First Class quotes again. However, my Retail and Online quotes are coming back about $0.29 higher and are the same. I checked the retail price on USPS Click and Ship and Retail is still the same as it was before this problem; according to their website, prices have not changed. Anyone else receiving different quotes than before this problem of not getting quotes?

Alan

Edited by spiritalan

Production:
osCommerce V. 2.3.4BS
VPS Box

Link to comment
Share on other sites

I checked my PRIORITY mail prices against previously placed orders and there was no diff.

Don't know if that helps you even though we have items that could go first class everyone uses PRIORITY.  

I was also told on Monday while talking to the Post Office staff that there is going to be a price change coming.  BUT they did not know on what or how much.

BJ

ALSO the NEW changes are only for First Class Parcels apparently according to the charts from Pitney Bowes chart 
<link> http://www.pitneybowes.com/content/dam/support/rate-change/en/rates-wall-chart-printable-090317.pdf</link>

 

Edited by Chadduck
Link to comment
Share on other sites

@kymation

I wonder if you might have a solution for a couple of things.

I'm trying to choose the 'second' USPS quote as default if:

1) international

2) under 13 oz.

3) under $400

My code:

        $cheapest = false;
        for ($i=0, $n=sizeof($rates); $i<$n; $i++) {
          if (is_array($cheapest)) {
            if ($rates[$i]['cost'] < $cheapest['cost']) {
              $cheapest = $rates[$i];
            }
          } else {
            $cheapest = $rates[$i];
          }
        }
				if($is_cont48 == 1){
					$cheapest = $rates[0];
				}
				
				if(($is_cont48 != 1) && ($shipping_weight < '.8125')){
					$cheapest = $rates[1];  //Set default USPS method to "2nd" in array.  Add exception for orders with value over $400, or weight over 13oz
				}
				
        return $cheapest;

First I added the $is_cont48 test.  It works.

Then I added the $shipping_weight (which is used elsewhere in the file) but it doesn't work.  Regardless of whether the weight is over or under .8125, the test returns true, and I get $rates[1].  Not sure what I'm doing wrong. 

And what would I use to test cart value?  I see $pkgvalue used in the usps module file, but don't I need to make that a global before the class file can use it in a test?

Link to comment
Share on other sites

This code

$shipping_weight < '.8125'

is doing a text comparison. The result of that is probably not what you want. Try using this instead

$shipping_weight < 0.8125

to make it do the comparison as a float. 

Yes, you need to declare an external value as a global to use it inside the class.

Regards

Jim

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

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...