Zen Cart Logo
Forums / Addon Shipping Modules / PO Box Ban [support thread]

PO Box Ban [support thread]

Views: 40,351

Results 21 to 35 of 35
18 Oct 2009, 6:30 PM
#21
dw08gm avatar

dw08gm

Totally Zenned

Join Date:
Sep 2008
Location:
DownUnder, overlooking South Pole.
Posts:
1,016
Plugin Contributions:
2

PO Box Ban [support thread]

Hi Steven300

Thanks for a great mod.

Could you please explain the use of "/", "" and "si" in your code, so that others might add their own additions without bothering you.

I am thinking of adding the following

GPO Box (is this already covered by your code?)
Private Box
Private Bag
Locked Bag

Best Regards

18 Oct 2009, 7:40 PM
#22
steven300 avatar

steven300

Totally Zenned

Join Date:
Jan 2008
Posts:
1,564
Plugin Contributions:
1

Re: PO Box Ban [support thread]

Sure.

Well this is the most basic example of preg_match:

if (preg_match("/choice/", "PHP is the web scripting language of choice.")) {
    echo "A match was found.";
} else {
    echo "A match was not found.";
}

As you can see, the forward slash "/" indicates the start and end of the pattern.

An "i" afterwards makes it case-insensitive.

I can't remember exactly what the "s" means. It's something to do with matching a pattern when there's a new line.

The period (dot) symbol is normally a wildcard (meaning it can stand for any single character). So if you actually want to match a period symbol itself, you need to escape it with a backslash "" before it.

Yes, "GPO Box" is already covered by the mod. The others will need adding.

Further reference:
http://php.net/manual/en/function.preg-match.php

28 Oct 2009, 10:38 PM
#23
stumpy74 avatar

stumpy74

New Zenner

Join Date:
Oct 2009
Posts:
26
Plugin Contributions:
0

Re: PO Box Ban [support thread]

Also my web provider (Quadrahosting) says for their unix accounts there is not mods required for uCRL proxies.....

28 Oct 2009, 10:58 PM
#24
steven300 avatar

steven300

Totally Zenned

Join Date:
Jan 2008
Posts:
1,564
Plugin Contributions:
1

Re: PO Box Ban [support thread]

What does cURL have to do with the PO Box Ban mod?

Are you in the right thread?

4 Feb 2018, 4:43 AM
#25
dw08gm avatar

dw08gm

Totally Zenned

Join Date:
Sep 2008
Location:
DownUnder, overlooking South Pole.
Posts:
1,016
Plugin Contributions:
2

Re: PO Box Ban [support thread]

The following post by JayWilliams dated 6 December 2013 was imported from the now closed thread Re: PO Box Ban 1.4 [support thread].

https://www.zen-cart.com/showthread.php?193601-PO-Box-Ban-1-4-support-thread

I cannot vouch for the post, but thought it worth preserving since the other thread has been closed.

Apologies for any transgressions of forum rules.

Cheers

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:
PHP Code:
// 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:
PHP Code:
// 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 Feb 2019, 7:04 PM
#26
patrick_vincent avatar

patrick_vincent

New Zenner

Join Date:
Jun 2015
Location:
New England
Posts:
29
Plugin Contributions:
0

Re: PO Box Ban [support thread]

Howdy, I installed the 1.5a version of the mod on ZC 1.5.5b a couple of weeks ago. I copied the four files to the server and didn't modify code.

Got an order today to a PO box in Canada from an existing customer. Customer had been registered since 2015. Am I correct in assuming this shouldn't happen or are there still use cases where it might slip through?

4 Mar 2019, 6:47 PM
#27
patrick_vincent avatar

patrick_vincent

New Zenner

Join Date:
Jun 2015
Location:
New England
Posts:
29
Plugin Contributions:
0

Re: PO Box Ban [support thread]

By 'didn't modify code' I meant other than replacing files the directions stated I should.

Any ideas why I received an order from an existing customer with a shipping and billing address as a PO box?

