Drupal 7 English and Chinese

English can get request rate.
Chinese error "Ship Date is invalid. Use format dd-mmm-yyyy"

change uc_usps.module
line:463
'' . format_date(time(), 'custom', 'd-M-Y', 'America/New_York') . '';
to
'' . format_date(time(), 'custom', 'd-m-Y', 'America/New_York') . '';
it works both English and Chinese.
but don't know why. anyone could tell me why and should I change it on uc_usps.module.

CommentFileSizeAuthor
#2 usps_error.jpg46.51 KBgeduozhao
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

TR’s picture

Status: Active » Postponed (maintainer needs more info)

Please turn on the shipping quotes debug information at admin/store/settings/quotes/settings, try to get a quote, and post here the part of the XML sent to USPS that contains the <ShipDate> tag. Do this before and after you make the above change, so we can see what is being sent to USPS by your server.

geduozhao’s picture

FileSize
46.51 KB

Thank you for your help, TR.

=====================================================
with
('' . format_date(time(), 'custom', 'd-m-Y', 'America/New_York') . '';)

<ShipDate Option="EMSH">23-02-2013</ShipDate>

=====================================================

with
('' . format_date(time(), 'custom', 'd-M-Y', 'America/New_York') . '';)

    Ship Date is invalid. Use format dd-mmm-yyyy.

<Revision>2</Revision><Package ID="0"><Service>ALL</Service><ZipOrigination>10002</ZipOrigination><ZipDestination>10002</ZipDestination><Pounds>1</Pounds><Ounces>0.0</Ounces><Container>VARIABLE</Container><Size>REGULAR</Size><Value>8</Value><Machinable>FALSE</Machinable><ReturnLocations>TRUE</ReturnLocations><ShipDate Option="EMSH">23-2 �-2013</ShipDate></Package>

<?xml version="1.0"?>
<RateV4Response><Package ID="0"><Error><Number>-2147219422</Number><Source>DomesticRatesV4;clsRateV4.ValidateShipDate;RateEngineV4.ProcessRequest</Source><Description>Ship Date is invalid.  Use format dd-mmm-yyyy.</Description><HelpFile></HelpFile><HelpContext>1000440</HelpContext></Error></Package></RateV4Response>

I don't want to hack the uc_usps.module to make it works.Thanks Tim

TR’s picture

When you post in this forum you have to put markup between <code></code> tags so it's readable.

d-M-Y means to print out the three letter month abbreviation where the M is.
d-m-Y means to print out the two digit month number where the m is.
The USPS documentation says that the three letter month abbreviation, in English, must be used.

It looks like when you use M, you're getting garbage. I suspect that has something to do with how your PHP is configured on your server - maybe your PHP language settings are causing that. You can write a tiny PHP script and run it from the command line to see what that format_date() function prints out on your server.

geduozhao’s picture

Thanks Tim. Let me try.:)

geduozhao’s picture

Just disabled translate d-M-Y to Chinese. It works without hack uc_usps.module.

Thank you so much. Tim.:)

geduozhao’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

Fixed

TR’s picture

Status: Closed (fixed) » Fixed
longwave’s picture

Category: support » bug
Status: Fixed » Active

This is a bug. format_date() is a Drupal function that by default formats the month name to the current locale (in this case, Chinese) but USPS always expects the month name in English.

longwave’s picture

Status: Active » Fixed

Tested on a site with English and French installed, the same error occurs when using French at checkout. Fixed in http://drupalcode.org/project/ubercart.git/commitdiff/fef42ba

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.