How can I add a mandatory 9-digit 'Organization Number' field in checkout?

Hi all, im new too shopify and apologies if i am completely in the wrong forum location or that this has been answered before or anything. I have tried to find an answer within google, shopify chat and shopify community without success.

Now my main goal was to add a mandatory field within the checkout called “Organization number”. It has to be digits only and has to be 9 digits. As far as i understand there is no way to edit the checkout using the Basic shopify plan.

So then i read further and found that maybe the best solution is too do this within the cart attribute. At this moment the code looks like this:


  
  

If i understand it correctly at the moment it will accept anything. Text, numbers whatever.

Would it be some kind of possibility to make something like:

"While ( vat_reg_no>99999999 && vat_reg_no<1000000000) {keep asking for the cart attribute}

(So basically only accept numbers that is 9 digits and if not keep asking)

Also i have figured like an alternative for me is: Create a new mandatory account field called “Organization number” and it will create a note on the account with the number in question. I would also need to set that account is required to buy at store which i would like to avoid.

Currently the code within customers/register.liquid looks like this:


This one has the same problem as the cart attribute that it has no kind of validation which is problematic.

Also naturally if i do get to fix this “Account creation with validation” i would like that the cart value gets automatically updated so that customers that have created an account dont have to fill it in twice.

Any help would be greatly appreciated. I am aware that there are apps that may help me out like “Customer fields” (https://apps.shopify.com/customr/reviews?rating=5&sort_by=recent)

However i am on a low budget and it will just not be possible. Thanks in advance.

Hi Andromedae,

I have read your case with interessting. I’m not facing the same promblem, but I think I can help you a little.

I have created a METAFIELD also for VAT number. When you create a METAFIELD you must deside the type of datainput. Then I use a code simalary yours in the main-cart.liquid:

Here you will see the pattern=“.{8,}” . The maximum carracters in this field.

In meanweile I have problems with storing the data Link to the case.

I have a question. Where do you store the “VAT Registration Number” in your solution?

//Stelton

After 14 days, the attributes on the Cart page work again. And honestly, and apart from the fact that I have spent a lot of time finding a cause, there have been no changes made to the shop. All tests are done at a test shop. Good that it works again…