5 Mar 2019, 9:42 AM
#28
dw08gm avatar

dw08gm

Totally Zenned

Join Date:
Sep 2008
Location:
DownUnder, overlooking South Pole.
Posts:
1,016
Plugin Contributions:
2

Re: PO Box Ban [support thread]

Patrick Vincent:

By 'didn't modify code' I meant other than replacing files the directions stated I should.

Any ideas why I received an order from an existing customer with a shipping and billing address as a PO box?

Apologies for not responding earlier, but I have only just had a useless piece of my anatomy removed.

While the trick to this mod is to add as many variant terms as possible to the list of possible post office addresses to defeat, it could be that some new php or regular expression function code has impacted part or all of this mod.

However I have not looked at this mod or done any zen-cart upgrading or any coding for several years now for me to know whether any more recent code may have affected this mod.

Nevertheless can you tell me what was the exact address line used? (please cut and paste here if possible)

Also what Db character set are you using (eg utf8_general_ci may be faster than utf8_unicode_ci, but is often less correct)?

cheers

6 Mar 2019, 7:14 PM
#29
patrick_vincent avatar

patrick_vincent

New Zenner

Join Date:
Jun 2015
Location:
New England
Posts:
29
Plugin Contributions:
0

Re: PO Box Ban [support thread]

First - sorry to hear about the surgery, and no worries on the delay. Hope you heal up well.

Address, specific with case sensitivity for the order that went through was "Po box 9140".

DB... all tables show utf8_general_ci for collation.

Thanks for the attention. Much appreciated.

6 Mar 2019, 7:17 PM
#30
patrick_vincent avatar

patrick_vincent

New Zenner

Join Date:
Jun 2015
Location:
New England
Posts:
29
Plugin Contributions:
0

Re: PO Box Ban [support thread]

Copied and pasted from order confirmation email: Po box 9140

8 Mar 2019, 5:14 AM
#31
dw08gm avatar

dw08gm

Totally Zenned

Join Date:
Sep 2008
Location:
DownUnder, overlooking South Pole.
Posts:
1,016
Plugin Contributions:
2

Re: PO Box Ban [support thread]

mmm! "Po box" should have been recognised and rejected.

I was hoping you would have copied the address from either or both of the Orders or Customers tables (as originally input) for comparison, as text could be changed for the order confirmation email.

While you seem to know what you are doing (utf8_general_ci => case insensitive), and I presume you have done a search and found an entry for "Po box" in the php files for this mod, I am somewhat at a loss to explain or help resolve this issue.

Best Regards

18 Aug 2019, 3:53 PM
#32
tmccaff avatar

tmccaff

Zen Follower

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

Re: PO Box Ban [support thread]

I uploaded a new version just waiting on approval.

Here is github repo:

https://github.com/tmccaff/Zencart-Po-Box-Ban

21 Sep 2023, 2:33 AM
#33
nicksab avatar

nicksab

Totally Zenned

Join Date:
Apr 2011
Posts:
592
Plugin Contributions:
0

Re: PO Box Ban [support thread]

tmccaff:

I uploaded a new version just waiting on approval.

Here is github repo:

https://github.com/tmccaff/Zencart-Po-Box-Ban

I know it is an old threads but does it works with ZC1.5.7 and OPC?

Thank you

21 Sep 2023, 2:57 AM
#34
dw08gm avatar

dw08gm

Totally Zenned

Join Date:
Sep 2008
Location:
DownUnder, overlooking South Pole.
Posts:
1,016
Plugin Contributions:
2

Re: PO Box Ban [support thread]

What is OPC?

You could test it and report your results back here.

Cheers

21 Sep 2023, 4:47 AM
#35
nicksab avatar

nicksab

Totally Zenned

Join Date:
Apr 2011
Posts:
592
Plugin Contributions:
0

Re: PO Box Ban [support thread]

dw08gm:

What is OPC?

You could test it and report your results back here.

Cheers

by OPC, I meant One-Page Checkout.