Auto-tag orders with a post office box#522
Open
timdmackey wants to merge 2 commits intolightward:mainfrom
Open
Auto-tag orders with a post office box#522timdmackey wants to merge 2 commits intolightward:mainfrom
timdmackey wants to merge 2 commits intolightward:mainfrom
Conversation
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.
Collaborator
|
@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! |
tekhaus
requested changes
Dec 9, 2025
| | match: po_box_regex | ||
| %} | ||
| {% assign po_box_match2 | ||
| = order.shipping_address.address2 |
Collaborator
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.