Custom field initial values

Hello,
I am trying to add a custom order field for the request user. The goal is to send the user’s id to Snipcart so I can process that later in webhook requests.

<billing section="bottom">
    <fieldset class="snipcart-form__set">
        <div class="snipcart-form__field">
            <snipcart-label class="snipcart__font--tiny" for="requestUser">
                User
            </snipcart-label>
            <snipcart-input name="requestUser" id="snipcart_request_user"></snipcart-input>
        </div>
    </fieldset>
</billing>

Is there a way to initialize the input, something like value=“1”? I guess another solution is to listen to JS events and manually change the value, but that sounds unnecessarily complicated.

Thanks in advance

Hi @multifractal,

Custom fields’ value are synced from the cart’s state. Here is a demo showing how you can set the cart state to add default custom fields values: Custom field default value - CodeSandbox

We are constantly thinking about how to improve our forms and custom field system and we will take this use case into account.

Cheers!

1 Like