endcapture error

Highlighted
New Member
8 0 0

I have a bit of code I am using to hide the prices of some products on our website. When I go to save it's throwing the error "Line 155— Liquid syntax error: 'endcapture' is not a valid delimiter for if tags. use endif

What am I missing with the following code? The last line of this code is Line 155.

 <div class="product-item__info">
    <div class="product-item__info-inner">
      {%- capture price_list -%}
        <div class="product-item__price-list price-list">
         {% assign hide_price = false %}          
{% for tag in product.tags %}{% if tag contains 'hide-price' %}{% assign hide_price = true %}{% break %}{% endif %}{% endfor %}          
         {%- if hide_price -%}
		  <strong>Contact us for price</strong>
      	 {%- else -%}
          {%- if product.price < product.compare_at_price -%}
            {%- if product.compare_at_price_varies -%}
              {%- capture price_min -%}<span>{{ product.price_min | money_without_trailing_zeros }}</span>{%- endcapture -%}
              {%- capture price_max -%}<span>{{ product.price_max | money_without_trailing_zeros }}</span>{%- endcapture -%}
              <span class="price price--highlight">{{ 'collection.product.from_price_html' | t: price_min: price_min, price_max: price_max }}</span>
              <span class="price price--compare">{{ product.compare_at_price_min | money_without_trailing_zeros }}</span>
            {%- else -%}
              <span class="price price--highlight">{{ product.price | money_without_trailing_zeros }}</span>
              <span class="price price--compare">{{ product.compare_at_price | money_without_trailing_zeros }}</span>
            {%- endif -%}
          {%- elsif product.price_varies -%}
            {%- capture price_min -%}<span>{{ product.price_min | money_without_trailing_zeros }}</span>{%- endcapture -%}
            {%- capture price_max -%}<span>{{ product.price_max | money_without_trailing_zeros }}</span>{%- endcapture -%}
            <span class="price">{{ 'collection.product.from_price_html' | t: price_min: price_min, price_max: price_max }}</span>
          {%- else -%}
            <span class="price">{{ product.price | money_without_trailing_zeros }}</span>
          {%- endif -%}
        </div>
        {%- if product.selected_or_first_available_variant.unit_price_measurement -%}
          <div class="product-item__price-info">
            <div class="unit-price-measurement">
              <span class="unit-price-measurement__price">{{ product.selected_or_first_available_variant.unit_price | money_without_trailing_zeros }}</span>
              <span class="unit-price-measurement__separator">/ </span>

              {%- if product.selected_or_first_available_variant.unit_price_measurement.reference_value != 1 -%}
                <span class="unit-price-measurement__reference-value">{{ product.selected_or_first_available_variant.unit_price_measurement.reference_value }}</span>
              {%- endif -%}
              <span class="unit-price-measurement__reference-unit">{{ product.selected_or_first_available_variant.unit_price_measurement.reference_unit }}</span>
            </div>
          </div>
        {%- endif -%}
      {%- endcapture -%}

Thanks!

0 Likes
Highlighted
Shopify Partner
1201 255 352

Hey there,

As per above code , according to me one of the endif is missing.

Put endif

{%- endif -%}

Above this:

 </div>
        {%- if product.selected_or_first_available_variant.unit_price_measurement -%}

Hope this will work.

 

Thanks!

If helpful then please Like and Accept Solution.
Do you need custom changes on store ? Hire me.
Feel free to Contact me on dmw.webartisan@gmail.com
Follow us on Instagram @dmw.webartisan
0 Likes
Highlighted
New Member
8 0 0

That cleared the syntax error but now the product grid has an error. As seen in the image below, the product that doesn't have the "hide-price" tag is sandwiched beneath the other product.

Capture.PNG

 <div class="product-item__info">
    <div class="product-item__info-inner">
      {%- capture price_list -%}
        <div class="product-item__price-list price-list">
          {% assign hide_price = false %}          
{% for tag in product.tags %}{% if tag contains 'hide-price' %}{% assign hide_price = true %}{% break %}{% endif %}{% endfor %}          
         {%- if hide_price -%}
		  <strong>Contact us for price</strong>
      	 {%- else -%}
          {%- if product.price < product.compare_at_price -%}
            {%- if product.compare_at_price_varies -%}
              {%- capture price_min -%}<span>{{ product.price_min | money_without_trailing_zeros }}</span>{%- endcapture -%}
              {%- capture price_max -%}<span>{{ product.price_max | money_without_trailing_zeros }}</span>{%- endcapture -%}
              <span class="price price--highlight">{{ 'collection.product.from_price_html' | t: price_min: price_min, price_max: price_max }}</span>
              <span class="price price--compare">{{ product.compare_at_price_min | money_without_trailing_zeros }}</span>
            {%- else -%}
              <span class="price price--highlight">{{ product.price | money_without_trailing_zeros }}</span>
              <span class="price price--compare">{{ product.compare_at_price | money_without_trailing_zeros }}</span>
            {%- endif -%}
          {%- elsif product.price_varies -%}
            {%- capture price_min -%}<span>{{ product.price_min | money_without_trailing_zeros }}</span>{%- endcapture -%}
            {%- capture price_max -%}<span>{{ product.price_max | money_without_trailing_zeros }}</span>{%- endcapture -%}
            <span class="price">{{ 'collection.product.from_price_html' | t: price_min: price_min, price_max: price_max }}</span>
          {%- else -%}
            <span class="price">{{ product.price | money_without_trailing_zeros }}</span>
          {%- endif -%}
        </div>
{%- endif -%}
        {%- if product.selected_or_first_available_variant.unit_price_measurement -%}
          <div class="product-item__price-info">
            <div class="unit-price-measurement">
              <span class="unit-price-measurement__price">{{ product.selected_or_first_available_variant.unit_price | money_without_trailing_zeros }}</span>
              <span class="unit-price-measurement__separator">/ </span>

              {%- if product.selected_or_first_available_variant.unit_price_measurement.reference_value != 1 -%}
                <span class="unit-price-measurement__reference-value">{{ product.selected_or_first_available_variant.unit_price_measurement.reference_value }}</span>
              {%- endif -%}

              <span class="unit-price-measurement__reference-unit">{{ product.selected_or_first_available_variant.unit_price_measurement.reference_unit }}</span>
            </div>
          </div>
        {%- endif -%}
      {%- endcapture -%}

Thank you for the help!

-Sean

0 Likes
Highlighted
Shopify Partner
1201 255 352

Try to correct this

</div>
{%- endif -%}
        {%- if product.selected_or_first_available_variant.unit_price_measurement -%}

to

{%- endif -%}
</div>
        {%- if product.selected_or_first_available_variant.unit_price_measurement -%}

Thanks!

If helpful then please Like and Accept Solution.
Do you need custom changes on store ? Hire me.
Feel free to Contact me on dmw.webartisan@gmail.com
Follow us on Instagram @dmw.webartisan
0 Likes