Product_option_value missing in Liquid?

Hi everyone,

I’m trying to use the new product_option_value object in my project. However, every time I call it, it returns a string instead of the new object

I know Liquid is unversioned, so I wouldn’t know why it wouldn’t show the new object. Unless there’s other setup I’m missing.

Best,
Tomás

I was also just researching this, so I added the following code and tried various things.

<div data-section-id="{{ section.id }}">
  {% for option in product.options_with_values %}
    <div style="border: 1px solid rgba(0,0,0,0.4);">
      <div style="display:flex; gap:8px;">
        <span>
          {{ option.name }}
        </span>
        <span>position: {{ option.position }}</span>
        <span>selected_value: {{ option.selected_value }}</span>
      </div>
      <div style="padding-left: 16px; max-height:300px; overflow-y:scroll;">
        {% for value in option.values %}
          <div style="margin-bottom: 8px; {% if value.selected %}background-color:rgba(255,0,0,0.4);{% endif %}">
            <div>value.name: {{ value.name }}</div>
            <div>value.id: {{ value.id }}</div>
            <div>value.selected: {{ value.selected }}</div>
            <div>value.variant: {{ value.variant.title }}</div>
          </div>
        {% endfor %}
      </div>
    </div>
  {% endfor %}
</div>

As I wanted to try the “Section Rendering API” as well, I placed it at the very top of the “main-product.liquid” file as a separate section.
In my case, this resulted in the correct display, and it helped me understand how it’s linked to the URL.
I hope this is helpful for you.

2 Likes