I have a Custom Post Type called Pricebooks. I then have a custom taxonomy for Pricebooks called Zip Codes. Within that taxonomy the terms are the actual zip codes. I want to limit a Zip Code (the tax TERM) to be used only one time across ALL Pricebooks. So a Pricebook can have multiple Zip Code Terms but a Zip Code Term can only be used on one Pricebook.

I've done some searching and found nothing that fits the bill. I'm open to other solutions as well like using custom fields, etc. Thanks.

  • 1
    by zipcode, do you mean post codes US style? Or are these one time use codes more akin to single use vouchers? Note that there's a high chance this will require a custom taxonomy metabox, and that any answer will also need to make extensive use of filters to prevent XMLRPC/REST API/AJAX from assigning a second term. What was your original reasoning for using a taxonomy? I take it you've created terms for every possible zip code? – Tom J Nowell Aug 7 '18 at 1:08
  • US postal codes. Figured it would be easier to manage in the CMS and also query using taxonomy terms. This won't necessarily require every possible zip in the US, just ones that are served. If zip code isn't found, I'd present a message that they aren't in the service area basically. – shagpun Aug 8 '18 at 3:58
  • A taxonomy is still fine then, especially if you want to search for price books via zip code. The answer will need to involve a custom taxonomy though, and it's likely you'll need to specify that the UI in the admin area needs to be hidden so that you can implement your own UI that does all the checking and enforcing of this rule – Tom J Nowell Aug 8 '18 at 15:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.