PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, June 30, 2022

[FIXED] How to count current showing products in Shopify 2.0 dawn theme?

 June 30, 2022     filter, html, liquid, pagination, shopify     No comments   

Issue

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


Solution

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 -%}



Answered By - Anupam Mistry
Answer Checked By - Willingham (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing