如何统计Shopify 2.0黎明主题中当前展示的产品?

问题描述 投票:0回答:1

在Dawn(版本5.0.0)主题Shopify的收藏页面中,有内置的功能来查看产品总数。

我想显示当更多产品进入分页时显示了多少当前产品。


html filter pagination shopify liquid
1个回答
0
投票

黎明主题2个文件有2处修改。

  1. facets.liquid
    文件中在 span id
    ProductCountDesktop
    下添加以下代码。
 {% if next_link %}
    {{ offset | plus: 1 }} - {{ offset | plus: page_size }} of 
{% else %} 
    {% capture itemsOnCurrentPage %} 
    {{ results.all_products_count | minus: offset }} 
    {% endcapture %} 
    
    {% if results.all_products_count > 0 %}
        {{ offset | plus: 1 }}
    {% else %}
        {{ offset }}
    {% endif %}
    - {{ offset | plus: itemsOnCurrentPage }} of  
{% endif %} 
  1. 现在将
    render: facets
    替换为
    main-collection-product-grid.liquid
    文件中的以下代码。
{%- paginate collection.products by section.settings.products_per_page -%} 
    {% render 'facets', results: collection, enable_filtering: section.settings.enable_filtering, 
    filter_type: section.settings.filter_type, enable_sorting: section.settings.enable_sorting, collapse_on_larger_devices: section.settings.collapse_on_larger_devices,
    offset : paginate.current_offset,next_link:paginate.next.is_link,page_size:paginate.page_size  %} 
{%- endpaginate -%}
© www.soinside.com 2019 - 2024. All rights reserved.