Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

No PO Boxes Permitted


only2empires

Recommended Posts

Hello! Is there a way to change codes so that when someone puts in a PO Box as a street address it rejects and makes them put in a physical address? I am only shipping via UPS & FedEx which requires a physical address. I have it stated in signup "Required - PO Boxes not permitted" but customers still seem to ignore that and order anyway. Then I have to fight tooth and nail to get a physical address or cancel their order.

 

Thanks!

Link to comment
Share on other sites

There is no default way to do it, but it wouldn't take a look of code to make it work. You could use any one of a number of php string searching functions to pattern count for PO BOX or P.O. Box or Box etc when the form was sent for processing. if the form element contained an illegal string like PO BOX, you could redirect back to the form page and throw up an error. The function stristr should do it...

 

$address = "I am a submitted address";

$srchstrng = "PO BOX";

if (stristr($address, $srchstrng) !== FALSE)

?? {

?? echo "No Po Boxes Please!";? ?

?? }

 

Yes?

Link to comment
Share on other sites

icx's code will function, but only if the customer types in his address as PO BOX 12345 in all upper case without periods. Here's my code to work around that:

$test = strtolower(str_replace(".","", $street_address));//define $test as $street_address without periods and in all lower case ("P.O. Box" becomes po box)
 if (substr_count($test, "po") == 0 && substr_count($test, "box") == 0)//does $test contain "po" and "box"?
   {

 

There are many different ways to say "PO Box." You could have:

P.O. Box

PO Box

po box

p.o.box

P.O. box

 

 

strtolower() will take a string of upper case or mixed case and make it all lower case. Thus "sTrInG" becomes "string" and more importantly, "PO Box" becomes "po box".

 

str_replace() replaces one character with another. In this case, all periods (.) are replaced with nothing, in effect removing them.

 

Combining these two functions makes every one of the above examples into "po box."

 

substr_count() returns the number of times one string occurs within another. The code above counts how many times "po" and "box" occur in the address.

 

If either of those is not zero, you could display the message about "No PO Boxes." The downfall of this code is a customer who lives on a street that happens to have "po" and "box" as part of the name...but I haven't had anyone from PoBox Street register at my store.

Link to comment
Share on other sites

Hi,

 

Ive noticed that ups/fedex wont give back rates for zipcodes that belong to PO boxes, mainly postoffice vs mailbox... So maybe it should be zipcode rejection plus string parsing in the shipping modules that gives you a PO box warning and tells you to check the address.

 

Dave...

 

Bin 123

PosOfic 123

Suite 123

Link to comment
Share on other sites

Chris is absolutely correct. That particular pattern matcher is strict. Ideally, you would convert to lower case as suggested and then use an array to match against all possible variations.

Link to comment
Share on other sites

hi, sorry, just bump in here.....which php page do i put the code in??? should i put this one

$address = "I am a submitted address";

$srchstrng = "PO BOX";

if (stristr($address, $srchstrng) !== FALSE)

  {

  echo "No Po Boxes Please!";   

  }

 

or this one

$test = strtolower(str_replace(".","", $street_address));//define $test as $street_address without periods and in all lower case ("P.O. Box" becomes po box)

if (substr_count($test, "po") == 0 && substr_count($test, "box") == 0)//does $test contain "po" and "box"?

  {

 

 

Thx! :D

OS-commerce is great, but with other magical contributions, that is just so "COOL"!

Link to comment
Share on other sites

  • 2 months later...

$test = strtolower(str_replace(".","", $street_address));//define $test as $street_address without periods and in all lower case ("P.O. Box" becomes po box)

if (substr_count($test, "po") == 0 && substr_count($test, "box") == 0)//does $test contain "po" and "box"?

{

 

Just wondering what code would you replace then add? also it seems like this statement is incomplete?

Link to comment
Share on other sites

Sorry, just now got notifications that there were answers to my post. Ok, so it can work, but like said.....where should this code be added? I have another site that isn't online yet that I can test it on before I go and add to my existing store.

 

Thanks for your help! Its appreciated!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...