Renaming metafields

Solved

Renaming metafields

lolkedijkstra
Shopify Partner
3 1 0

Hello,

 

On my website, I have changed some product metafield definitions (that is renamed the metafield, I am not talking about the associated content). 

 

After having done that, the site appeared to work fine. BUT..

I discovered I had forgotten to update the names in some places in liquid code. So, I updated these accordingly.

After that, the site no longer works correctly. WHAT?

 

Okay, to make sure I am not mistaken here, I changed them back in the snippet to the OLD definitions. Surprise, surprise, it works again. WOW!

 

I am developing on CLI. 

 

My idea is that this is a CACHING problem. But how?

 

Here's a bit more info.

 

It looks like this here is the culprit:

 
the metafield: custom.compare_customer_title no longer exists (in my mind) because I renamed it to custom.compare_title
 
So, the old code had:
{% if product.metafields.custom.compare_customer_title %}
 
and that was replaced with
{% if product.metafields.custom.compare_title %}
 
making it consistent with the name change. Now it stopped showing that component.
 
So, I changed it back to:
{% if product.metafields.custom.compare_customer_title %}
 
And it worked again(!) But, that of course, is problematic. 
 

Does somebody have similar experience, or somebody here able to help?

 

Oh, forgot to mention, the metafields (new name) are visible on the product page on Shopify, and they have content.

 

Your help is much appreciated!

Thanks,

Luke

 
 

 

Accepted Solution (1)
lolkedijkstra
Shopify Partner
3 1 0

This is an accepted solution.

Solution: delete metafields with data (second option) and then define the new datafield. 

View solution in original post

Replies 2 (2)

lolkedijkstra
Shopify Partner
3 1 0

Don't seem to be able to edit my post, so I am adding some additional info here. It is just to make it more clear. 

Screenshot 2025-02-15 at 15.22.40.png

Above:

  • Metafields have been renamed and are filled in.
  • Product: Hydro+ Infinity

Below:

The code snippet below references the old names

Screenshot 2025-02-15 at 15.24.19.png

lolkedijkstra
Shopify Partner
3 1 0

This is an accepted solution.

Solution: delete metafields with data (second option) and then define the new datafield.