How to add line Item Properties to only 1 collection?

How to add line Item Properties to only 1 collection?

HappyHues
Visitor
2 0 0

I have the code written for the "Colors You Would Like: (Example G3, P6, BK1)" line item, "Wooden Beads: Yes/NO" line item, and "🪢 Braids, Twists, & Knots: Yes/No" line item. They work perfectly! But I only want to add those 3 line items to my collection called "Custom Orders". 

Can someone please write a code for this? Thank you! 

 

The 3 codes that work: 

<p class="line-item-property__field">

  <label for="colors-you-would-like-example-g3-p6-bk1">🎨Colors You Would Like: (Example G3, P6, BK1) </label>

  <input required class="required" id="colors-you-would-like-example-g3-p6-bk1" type="text" name="properties[🎨Colors You Would Like: (Example G3, P6, BK1) ]">

</p>

 

<p class="line-item-property__field">

  <label for="wooden-beads-yesno">🪵Wooden Beads: Yes/No</label>

  <input required class="required" id="wooden-beads-yesno" type="text" name="properties[🪵Wooden Beads: Yes/No]">

</p>

 

<p class="line-item-property__field">

  <label for="wooden-beads-yesno">🪵Wooden Beads: Yes/No</label>

  <input required class="required" id="wooden-beads-yesno" type="text" name="properties[🪵Wooden Beads: Yes/No]">

</p>

Replies 2 (2)

BSSCommerce-B2B
Shopify Partner
1430 400 464

Hi @HappyHues , 

I have reviewed your requirement, you just need to edit code script and the issue will be resolved.  

You need to wrap the line items in a conditional statement that checks if the product belongs to the "Custom Orders" collection in liquid file.

Like this below: 

{% if product.collections contains 'Custom Orders' %}
  <p class="line-item-property__field">
    <label for="colors-you-would-like-example-g3-p6-bk1">:artist_palette:Colors You Would Like: (Example G3, P6, BK1) </label>
    <input required class="required" id="colors-you-would-like-example-g3-p6-bk1" type="text" name="properties[:artist_palette:Colors You Would Like: (Example G3, P6, BK1) ]">
  </p>

  <p class="line-item-property__field">
    <label for="wooden-beads-yesno">🪵Wooden Beads: Yes/No</label>
    <input required class="required" id="wooden-beads-yesno" type="text" name="properties[🪵Wooden Beads: Yes/No]">
  </p>

  <p class="line-item-property__field">
    <label for="braids-twists-knots-yesno">🪢 Braids, Twists, & Knots: Yes/No</label>
    <input required class="required" id="braids-twists-knots-yesno" type="text" name="properties[🪢 Braids, Twists, & Knots: Yes/No]">
  </p>
{% endif %}

 

With "{% if product.collections contains 'Custom Orders' %}" , you can add those 3 line items to my collection called "Custom Orders". 

 

I hope these instructions will help you. If they are helpful, please give us likes and mark as the solution.

Have a nice day sir! 

B2B Wholesale Solution: Streamline your B2B operation with advanced features like wholesale registration forms, custom pricing.


B2B Portal, Quote, Net 30: Speed up purchasing and streamline your quotation process with advanced features like quick order, request for quote.


B2B Lock Password Protect: Easily control access to pages, products, and pricing with robust features.


BSS Commerce - Full-service eCommerce Agency I Use Shopify for 1$ in the first month now

HappyHues
Visitor
2 0 0

Thank you for the reply! I appreciate you taking the time to help! It is still not working, am I putting the code into the wrong line or section? I am very new to this!

 Screen Shot 2024-08-07 at 11.37.22 AM.pngScreen Shot 2024-08-07 at 11.33.39 AM.png