You can restrict shipping to p.o. boxes with
Calcurates shipping software. Calcurates provides you with a preset Shipping Segment with conditions for address lines 1 and 2 that contain a set of regular expressions for p.o. boxes commonly used in the US and Canada: HCR, RFD, P.O.B, Box, PO., P.O, and Route. This Shipping Segment can be used as a condition for the Shipping Rule that restricts shipping to p.o. boxes.
If any of these restrictions are activated and the customer enters any of those conditions in address lines 1 or 2, the shipping method will not be available at the checkout and the explanatory message can be displayed to inform the customer about the P.O. box shipping restriction.
You can install Calcurates multi-carrier shipping extension for
Magento,
Shopify, or
WooCommerce.