Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

V-3066 ADD No results text for products (#12717)

brozeka81803af59c2
diff --git a/core/config/locales/en.yml b/core/config/locales/en.yml
index 12228dd744..e72d454878 100644
--- a/core/config/locales/en.yml
+++ b/core/config/locales/en.yml
@@ -2145,6 +2145,7 @@ en:
translations_for: "%{resource_name} translations"
tree: Tree
true_label: 'TRUE'
+ try_removing_filters: Try removing some filters to see more products
twitter: Twitter
type: Type
type_to_search: Type to search
diff --git a/storefront/app/views/themes/default/spree/page_sections/_product_grid.html.erb b/storefront/app/views/themes/default/spree/page_sections/_product_grid.html.erb
index c2c1e81cf9..0a40b611a9 100644
--- a/storefront/app/views/themes/default/spree/page_sections/_product_grid.html.erb
+++ b/storefront/app/views/themes/default/spree/page_sections/_product_grid.html.erb
@@ -37,16 +37,23 @@
</div>
</div>
- <% if products %>
- <div style='<%= section_styles(section) %>'>
- <div class='page-container'>
- <div class='grid gap-y-8 gap-x-4 grid-cols-2 lg:grid-cols-4 lg:gap-x-6 lg:gap-y-10 mb-7' id='products'>
+ <div style="<%= section_styles(section) %>">
+ <div class="page-container">
+ <% if products.any? %>
+ <div class="grid gap-y-8 gap-x-4 grid-cols-2 lg:grid-cols-4 lg:gap-x-6 lg:gap-y-10 mb-7" id="products">
<%= render 'spree/shared/products', products: products %>
</div>
- </div>
- <%= render 'spree/products/show_more_button' %>
- </div>
- <%= render 'spree/products/json_ld_list', products: products unless turbo_frame_request? %>
- <% end %>
+ <%= render 'spree/products/show_more_button' %>
+ <%= render('spree/products/json_ld_list', products: products) unless turbo_frame_request? %>
+ <% else %>
+ <div class="grid">
+ <div class="text-center py-10">
+ <h2 class="text-xl font-semibold mb-2"><%= Spree.t(:no_products_found) %></h2>
+ <p class="text-sm"><%= Spree.t(:try_removing_filters) %></p>
+ </div>
+ </div>
+ <% end %>
+ </div>
+ </div>
<% end %>