Enhance the Checkout Process for PO Box Addresses!

We often get to hear customers complaining about issues with shipment deliveries when they are not available at their physical addresses. For example, someone who spends summers in Florida and winters in Scottsdale may be getting tired of having to forward their shipments from one location to another. In addition, deliveries to inaccurate addresses might add to the trouble. Sometimes people run home-based businesses and want to separate business and personal mails. And then there are others who just wish to keep their home address private… Choosing PO Boxes appears to be a natural solution for all these cases.

A PO Box or Post Office Box is a lockable box located in a post office which customers can rent out. In the United States, PO Boxes are generally available through the United States Postal Service (USPS). Other major shipping carriers such as UPS, FedEx, DHL etc. have alternate solutions to this, but none able to directly deliver to a PO Box.

This might pose a problem when you run an online store and want to display multiple shipping options from varied carriers to your customers. If customers are choosing incorrect shipping methods, it’ll create trouble for store owners, and acts as a major hindrance to the overall shipping workflow.

For example, John is using both FedEx and USPS for his shipping needs. However, he faces a problem where his customers are continuously choosing FedEx Ground for PO Box addresses. This request cannot be fulfilled as FedEx, by law, cannot hand deliver the shipment to a US post office themselves. However, FedEx SmartPost reaches almost all U.S. addresses, including P.O. boxes and military APO, FPO and DPO destinations by utilizing the U.S. Postal Service (USPS) for final delivery. Similarly, DHL website says, “Although DHL Express cannot deliver to PO, APO, or FPO box address you may request the shipment to be held for pickup. The receiver will then be able to pickup the shipment at the local DHL Express station.” UPS too has an option where your mail and packages can be delivered to a personalized mailbox at The UPS Store.

So, among the varied list of shipping carriers, USPS is the only one permitted to use PO Boxes (rather the only one that uses PO Boxes to its fullest potential).

Since John is facing this problem continuously, he actively seeks out for a solution. He checks whether WooCommerce forums have any tweaks for this. But he couldn’t find a solution to allow PO Boxes with WooCommerce.

XAdapter Solution!
Out of frustration, John decides to tackle the problem differently. Since USPS is the standard for handling PO Boxes, the solution is to limit the services of other carriers and only show USPS rates in checkout (when PO Box is entered in ‘address line 1’ instead of a street address).

XAdapter helped John by developing a code snippet for this:
Go to Appearance –> Editor –> Theme Functions (functions.php) and insert the snippet to enable this functionality.

The above snippet shows only the USPS rates when a customer enters the string “pobox” in the checkout page as shown below :

John’ cart for a physical address: Note both FedEx and USPS services are displayed.

John’ cart for a PO Box address: Only USPS service is displayed.

So now, you can easily streamline your shipping based on PO Boxes and forget all about customers choosing incorrect shipping service for PO box addresses. Now make your checkout process as smooth as ever!

Comments (8)

  • Lorenzo

    Hi nicolab,

    Are you getting a http 500 issue as well. could you raise a support ticket so that I can have a look.


    February 9, 2018 at 10:09 am
    • nicolab

      Not that I know of. All I know is that when I add the code in this post to the function file it only works for “pobox” and not any other combination. When it works, fedex is removed as a shipping option, but if I enter “p o box” or “p.o. box” it doesn’t remove fedex as a shipping option.

      February 9, 2018 at 7:37 pm
    • nicolab

      If I change line 9 to the suggestion below from Kevin, I get this error:

      Your PHP code changes were rolled back due to an error on line 804 of file wp-content/themes/mediclinic/functions.php. Please fix and try saving again.

      syntax error, unexpected ‘strstr’ (T_STRING)

      February 9, 2018 at 7:46 pm
  • Kevin

    This was a question, not a request.

    Also this code does not work and returns SERVER ERROR 500:

    Hello, we are using both the UPS and USPS Woocommerce plugins.

    We want to show only USPS prices for PO Boxes.

    When we try to use the example code on this page:

    PHP Fatal error: Can’t use method return value in write context in /var/www/vhosts/elrhq.com/dev.elrhq.com/wp-content/themes/xstore-child/functions.php on line 22

    January 9, 2018 at 11:39 pm
    • Kevin

      For others having this PHP error, upgrading to PHP 5.6 fixed it for me.

      January 9, 2018 at 11:54 pm
  • Kevin

    Please adapt this code to include ALL variations! NOBODY actually types in “pobox”! They type in “po box” or “p.o. box” or “P.O. Box” or “PO Box” or “P.o. box” or “po. box” or “Po Box.”.

    Will it work to just change line 9 to:
    if ( strstr( $address, ‘pobox’ ) || strstr( $postcode, ‘pobox’ )
    strstr( $address, ‘po box’ ) || strstr( $postcode, ‘po box’ )
    strstr( $address, ‘p.o. box’ ) || strstr( $postcode, ‘p.o. box’ )
    strstr( $address, ‘P.O. Box’ ) || strstr( $postcode, ‘P.O. Box’ )
    strstr( $address, ‘PO Box’ ) || strstr( $postcode, ‘PO Box’ )
    strstr( $address, ‘P.o. box’ ) || strstr( $postcode, ‘P.o. box’ )
    strstr( $address, ‘po. box’ ) || strstr( $postcode, ‘po. box’ )
    strstr( $address, ‘Po Box.’ ) || strstr( $postcode, ‘Po Box.’ )
    ) {

    Surely there is a more effecient way to check for this?

    December 19, 2017 at 9:52 pm
    • Ipshita

      Hi Kevin,

      Thanks a lot for the suggestion.
      We shall definitely consider it for future enhancement. But currently, we won’t be able to provide any timeline for this.


      December 20, 2017 at 7:46 pm
    • nicolab

      Did you get this to work? I’m having the same issue.

      February 8, 2018 at 9:09 pm

Leave a Reply