Pre-fill order custom field

Hi

I have created custom order field and I want to prefill them with text value. How should I approach this?

I checked the document but could not find a section for this.

Any help is appreciated

Hey @MorningTide,

Unfortunately, it’s not possible to prefill the custom field with a value at the moment. This is something we do have in our backlog, but no ETA at this point.

Hi

Thank you for your reply. That’s a bit unfortunate.

I was hoping to create a system where I have the user selects wards and districts then fill the zip code field accordingly. There’s must be someway to achieve this. I will try to look into it more.

Hi @charles

I am wondering about this method, can you help me by confirming if this would work or not.

  1. I will self-host the snipcart.js script
  2. In the snipcart.js, I will modify the default value of this section

Looking forward to hearing from you soon

Hi, I would love to follow up on this topic. It’s ok if it is not possible

Hi @MorningTide,

You can update the billing address by using the Snipcart.api.cart.update method.

Hi @lea

Thank you for the reply but I read the documentation, it says that all field must be filled and I am only need to fill the zip code field for the customer.

Customers checkout → Input their address → the zip code is already filled → Customer doesn’t have to fill them anymore

I hope that makes sense

Hi there,

At the moment, addresses are validated as a whole upon patching the cart. It is currently not possible to patch only a subset of the required fields.

Hi @francis

I just tried self-hosting snipcart.js and changed that specific field I mentioned above. It worked!

Thanks for the update. Well that’s good if you managed to modify our scripts to make it work! Definitely not the typical integration path though :grimacing:

For the record, this is an extreme situation that I had to do this. I would not recommend anyone to do this since:

  1. You won’t get any update
  2. If anything breaks, it’s my fault or your fault

I only change the postal code field so that it has a default value of something else instead of being blank.

With that being said, it shows that there is potential for expandability i.e set default value for a certain field.