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.

Storefront: PDP page

Damian Legawiec0a90d225c43b
diff --git a/core/app/models/spree/product.rb b/core/app/models/spree/product.rb
index ee0a5669a7..37e0df7d21 100644
--- a/core/app/models/spree/product.rb
+++ b/core/app/models/spree/product.rb
@@ -396,6 +396,12 @@ module Spree
end
end
+ # Returns the short description for the product
+ # @return [String]
+ def storefront_description
+ property('short_description') || description
+ end
+
# Returns tax category for Product
# @return [Spree::TaxCategory]
def tax_category
diff --git a/core/config/locales/en.yml b/core/config/locales/en.yml
index 2e14bd74ee..c415a393bd 100644
--- a/core/config/locales/en.yml
+++ b/core/config/locales/en.yml
@@ -1599,6 +1599,7 @@ en:
seo: SEO
seo_robots: SEO Robots
seo_title: SEO Title
+ search_results_for: "Search results for ${query}"
server: Server
server_error: The server returned an error
settings: Settings
diff --git a/storefront/app/controllers/spree/products_controller.rb b/storefront/app/controllers/spree/products_controller.rb
index 534a77c11a..46ae479056 100644
--- a/storefront/app/controllers/spree/products_controller.rb
+++ b/storefront/app/controllers/spree/products_controller.rb
@@ -34,7 +34,7 @@ module Spree
load_product if action_name == 'show' # we need this for ahoy analytics
if @product
- @product.meta_title.blank? ? [@product.vendor&.display_name, @product.name].compact.join(' ') : @product.meta_title
+ @product.meta_title.blank? ? @product.name : @product.meta_title
else
params[:q].present? ? Spree.t(:search_results_for, query: params[:q]) : Spree.t(:shop_all)
end
diff --git a/storefront/app/helpers/spree/products_helper.rb b/storefront/app/helpers/spree/products_helper.rb
index 8342bb2a0f..ede0805063 100644
--- a/storefront/app/helpers/spree/products_helper.rb
+++ b/storefront/app/helpers/spree/products_helper.rb
@@ -194,5 +194,11 @@ module Spree
json_ld
end
+
+ def option_type_colors_preview_styles(option_type)
+ return unless option_type.color?
+
+ Spree::ColorsPreviewStylesPresenter.new(option_type.option_values.map { |ov| { name: ov.name, filter_name: ov.name } }).to_s
+ end
end
end
diff --git a/storefront/app/views/themes/default/spree/page_sections/_featured_product.html.erb b/storefront/app/views/themes/default/spree/page_sections/_featured_product.html.erb
index 98061f6662..f9bb7551c2 100644
--- a/storefront/app/views/themes/default/spree/page_sections/_featured_product.html.erb
+++ b/storefront/app/views/themes/default/spree/page_sections/_featured_product.html.erb
@@ -124,7 +124,7 @@
<% end %>
<% end %>
<% end %>
- <%= render('spree/products/add_to_waitlist', variant: current_variant) if current_variant.present? %>
+ <%= render('spree/products/add_to_waitlist', variant: current_variant) if spree.respond_to?(:waitlist_path) && current_variant.present? %>
</div>
</div>
</div>
diff --git a/storefront/app/views/themes/default/spree/page_sections/_product_details.html.erb b/storefront/app/views/themes/default/spree/page_sections/_product_details.html.erb
index 1b229bedb1..f73241df49 100644
--- a/storefront/app/views/themes/default/spree/page_sections/_product_details.html.erb
+++ b/storefront/app/views/themes/default/spree/page_sections/_product_details.html.erb
@@ -85,7 +85,7 @@
<%= render 'spree/products/add_to_wishlist', variant: current_variant, css_classes: 'btn-secondary ml-5 h-12 !py-0 !px-3 border-default', icon_size: 24 %>
</div>
<% end %>
- <%= render 'spree/products/add_to_waitlist', variant: current_variant %>
+ <%= render 'spree/products/add_to_waitlist', variant: current_variant if spree.respond_to?(:waitlist_path) && current_variant.present? %>
</div>
<%= render 'spree/products/details', product: product %>
diff --git a/storefront/app/views/themes/default/spree/products/_variant_picker.html.erb b/storefront/app/views/themes/default/spree/products/_variant_picker.html.erb
index 3cb6efc573..b1d1d28d2c 100644
--- a/storefront/app/views/themes/default/spree/products/_variant_picker.html.erb
+++ b/storefront/app/views/themes/default/spree/products/_variant_picker.html.erb
@@ -4,7 +4,7 @@
<% product.option_types.each_with_index do |option_type, index| %>
<% selected_option = product_selected_option_for_option(option_type, product: product, selected_variant: selected_variant, options_param_name: options_param_name) %>
<% if option_type.color? %>
- <%= option_type.colors_preview_styles.html_safe %>
+ <%= option_type_colors_preview_styles(option_type).html_safe %>
<fieldset data-option-id="<%= option_type.id %>" class="flex flex-col gap-y-2">
<span class="text-sm leading-4 uppercase tracking-widest"><%= option_type.presentation %>: <%= selected_option.presentation %></span>
<ul class="flex items-center flex-wrap gap-1">