Splitting Metafield Value List / Product with multiple colors

Splitting Metafield Value List / Product with multiple colors

Ben_Simon
Tourist
9 0 1

I have a Color metafield:
- Single Line
- Value List

Where I want to put the product colors in.
Sometimes only one, sometimes 5 colors per product.

 

Now I want to display the color(s) to the customer in a single line seperated by a "/".
 
This is the output if you render the metafield like : 

{{ product.metafields.custom.color.value }}

1.jpg

 Both tags have no space in-between

 

And this is the output if I´m trying to use the "Split" function:

{{ product.metafields.custom.color.value | Split:"/" }}

2.jpg

Why does it render the "(" brackets? 

 

This is how the metafield is set up

3.jpg


The Code that renders the Color Variant:

 

<p class="related-products-heading" style="font-size: {{block.settings.heading_font_size}}px; color: {{block.settings.heading_color}};">{{ block.settings.heading }}
<span style="color: #acacac;">Farbe:&ensp;</span> <span style="color: #4DA9A9;"> {{ product.metafields.custom.color.value }}</span>
</p> 

 

Any ideas how to solve my issue?

Replies 2 (2)

Ben_Simon
Tourist
9 0 1

Of course you can do something like this:

 

{{ product.metafields.custom.color.value | remove: "[" | remove: "]" | remove: '"' | split: "/" }}

 

But at the end the "/" still does not work and will only render a ",":

Bildschirmfoto 2024-02-01 um 16.53.36.jpg

 

 

Ben_Simon
Tourist
9 0 1

Bump!