Zen Cart Logo
Forums / All Other Contributions/Addons / PO Box Ban 1.4 [support thread]

PO Box Ban 1.4 [support thread]

Locked

Views: 2,822

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
10 Mar 2012, 8:05 PM
#1
mvstudio avatar

mvstudio

Zen Follower

Join Date:
Apr 2008
Posts:
447
Plugin Contributions:
1

PO Box Ban 1.4 [support thread]

This is the support thread for the PO Box Ban 1.4

We've made some much needed changes to the PO Box Ban 1.3 mod, and I've packed the module hoping it would be useful to someone else.

Basically the problem was clients couldn't add a PO box to their billing address because the mod would launch an error message, so we started having complaints. The module was supposed to block the PO boxes from being added to shipping, not billing, but that wasn't working, so we made it work the way it should. Now customers can add PO boxes as their billing address, while the system will launch an error if a PO box is added as a shipping address.

Another problem we were facing, because our store was already active when we installed this module, was that customers with existing PO box addresses in the database were able to checkout without the system launching any error. We were able to fix that issue and added an extra piece of code (thanks to a piece of code by DrByte) to the shipping module (ours is USPS but same code applies to any other module), so when a customer tries to checkout with a previously entered PO box address as a shipping address it will launch an error message, preventing checkout until a new address is entered.

I've already uploaded the addon, so it's a matter of time until it's approved. This module is supper simple to install. Only 2 new files and modification to 4 files.

Hope someone else can find it useful! :smile:

5 Dec 2013, 5:09 PM
#3
jaywilliams avatar

jaywilliams

New Zenner

Join Date:
Aug 2009
Posts:
6
Plugin Contributions:
0

Re: PO Box Ban 1.4 [support thread]

Thank you for updating this mod, however I do have a few improvements I'd like to pass along for inclusion in possible future versions.

First, rather than running multiple preg_match() calls, you can combine all of them into one regular expression, this provides a performance boost, as well as less duplicate code. Second, I've extended the regular expression to avoid false positives (e.g. Boxer Dr, Polk St, Box Cir, etc.).

Here is the primary snippet, which you can modify the message stack name for each instance:

// BEGIN PO Box Ban 1/1
if (preg_match('/(?:^|\W)(?:(?:P\.?O\.?\s*)?BOX|P\.?O\.?)\s*\d+/i', $street_address)) {
    $error = true;
    $messageStack->add('addressbook', PO_BOX_ERROR);
}
// END PO Box Ban 1/1

Here is the shipping module snippet:

// BEGIN PO Box Ban 1/1
if (preg_match('/(?:^|\W)(?:(?:P\.?O\.?\s*)?BOX|P\.?O\.?)\s*\d+/i', $order->delivery['street_address'])) {
    $this->quotes = array(
        'module' => $this->title,
        'error'  => '<span class="alert messageStackError">Sorry, we do not ship to PO Boxes. Please change your shipping address.</span>');
    return $this->quotes;
}
// END PO Box Ban 1/1

This regular expression is case-insensitive, and will match cases such as:

  • P.O. Box 123
  • POBOX 123
  • PO 123
  • BOX 123
  • BOX123
  • POBOX123
  • Etc.

Hopefully this will help others trying to block PO Box addresses.

25 Jan 2018, 6:24 PM
#4
tmccaff avatar

tmccaff

Zen Follower

Join Date:
Jan 2018
Posts:
157
Plugin Contributions:
0

Re: PO Box Ban 1.4 [support thread]

Updated for 1.5.5f what I was told is that you don't need to add this code to your shipping module. I will upload it shortly.