-2

I have an ecommerce website and I would like to sell ONLY to a specific Zip code.

When a user go to my check out page and insert their information I want to disable the "buy button" if the zip code field does not matching with a predefined zip code list.

I want to implement that function on my woocommerce store.

Do you think that is possible to implement that using JS? If so, could you pass me the code Please?

Thank you so much in advance! I really appreciate your help.

I'm newbie and I have Started to study coding only 2 month ago.

  • Does this answer your question? [ZIP Code (US Postal Code) validation](https://stackoverflow.com/questions/160550/zip-code-us-postal-code-validation) – Marcello B. Feb 14 '21 at 18:01
  • `var isValidZip = /(^\d{5}$)|(^\d{5}-\d{4}$)/.test("90210");` – Marcello B. Feb 14 '21 at 18:03
  • You should work yourself into the nuts and bolts of the woocommerce plugin first. Asking for code without knowing its internal structure is useless, since you wont know where to put it. This is the place to start: https://docs.woocommerce.com/document/create-a-plugin/ – r3dapple Feb 14 '21 at 18:16

1 Answers1

0

Hey Frank i saw that you are located in italy,

dont forget that there are European laws wich forbid you to prevent buying stuff from an eu country or zipcode if you sell stuff in the eu. There should be an option for them to buy anywhere in the eu but you only ship to your prefered zipcodes.