Re: How to add a text field in the information area of checkout

How to add a text field in the information area of checkout

raprapskie
Shopify Partner
12 0 1

I hope everyone is doing well.

 

Can someone help me add a text field for Name and contact number under "Your Contact information".

 

raprapskie_0-1664469414969.png

 

Thank you everyone

 

Replies 3 (3)

layoutbase
Pathfinder
111 13 25

Hi @raprapskie , it's Layoutbase here.

We would like to provide you with our thoughts on your question.

 

The plus plan is required to perform the mentioned adjustment. Other plans can’t do it.

Instructions are as below:

1. Go to Online Store->Theme->Edit code

2. Layout/checkout.liquid -> add code below before </head> tag

 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>

 

3. Go to Layout/checkout.liquid -> add code below before </body> tag

 

<script>
      const NAME = '';
      const PHONE_NUMBER = '';
      var addCustomField = function () {
        let nameField = `<div class="field"><div class="field__input-wrapper custom" id="name-field"><label class="field__label field__label--visible" for="contact-name">Name:</label>
        <input data-is-error="true" data-custom-input="true" placeholder="Name" value="${NAME}" autocorrect="off"  class="field__input" aria-required="true" type="text" name="checkout[attributes][Contact Name]" id="contact-name" >
        </div></div>`;
        
        let phoneField = `<div class="field"><div class="field__input-wrapper custom" id="phone-field"><label class="field__label field__label--visible" for="phone-number">Number Phone:</label>
        <input data-is-error="true" data-custom-input="true" placeholder="Number Phone" value="${PHONE_NUMBER}" autocorrect="off"  class="field__input" aria-required="true" type="text" name="checkout[attributes][Phone Number]" id="phone-number">    
        </div></div>`;
        $('.section--contact-information .fieldset').prepend(phoneField);
        $('.section--contact-information .fieldset ').prepend(nameField);
      };
       addCustomField();
    </script>

 

Hope you find our suggestion helpful.

 

Best regards,

Layoutbase

 

Please let us know if you find it helpful by giving us a LIKE and Mark as Solution.

Layoutbase is a leading Shopify page builder. Give us a try HERE!

Please let us know if you find it helpful by giving us a LIKE and Mark as Solution. Layoutbase is a leading Shopify page builder. Give us a try!
raprapskie
Shopify Partner
12 0 1

Thank you for your help, if we get the shopify plus, I will try this one.

cmoosbrugger
Tourist
3 0 0

Hi,

 

can you give me also the snippet to just add a static text above the ATC button? It also should be able to be translated.

 

thanks!

2023-04-15 09_22_48-Zahlung - Martello Café - Bezahlung.png