Have your say in Community Polls: What was/is your greatest motivation to start your own business?

Re: expected String to be a Hash: properties

Solved

expected String to be a Hash: properties

ProuWarrior
Visitor
2 0 0

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.

 

Accepted Solution (1)

Ecommpremium
Shopify Partner
512 43 93

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.

- Did we solve your issue? Like & Mark As Solution to help the community
- SKYPE: ahsanaliawan
- 300+ Video Tutorials
-Website

View solution in original post

Replies 3 (3)

Ecommpremium
Shopify Partner
512 43 93

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.

- Did we solve your issue? Like & Mark As Solution to help the community
- SKYPE: ahsanaliawan
- 300+ Video Tutorials
-Website
ProuWarrior
Visitor
2 0 0

Thank You! Problem solved.😁

 

DylanBensi20
Visitor
3 0 0

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