Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "Maximum Products to Show" setting to Product Recommendations section #1429

Merged
merged 7 commits into from Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions locales/en.default.schema.json
Expand Up @@ -2257,6 +2257,9 @@
"heading": {
"label": "Heading"
},
"products_to_show": {
"label": "Maximum products to show"
},
"columns_desktop": {
"label": "Number of columns on desktop"
},
Expand Down
13 changes: 11 additions & 2 deletions sections/product-recommendations.liquid
Expand Up @@ -21,7 +21,7 @@
{%- endstyle -%}

<div class="color-{{ section.settings.color_scheme }} gradient">
<product-recommendations class="product-recommendations page-width section-{{ section.id }}-padding isolate" data-url="{{ routes.product_recommendations_url }}?section_id={{ section.id }}&product_id={{ product.id }}&limit=4">
<product-recommendations class="product-recommendations page-width section-{{ section.id }}-padding isolate" data-url="{{ routes.product_recommendations_url }}?section_id={{ section.id }}&product_id={{ product.id }}&limit={{ section.settings.products_to_show }}">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I am requesting the number of products directly here instead of always requesting the max of 10 and then using the merchants setting to define how many to show is to avoid requesting more than what the merchant needs to request in their store

{% if recommendations.performed and recommendations.products_count > 0 %}
<h2 class="product-recommendations__heading {{ section.settings.heading_size }}">{{ section.settings.heading | escape }}</h2>
<ul class="grid product-grid{% if section.settings.columns_desktop == 1 %} grid--full-width{% else %} grid--{{ section.settings.columns_desktop }}-col-desktop{% endif %} grid--{{ section.settings.columns_mobile }}-col-tablet-down" role="list">
Expand Down Expand Up @@ -113,11 +113,20 @@
"default": "h1",
"label": "t:sections.all.heading_size.label"
},
{
"type": "range",
"id": "products_to_show",
"min": 2,
"max": 10,
"step": 1,
"default": 4,
"label": "t:sections.product-recommendations.settings.products_to_show.label"
},
{
"type": "range",
"id": "columns_desktop",
"min": 1,
"max": 4,
"max": 5,
"step": 1,
"default": 4,
"label": "t:sections.product-recommendations.settings.columns_desktop.label"
Expand Down