All things Shopify and commerce
I'm trying to add html code to my store to create an add name box but when i press the add to cart button '!expected String to be a Hash: properties' comes up.
How do I solve this?
I added the bottom 4 lines of code below 'variant picker'
{%- when 'variant_picker' -%}
{% render 'product-variant-picker', product: product, block: block, product_form_id: product_form_id %}
<div>
<label for="custom-name">Add Name</label>
<input type="text" id="custom-name" form="{{product_form_id}}"name="properties"[Add Name]/>
</div>
Thank for your help.
Solved! Go to the solution
This is an accepted solution.
Hi @ProuWarrior
The error message "!expected String to be a Hash: properties" typically occurs when there's an issue with the format of the properties being passed to the Shopify cart. To resolve this error, you need to ensure that the properties are formatted correctly. Here's how you can modify the code to fix the issue:
Replace the following line:
<input type="text" id="custom-name" form="{{product_form_id}}" name="properties"[Add Name]/>
With the updated code:
<input type="text" id="custom-name" form="{{ product_form_id }}" name="properties[Add Name]">
In the modified code, the properties value is placed inside square brackets [] and followed by an equal sign. This ensures that the "Add Name" value is correctly passed as a property to the cart.
Make sure to include the correct product form ID (product_form_id) in the form attribute of the input field.
After applying these changes, the "!expected String to be a Hash: properties" error should be resolved, and the "Add Name" value should be sent as a property to the Shopify cart.
Remember to thoroughly test the functionality to ensure that the custom name is correctly added to the cart for the selected product.
I hope this helps! Let me know if you have any further questions.
This is an accepted solution.
Hi @ProuWarrior
The error message "!expected String to be a Hash: properties" typically occurs when there's an issue with the format of the properties being passed to the Shopify cart. To resolve this error, you need to ensure that the properties are formatted correctly. Here's how you can modify the code to fix the issue:
Replace the following line:
<input type="text" id="custom-name" form="{{product_form_id}}" name="properties"[Add Name]/>
With the updated code:
<input type="text" id="custom-name" form="{{ product_form_id }}" name="properties[Add Name]">
In the modified code, the properties value is placed inside square brackets [] and followed by an equal sign. This ensures that the "Add Name" value is correctly passed as a property to the cart.
Make sure to include the correct product form ID (product_form_id) in the form attribute of the input field.
After applying these changes, the "!expected String to be a Hash: properties" error should be resolved, and the "Add Name" value should be sent as a property to the Shopify cart.
Remember to thoroughly test the functionality to ensure that the custom name is correctly added to the cart for the selected product.
I hope this helps! Let me know if you have any further questions.
Thank You! Problem solved.😁
Hey, I still have this problem. do you maybe now how I can fix this. I dont know where to add the code. i have it for all of my products
As 2024 wraps up, the dropshipping landscape is already shifting towards 2025's trends....
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024In today’s interview, we sat down with @BSS-Commerce to discuss practical strategies f...
By JasonH Nov 13, 2024