Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
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.
Solved! Go to the solution
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
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
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025