如何计算当前在Shopify 2.0 Dawn主题中显示产品的当前?

发布于 2025-01-26 01:57:50 字数 588 浏览 3 评论 0 原文

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

我想证明当更多产品进入分页时正在显示多少当前产品。


In collection page of dawn(version 5.0.0) theme Shopify, there is and inbuilt functionality to see the total number of products.
enter image description here
I want show that how many current product are showing when more products are getting into pagination.
enter image description here

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

薄荷港 2025-02-02 01:57:50

黎明主题的两个文件中有2个修改。

  1. faceets.liquid 文件中,文件在跨度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. 现在,渲染:facets 用以下代码中的 MAIN-CORCTORTY-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 -%}

There is 2 modification in 2 files of dawn theme.

  1. in facets.liquid file add below code under the 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. now replace render: facets with below code in main-collection-product-grid.liquid file.
{%- 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 -%}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文