Skip to content

Auto-tag orders with a post office box#522

Open
timdmackey wants to merge 2 commits intolightward:mainfrom
timdmackey:task/auto-tag-orders-with-a-post-office-box
Open

Auto-tag orders with a post office box#522
timdmackey wants to merge 2 commits intolightward:mainfrom
timdmackey:task/auto-tag-orders-with-a-post-office-box

Conversation

@timdmackey
Copy link
Contributor

@timdmackey timdmackey commented Nov 30, 2025

This task monitors for newly-created orders, and auto-tags any that have a detected post office box in the shipping address. This is useful for shipping services that do not service postal boxes. The task can also optionally send an email notification when a P.O. Box is detected.

Canny request.

I'm interested in feedback on this one, particularly on whether the pattern matching is robust enough for this to be serviceable. The regex I have should be highly accurate, but there's still the possibility of some edge cases being missed or incorrectly flagged. Is it good enough even if there's a slim possibility of false positives/negatives?

Also, I'm not sure about my approach to option validation. Since email notifications are optional, I didn't want to make the email options required. My approach throws an error object if any of the options are missing (when notifications are enabled), but the downside is that it's possible for the merchant to miss this if the options are pushed down the page far enough to be out of the viewport.

This task monitors for newly-created orders, and auto-tags any that have a detected post office box in the shipping address. This is useful for shipping services that do not service postal boxes. The task can also optionally send an email notification when a P.O. Box is detected.
@tekhaus tekhaus self-assigned this Dec 8, 2025
@tekhaus
Copy link
Collaborator

tekhaus commented Dec 9, 2025

@timdmackey The option field validation approach in the task code is a perfectly acceptable solution in this context.

Only one other comment I had in the task code itself that should be remediated.

Everything else looks good!

| match: po_box_regex
%}
{% assign po_box_match2
= order.shipping_address.address2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe address2 field can be null in the webhook (at least per the Shopify dev docs). If so, then the scan will throw an error as it expects a string.

Just pop an if statement around this I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants