Remember with any implmenetation to check for different spelling of PO box , P.O. box , pobox, po box, P.0. ; last one is missing “box” etc etc ad nausem.
Pre-checkout
To try and catch invalid addresses before checkout, you want to build a shipping address form in the /cart ; typically under the guise of a shipping cost calculator this would let you inform potential customers of incompatible addresses BEFORE they go to checkout.
In checkout
To enforce address rules in the checkout itself you either need an app using the carrier service api, build your own, or be on shopify Plus and modify the checkout.
To roll your own PO box rejection use the delivery-customization shopify-function feature.
https://shopify.dev/docs/api/functions/reference/delivery-customization#:~:text=Hide%20delivery%20options%20for%20PO%20Box%20addresses
different approaches may be available in future shopify-functions [1].
Post checkout
To catch these AFTER the order is placed.
Should be able to catch most in a shopify flow automation, or maybe even utilizing shopfys free fraud filter app to try and catch PO boxes before accepting payment or sending off to fulfillment, etc.
Remember to check for different spelling of PO box , P.O. box , pobox, po box, P.0. ; last one is missing “box” .
Example flow template of advanced usages in checking addresses:
Hold fulfillments if a customer placed multiple orders to the same address in 24 hours
https://shopify.com/admin/apps/flow/web/editor/templates/178e69ed-6bfe-4fc8-8cb8-817fc28f81da
In flow checking first line address should be order.shippingAddress.address1
and second line order.shippingAddress.address2
1.Beta https://shopify.dev/docs/api/functions/reference/cart-checkout-validation ,
Beta https://shopify.dev/docs/api/functions/reference/fulfillment-constraints