Coming soon: Blockly Checkout Customizer — validation rules, upsells & checkout analytics.Get early access
Tutorial

How to Block PO Box Addresses at Shopify Checkout

Some carriers can't deliver to PO boxes, and some products shouldn't ship there. Here's how to block PO box addresses at Shopify checkout reliably, with clear messages and fewer edge-case failures.

How to Block PO Box Addresses at Shopify Checkout

A customer places an order, you print the label, and the carrier rejects it: the shipping address is a PO box. Now you're emailing the customer for a new address, the order is delayed, and if the package was already handed over, it may come back to you with a return fee attached.

If your carrier or your products can't go to PO boxes, the cheapest place to fix the problem is checkout, before the order exists. This tutorial shows how to block PO box addresses at Shopify checkout, why the common workarounds fall short, and how to write rules that catch the variants customers actually type.

Why blocking PO boxes matters

Many postal services deliver to PO boxes without issue, but you likely need a block if any of these apply:

  • You ship with a courier that only delivers to physical street addresses
  • You sell large, heavy, or oversized items that won't fit in a box
  • Your products require a signature or age verification on delivery
  • You ship hazardous or restricted goods with carrier restrictions
  • You offer same-day or local delivery by your own drivers

Catching a PO box at checkout means the customer corrects the address while they're still engaged, instead of days later.

Your options on Shopify

Native Shopify settings

Shopify doesn't have a built-in "no PO boxes" toggle. Shipping zones are based on countries and regions, not address types, so you can't exclude PO boxes with shipping settings alone.

Theme notes and cart scripts

The most common workaround is a note on the cart page or product page: "We cannot ship to PO boxes." It helps, but customers skim. Some stores add JavaScript to the cart to warn customers, but the address isn't entered until checkout, so a cart script has nothing to check. And express checkout buttons skip the cart entirely.

Shopify Functions validation

The reliable approach is a Cart and Checkout Validation function. It runs on Shopify's servers inside checkout, reads the shipping address the customer entered, and blocks progress with an error message if the address matches a PO box pattern. Because it runs server-side, it applies no matter how the customer reached checkout, including Shop Pay and other accelerated paths.

Public apps that use validation functions work on all Shopify plans. If you want to build a custom app yourself, custom apps using Functions generally require Shopify Plus. For background, see our checkout validation rules guide.

Step-by-step setup

  1. Decide the scope. Should the block apply to every order, or only to certain products, shipping methods, or countries?
  2. List the address fields to check. Usually address line 1 and address line 2, since customers put the box number in either one.
  3. Define the patterns to match (see the next section).
  4. Write the error message the customer will see.
  5. Decide where the error appears. Attaching it to the address field helps customers see exactly what to change.
  6. Test with real examples, including false positives you want to allow.
  7. Turn it on and watch support tickets and checkout drop-off for a week or two.

Matching the variants customers type

The hardest part of blocking PO boxes isn't the blocking, it's the matching. Customers type PO boxes in many different ways. A rule that only checks for "PO Box" will miss most of them.

Before matching, normalize the text: convert to lowercase, remove periods, and collapse extra spaces. That turns "P.O. Box", "p.o.box", and "PO BOX" into the same thing.

Then match against a list of common variants:

Customer typesAfter normalizingShould match?
P.O. Box 123po box 123Yes
PO BOX 123po box 123Yes
POB 123pob 123Yes
Post Office Box 123post office box 123Yes
P O Box 123p o box 123Yes
Box 123box 123Usually yes
PMB 456pmb 456Depends on carrier
123 Boxwood Lane123 boxwood laneNo
45 Pobrook Road45 pobrook roadNo

Notice the last two rows. A naive "contains box" or "contains pob" check will block legitimate street names. Match whole words or patterns that end in a number, rather than any substring.

A reasonable pattern for most stores looks like this:

(^|\s)(p\s?o\s?box|pob|post\s?office\s?box|box)\s?#?\s?\d+

Test any pattern against your real order history before turning it on. Your customer base may have street names or building names that trip it.

APO, FPO, and DPO addresses

Military addresses (APO, FPO, DPO) are a related but separate decision. They're delivered through the postal system, so couriers that can't reach PO boxes usually can't reach them either. But blocking them also turns away service members, which many brands want to avoid.

Options:

  • Block them along with PO boxes if your carrier truly can't deliver
  • Allow them, but use a delivery customization to show only postal service shipping options
  • Allow them only for certain products

Whichever you choose, make it a deliberate rule, not an accidental side effect of your PO box pattern.

Rule examples

Here are concrete rules with messages that tell the customer how to fix the problem.

  • Block all PO boxes. Condition: shipping address line 1 or line 2 matches the PO box pattern. Message: "We can't deliver to PO boxes. Please enter a street address."
  • Block PO boxes for oversized items only. Condition: cart contains a product tagged oversized AND address matches the pattern. Message: "Your cart includes items that need a street address for delivery. Please update your shipping address."
  • Block PO boxes for one country. Condition: shipping country is US AND address matches. Message: "PO boxes aren't supported for US orders. Please use a physical address."
  • Block PO boxes for a delivery method. Condition: selected delivery method is express courier AND address matches. Message: "Express delivery requires a street address. Choose standard shipping or enter a street address."

If you'd rather steer than block, consider hiding courier delivery options for PO box addresses instead, so only postal options remain. Our guide to hiding shipping methods with Shopify Functions covers that pattern.

Pitfalls and edge cases

False positives on street names. As shown above, "Boxwood" and "Pobrook" are real. Always match whole tokens followed by a number.

International formats. Other countries use different terms, such as "Postfach" in Germany, "Case postale" in Switzerland, or "Apartado" in Spain. If you ship internationally, either add the local terms for your main markets or scope the rule to the countries you understand.

Private mailboxes. PMB and suite numbers at mailbox stores are sometimes deliverable by couriers because the store has a street address. Check with your carrier before blocking them.

Billing vs shipping. Only check the shipping address. A PO box billing address is normal and shouldn't block anything.

Vague messages. "Invalid address" sends customers to support. Tell them it's the PO box and what to enter instead. More on that in our post about checkout error message UX.

Doing it with Blockly Checkout Customizer

Blockly Checkout Customizer, launching soon on the Shopify App Store, handles this as a no-code validation rule. You choose an address condition such as "shipping address contains PO box", optionally combine it with product, country, or delivery method conditions, write your error message, and save. The rule runs as a Shopify Function, so it applies to express checkouts and direct checkout links as well as the normal flow.

The takeaway

Blocking PO boxes is a small rule with an outsized payoff: fewer rejected labels, fewer address-correction emails, and fewer returned packages. Do it at checkout with server-side validation, normalize the address before matching, test against real street names to avoid false positives, decide deliberately about APO/FPO and international formats, and write a message that tells the customer exactly what to fix.

Up nextRestrict Shopify Checkout by ZIP or Postal Code

Related articles

More tutorial articles →
Free forever plan

Ready to protect
your store?

Join 5,000+ Shopify merchants. Install in 30 seconds and block your first bad actor today.

  • No credit card
  • 5-minute setup
  • Cancel anytime