Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Stop shoppers from shipping to a PO Box


orion7_11

Recommended Posts

Posted

Is there a way to stop users from selecting a PO Box as their ship to address? I have put up comments that it can't be shipped to a PO box etc but I still have customers go through the whole process and end up with a PO box as a ship to address.

 

I use UPS to ship with and UPS doesn't deliver to Post Offices. Is there some code I could modify that could scan address line 1 and 2 for PO Box, or Post office box or something like that and then either pop up an error message or reject it somehow when it's selected as the ship to address?

 

Any help would be appreciated.

Posted

Try this:

On Page: catalog\checkout_shipping.php about Line 37

 

You will see -

if ($check_address['total'] != '1') {

$sendto = $customer_default_address_id;

if (tep_session_is_registered('shipping')) tep_session_unregister('shipping');

}

}

}

 

 

Insert this under it:

// BOF: PhotoFXPlus.com Added: ************************************************************************

$str_search = array(

' PO ',

'P.O.',

'Post Office Box',

'P.O.Box'

);

 

$address_query = tep_db_query("select entry_street_address from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customers_id . "' and address_book_id = '" . (int)$sendto . "'");

$address = tep_db_fetch_array($address_query);

while (list(,$value) = each($str_search)) {

if (strpos($address['entry_street_address'], $value)) {

$messageStack->add_session('You cannot ship to a PO Box', 'error');

tep_redirect(tep_href_link(FILENAME_DEFAULT));

}

}

// EOF: PhotoFXPlus.com Added: ************************************************************************

 

You can change the serach characters in the array, be sure and leave the quotes ''.

You can also change the message in the error message:

$messageStack->add_session('You cannot ship to a PO Box', 'error');

 

and the file to redirect to..

 

I did not try it - but it should be close to what you are asking..

Lloyd

Archived

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

×
×
  • Create New...