Cant resolve the syntax error in ruby language
Open
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 11.9k
- Forks
- 1.5k
- Avg merge
- 17h 55m
- Merged PRs (30d)
- 3
Description
I have this shopify snippet which displays the related products on product details page as well as on cart page
`{% for item in cart.items %}
{{ item.product.title }}
{% assign existed_handle = item.product.handle %} {% assign related_product_handles = '' %} {% for collection in item.product.collections %}
{% if collection.title != 'Home page'%}
{% assign current_collection = collections[collection.handle] %}
{% for productItem in current_collection.products %}
{% assign not_existed = true %}
{% if existed_handle == productItem.handle %}
{% assign not_existed = false %}
{% endif %}
{% if not_existed %}
{% assign relatedHandleArr = related_product_handles | split: ',' %}
{% unless relatedHandleArr contains productItem.handle %}
{% if related_product_handles != '' %}
{% assign related_product_handles = related_product_handles | append: ',' %}
{% endif %}
{% assign related_product_handles = related_product_handles | append: productItem.handle %}
{% endunless %}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
{% if related_product_handles != '' %}
<div class="gp-related-products" id="gp-related-products">
<div class="related-title">
<h2>{{ 'products.product.related_products' | t }}</h2>
</div>
<div class="related-items">
{% assign count_product_main = 1 %}
{% assign related_product_handle_items = related_product_handles | split: ',' %}
{% assign related_product_handle_size = related_product_handle_items.size %}
{% assign product_per_row = 5 %}
{% assign total_rows = related_product_handle_size | divided_by: product_per_row | ceil %}
{% assign limit = product_per_row | times: 2 %}
{% assign row_count = 1 %}
<div class="product_items slick-related">
{% for related_product_handle in related_product_handle_items %}
{% if count_product_main <= limit %}
{% if count_product_main == 1 %}
<div class="related-product-row">
{% endif %}
<div class="product-item">
{% assign productItem = all_products[related_product_handle] %}
{% include 'gp-product-grid' with product: productItem %}
</div>
{% if count_product_main == limit or count_product_main == related_product_handle_size %}
</div>
{% assign remaining_items = total_rows | minus: row_count | times: product_per_row %}
{% if remaining_items > 0 %}
{% for i in (1..remaining_items) %}
<div class="product-item empty"></div>
{% endfor %}
{% endif %}
{% assign row_count = row_count | plus: 1 %}
{% if row_count <= total_rows %}
<div class="related-product-row">
{% endif %}
{% elsif count_product_main | modulo: product_per_row == 0 %}
</div>
{% assign row_count = row_count | plus: 1 %}
{% if row_count <= total_rows %}
<div class="related-product-row">
{% endif %}
{% endif %}
{% assign count_product_main = count_product_main | plus: 1 %}
{% endif %}
{% endfor %}
</div>
</div>
</div>
{% endif %}
</div>
{% endfor %}
`
I cant understand and resolve this error in this code
`Liquid syntax error (snippets/gp-product-related line 57): Expected end_of_string but found pipe in "count_product_main | modulo: product_per_row == 0"
Any kind of help will be very thankful.
`
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The report points to snippets/gp-product-related at line 57 and includes the failing Liquid expression. Read that expression and the surrounding conditional syntax; done would require a confirmed explanation or correction, but no repository change or test is specified.
Written by the indexing model from the issue text.
Assessment
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100