We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Need URGENT help pulling custom liquid into cart

Need URGENT help pulling custom liquid into cart

Tommasters9
Visitor
1 0 1

I need help pulling custom liquid from the product page into the cart. I have spent hours on end trying to figure this out and using Chat GPT but I havent managed to implement anything that works. For context, I provide experience days and need customers to be able to select a date they wish for their experience to take place. I have this as a custom liquid but it is not pulling through onto the cart. 

Any help or advise on this would be appreciated...

Reply 1 (1)

TheUntechnickle
Shopify Partner
555 66 162

Hey @Tommasters9,

 

Oh man, I totally feel your pain on this one!

 

The key thing with Shopify is that custom liquid on product pages doesn't automatically carry over to the cart - you need to pass it through as line item properties. Here's how to get your date selector working:

 

On your product page, make sure your date input has the right naming:

 

<label for="experience-date">Select Experience Date:</label>
<input type="date" 
       name="properties[Experience Date]" 
       id="experience-date" 
       required>

The crucial part is name="properties[Experience Date]" - that "properties" prefix is what tells Shopify to save this data with the cart item.

 

If you're using a more complex date picker, wrap it like this:

 

<div class="date-selector">
  <label>Choose your experience date:</label>
  <!-- Your custom date picker liquid here -->
  <input type="hidden" 
         name="properties[Experience Date]" 
         id="selected-date-hidden">
</div>

<script>
// When your custom picker changes, update the hidden field
document.addEventListener('dateSelected', function(e) {
  document.getElementById('selected-date-hidden').value = e.detail.selectedDate;
});
</script>

 

Then in your cart template, you can display it:

 

{% for item in cart.items %}
  <div class="cart-item">
    <h3>{{ item.product.title }}</h3>
    {% if item.properties['Experience Date'] %}
      <p><strong>Experience Date:</strong> {{ item.properties['Experience Date'] }}</p>
    {% endif %}
  </div>
{% endfor %}

 

If you're still having trouble, can you share a bit of your current date selector code? I'd be happy to take a look and see what might be tripping it up!

Hope this helps get you unstuck!

 

Cheers!
Shubham | Untechnickle

Helping for free: hello@untechnickle.com


Don't forget to say thanks, it'll make my day - just send me an email! 


Get Revize for Free | Let your shoppers edit orders post-purchase | Get Zero Support Tickets | #1 Order Editing + Upsell App