Personalized checkout and custom promotions with Shopify Scripts
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 🙂
Solved! Go to the solution
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.
oh sorry for that issue if possible to add that code and share store url so i will check and let you know
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="" />
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?
@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
Result screenshot
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 😄
@larsgro ,
Replace input code with below one
<input type="text" name="properties[cart name]" class="field__input" required="" style="width: 300px; padding: 0px 10px;">
Hope this would be desired solution 😉
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!
Oh and another thing I just noticed @gr_trading :
How do I see the information they wrote in the field in the order itself?
<input type="text" name="properties[cart name]" class="field__input" required="" style="width: 300px; padding: 0px 10px;" placeholder="Enter details" />
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?
Thanks so much for your response 😄
@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" />
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 😄
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.
2m ago Learn the essential skills to navigate the Shopify admin with confidence. T...
By Shopify Feb 12, 2025Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025