Thanks for this post! It really should be a lot simpler to things like this in Magento.
In my case, I also added a pattern check against a 2nd line of street address:
if( preg_match("/p\.* *o\.* *box/i", $this->getStreet(1)) || preg_match("/p\.* *o\.* *box/i", $this->getStreet(2)) ) { $errors[] = $helper->__('We cannot ship to PO boxes.'); }
<code>
<blockcode>
<apache>
<bash>
<c>
<cpp>
<drupal5>
<drupal6>
<java>
<javascript>
<perl>
<php>
<python>
<ruby>
<xml>
<foo>
[foo]
More information about formatting options
Thanks for this post! It really should be a lot simpler to things like this in Magento.
In my case, I also added a pattern check against a 2nd line of street address:
if( preg_match("/p\.* *o\.* *box/i", $this->getStreet(1))
|| preg_match("/p\.* *o\.* *box/i", $this->getStreet(2)) )
{
$errors[] = $helper->__('We cannot ship to PO boxes.');
}