Re: Add a required field to the cart page of Sense 2.0 theme

Solved

Add a required field to the cart page of Sense 2.0 theme

larsgro
Tourist
8 0 1

Hey!

 

I'd like to add a required field to the cart page of the Sense 2.0 theme.

Does anybody know how to do that?

I tried the Shopify UI Elements Generator as well as the app "Required", but both options don't work.

 

- Lars 🙂

Accepted Solution (1)
gr_trading
Shopify Partner
1996 147 205

This is an accepted solution.

@larsgro ,

Kindly replace the code with below one.

 

<label>Add Description</label>
<input type="text" name="attributes[cart name]" class="field__input" required="" style="width: 300px; padding: 0px 10px;" placeholder="Enter details" />

 

 

If your issue resolve, don't forget to like and mark as solution.

For any custom development WhatsApp or connect at Email ID: gr.trading15@gmail.com for quick consultation. | Shopify Free codes
To support Buy Me a Coffee

View solution in original post

Replies 14 (14)

KetanKumar
Shopify Partner
37583 3668 12151

@larsgro 

oh sorry for that issue if possible to add that code and share store url so i will check and let you know 

If helpful then please Like and Accept Solution. Partnership of your ️ Coffee Tips and my code can bring miracles.
Want to modify or custom changes on store Hire Me.
- Feel free to contact me on bamaniyaketan.sky@gmail.com regarding any help Shopify Partner | Skype : bamaniya.sky
PSD to Shopify | Shopify Design Changes | Shopify Custom Theme Development and Desing | Custom Modifications In to Shopify Theme | SEO & Digital Marketing

gr_trading
Shopify Partner
1996 147 205

Hi @larsgro ,

 

Please add below code after line number 77 in main-cart-items.liquid 

<input type='text' name="properties[cart name]" class="form-control" required="" />

 

For any custom development WhatsApp or connect at Email ID: gr.trading15@gmail.com for quick consultation. | Shopify Free codes
To support Buy Me a Coffee
larsgro
Tourist
8 0 1

Hey @gr_trading 

 

Thanks for your reply!

I added the code, but the field is below every product on the cart now. Is it possible to add it to the cart page only once?

 

Required_Fields.PNG

gr_trading
Shopify Partner
1996 147 205

@larsgro ,

 

To enable mandatory field only once you need to put below code just before to line no. 289, after {%- endfor -%}

<tr>
            <td colspan="5">
              <input type='text' name="properties[cart name]" class="form-control" required="" />
            </td>
</tr>

below is screenshot for reference

hari1_prasad_0-1666600921744.png

 

 

Result screenshot

hari1_prasad_1-1666600942604.png

 

 

 

For any custom development WhatsApp or connect at Email ID: gr.trading15@gmail.com for quick consultation. | Shopify Free codes
To support Buy Me a Coffee
larsgro
Tourist
8 0 1

Thank you so much @gr_trading !

 

Is there a possibility to make the field bigger and add a description above it?

Then the solution is found 😄

gr_trading
Shopify Partner
1996 147 205

@larsgro ,

 

Replace input code with below one

<input type="text" name="properties[cart name]" class="field__input" required="" style="width: 300px; padding: 0px 10px;">

 

hari1_prasad_0-1666685631625.png

 

Hope this would be desired solution 😉

For any custom development WhatsApp or connect at Email ID: gr.trading15@gmail.com for quick consultation. | Shopify Free codes
To support Buy Me a Coffee
larsgro
Tourist
8 0 1

Hey @gr_trading 

 

Thanks for the edited code 😄

There's one thing left: do you know how to add a description above the field? So customers know what they have to put in the field?

 

Thanks again for your response, appreciate it!

larsgro
Tourist
8 0 1

Oh and another thing I just noticed @gr_trading :

How do I see the information they wrote in the field in the order itself?

gr_trading
Shopify Partner
1996 147 205

@larsgro 

 

<input type="text" name="properties[cart name]" class="field__input" required="" style="width: 300px; padding: 0px 10px;" placeholder="Enter details" />

 

For any custom development WhatsApp or connect at Email ID: gr.trading15@gmail.com for quick consultation. | Shopify Free codes
To support Buy Me a Coffee
larsgro
Tourist
8 0 1

Hey @gr_trading 

 

The field is bigger now but the description doesn't show up...

And I can't see the details the customer put in in the order itself, do you know how to add them?

Screenshot.png

 

Thanks so much for your response 😄

gr_trading
Shopify Partner
1996 147 205

@larsgro ,

 

Change name="properties[cart name]" with name="attributes[cart name]"

 

 

<input type="text" name="attributes[cart name]" class="field__input" required="" style="width: 300px; padding: 0px 10px;" placeholder="Enter details" />

 

For any custom development WhatsApp or connect at Email ID: gr.trading15@gmail.com for quick consultation. | Shopify Free codes
To support Buy Me a Coffee
larsgro
Tourist
8 0 1

Thanks so much for the swift reply @gr_trading !

 

I just can't seem to add a description above the field...

After that, the problem is solved 😄Scr.png

gr_trading
Shopify Partner
1996 147 205

This is an accepted solution.

@larsgro ,

Kindly replace the code with below one.

 

<label>Add Description</label>
<input type="text" name="attributes[cart name]" class="field__input" required="" style="width: 300px; padding: 0px 10px;" placeholder="Enter details" />

 

 

If your issue resolve, don't forget to like and mark as solution.

For any custom development WhatsApp or connect at Email ID: gr.trading15@gmail.com for quick consultation. | Shopify Free codes
To support Buy Me a Coffee
larsgro
Tourist
8 0 1

Thank you so much @gr_trading ! 😄