Unable to edit customer field in liquid code

Solved

Unable to edit customer field in liquid code

Userino1999
New Member
7 0 0

Hi there,

 

I'm trying to edit a customer field in theme.liquid without any success.

 

This is the code I've tried to clear the customer's company name when they are logged in.

{%- if customer -%}
<p>TEST the user is logged in TEST</p>
{% assign customer.company = nil %}
{%- endif -%}

 

I've also tried the below to just test:

{%- if customer -%}
<p>TEST the user is logged in TEST</p>
{% assign test_var = customer.company %}
{{ test_var}}
{%- endif -%}

 

I've also tried changing customer.first_name and others. It appears that I just can't access/edit the customer field at all in code. Any ideas why this could be?

 

Using Dawn 2.0 theme.

Accepted Solution (1)

PaulNewton
Shopify Partner
7722 678 1626

This is an accepted solution.

Liquid does not allow directly mutating the values of properties of resource objects.

 

Make your own variable and use that in customer templates set to nil, and or based on the initial customer.company  variable

 

i.e. {% assign test_var = nil %}

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org


View solution in original post

Reply 1 (1)

PaulNewton
Shopify Partner
7722 678 1626

This is an accepted solution.

Liquid does not allow directly mutating the values of properties of resource objects.

 

Make your own variable and use that in customer templates set to nil, and or based on the initial customer.company  variable

 

i.e. {% assign test_var = nil %}

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org