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…
1 Like
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