Added a required field to all product pages, but I want it to show on all products EXCEPT for one.

Solved
Tourist
8 0 1

I have a custom required question on all of my products ("What is your dog's name?")

This is the code I currently use:

 

{% form 'product', product, class:productform_class %}
<p class="line-item-property__field">
<label for="what-is-your-dogs-name">What is your dog's name?</label>
<input required class="required" id="what-is-your-dogs-name" type="text" name="properties[What is your dog's name?]">

 

Everything is working great, except that there is one product that I'd like this question to not show up on. How could I do this?

 

Thank you!!

0 Likes
Pathfinder
102 4 11

@CCBandanas wrote:

I have a custom required question on all of my products ("What is your dog's name?")

This is the code I currently use:

 

{% form 'product', product, class:productform_class %}
<p class="line-item-property__field">
<label for="what-is-your-dogs-name">What is your dog's name?</label>
<input required class="required" id="what-is-your-dogs-name" type="text" name="properties[What is your dog's name?]">

 

Everything is working great, except that there is one product that I'd like this question to not show up on. How could I do this?

 

Thank you!!


You should check if the current product's id equal to the product which you don't want to show => hidden the form.

Vince Nguyen | Ecommerce Consultant at HappyPoints.io
Was my reply helpful? Click Like to let me know!
Was your question answered? Mark it as an Accepted Solution
Email me at: vince@happypoints.io
Skype: vince@happypoints.io
1 Like
Tourist
8 0 1

Thank you for taking the time to help!

 

I'm not 100% sure what you mean though. I have the code pasted in product-template.liquid so it's applying to all products. The product I want to exclude has an ID of 1738519052351

Could you help me write a line that basically says "except 1738519052351"?

 

I'm new to this, sorry!!

0 Likes

Success.

Shopify Partner
26 5 5

Try replacing above mention code with this one.

 

{% form 'product', product, class:productform_class %}
<p class="line-item-property__field">

{% if product.id != 1738519052351 %}
<label for="what-is-your-dogs-name">What is your dog's name?</label>
<input required class="required" id="what-is-your-dogs-name" type="text" name="properties[What is your dog's name?]">

{% endif %}

 

1 Like
Tourist
8 0 1

Yes this is perfect, thank you!!

0 Likes
Tourist
3 0 0

I'm brand new to shopify and need to add a code like this to our store. We're a veterinary clinic and I need each product to have a required text field for the client to be able to put the pet's name. I'm not sure where or how to enter this code. Any help would be appreciated.

0 Likes
Tourist
8 0 1

 


@jstuk05 wrote:

I'm brand new to shopify and need to add a code like this to our store. We're a veterinary clinic and I need each product to have a required text field for the client to be able to put the pet's name. I'm not sure where or how to enter this code. Any help would be appreciated.


I pasted the code in "product-template.liquid" right before the </p> tag

1 Like
Shopify Partner
26 5 5

@jstuk05 

By looking at your requirement, you can go with any of the app mention below. I am not promoting any of the app but once you add that particular code on your product page, you must need that information into your cart and order details also. So by just implementing on product page your task will not gets completed.

https://apps.shopify.com/custom-options

https://apps.shopify.com/product-options

https://apps.shopify.com/product-options-by-hulkapps-1

 

You can have more idea here: https://help.shopify.com/en/themes/customization/products/features/get-customization-information-for...

1 Like
Tourist
4 0 1

Hi, I have a questions and I hope you can help me.

 

I have a mix of digital download products and personalized digital products.

For the custom / personalized products, I have to get input from customers and I want to make that input as "required"

 

So I made a code and input between <form> 

 

            <p class="line-item-property__field">
            <label for="personalization">Add your personalization</label>

            <textarea required class="required" id="personalization" placeholder="★First name★ Age ★Date and Time★ Location ★RSVP★" name="properties[Personalization]"></textarea>
            </p>
               <style>
                  textarea 
                    {
                    width: 100%;
                    }
              </style>
            {% include 'autosizetextarea' %}

I have 2 questions.

1 - The required option for the text box is not working and when I click on the submit button (add to cart) I can add products and validation on textarea is not working. Can anybody point me what is wrong with my code?

 

2 - second. I want this code to appear on all collections or product types except one.

For example (if collection name is XYZ than hide this personalization option and apply this to all products inside a collection) or (if product type is XYZ than hide this personalization). I'm new to liquid so if anybody can help me liquid code on how to achieve that? 

 

Thanks for your time!

Jovica

 

 

0 Likes
Highlighted
Shopify Partner
26 5 5

@S3ratin  I know it is too late...but if you need some help regarding the same issue, I can help with it.

0 Likes