Page 1 of 1
Restrict PO Box
Posted: Fri Apr 22, 2011 8:24 am
by phaques
Does anybody have any insight into a method of restricting customers from entering a PO Box into the shipping address?
Re: Restrict PO Box
Posted: Fri Apr 22, 2011 4:22 pm
by grgr
On the guest checkout:
edit: ...\catalog\controller\checkout\guest_step_1.php
Line 480'ish add
Code: Select all
$filestring = $this->request->post['address_1'];
$findme = 'po box';
if (strlen(stristr($filestring,$findme))>0) {
$this->error['address_1'] = $this->language->get('error_address_1_pobox');
}
Edit: ...\catalog\language\english\checkout\guest_step_1.php
Add:
Code: Select all
$_['error_address_1_pobox'] = 'We can\'t ship to PO Boxes!';
You'll need to repeat this anywhere the address is entered.
Not entirely tested but should be ok.
Re: Restrict PO Box
Posted: Sat Apr 23, 2011 8:41 am
by phaques
That's fairly functional. One caveat, this also restricts those that have a PO Box for their payment address but not their shipping.
Also is there a way to add other spellings to the '$findme' string? Such as 'p.o. box' or 'p o box', etc.?
Thanks for the start!
Re: Restrict PO Box
Posted: Sat Apr 23, 2011 3:46 pm
by grgr
Try:
Code: Select all
$filestring = $this->request->post['address_1'];
$keywords = array("po box","pobox","p.o. box");
foreach ( $keywords as $keyword ) {
if ( stripos( $filestring, $keyword ) !== FALSE ) {
$this->error['address_1'] = $this->language->get('error_address_1_pobox');
}
}
The only way I can think of sorting the other problem is by forcing seperate billing and shipping addresses.
Re: Restrict PO Box
Posted: Sat Apr 23, 2011 8:09 pm
by mberlant
There are so many variations possible in what a customer might put into the address field that it is not practical to test for all of them. You may test for "po box", but should you also test for "post office box", "p o box", "box", etc.? If you do, what do you do for a customer who lives in a house on Box Road?
About the only thing you can do is to to post prominently in your Terms and Conditions that you cannot ship to post office boxes, and that orders will be significantly delayed and will be subject to a surcharge for correcting the error if a customer inputs such a shipping address. Make acceptance of the terms a requirement of the checkout page.
It's not much of a help, but here is a link to
Amazon's policy page to help you get an idea of how the "big boys" handle the problem.
Re: Restrict PO Box
Posted: Sat Apr 23, 2011 11:34 pm
by phaques
Thank you both!
I have already put that information into the Terms and also modified the template page to display a notice too. Just trying to make it as prominent as possible since people don't tend to read anything!
Re: Restrict PO Box
Posted: Sun Apr 24, 2011 8:14 pm
by mberlant
phaques wrote:... Just trying to make it as prominent as possible since people don't tend to read anything!
Indeed, that's true. If you make something more idiot-proof you will only attract a stronger breed of idiot.
Re: Restrict PO Box
Posted: Sun Apr 24, 2011 10:19 pm
by phaques
Yes, survival of the dumbest.
Re: Restrict PO Box
Posted: Mon Jul 18, 2011 1:39 pm
by phaques
Can anybody update this for v1.5?
I tried adding this to guest.php and the english file as done with the previous version, but I don't get the errors like I should. The cart just advances on.
Thanks in advance!