Module: Spree::BaseHelperDecorator
- Defined in:
- app/helpers/spree/base_helper_decorator.rb
Defined Under Namespace
Classes: ChildTaxonsSection
Constant Summary collapse
- CHILD_TAXONS_SECTION_DEFAULT_PREFERENCES =
{ heading_size: 'medium', heading_alignment: 'center' }.freeze
Instance Method Summary collapse
-
#render_child_taxons_section(taxon, preferences: CHILD_TAXONS_SECTION_DEFAULT_PREFERENCES) ⇒ Object
子カテゴリを「注目カテゴリ」セクションとして描画する。 taxon ページの商品グリッド (_product_grid.html.erb) から呼ばれる。.
- #sort_adjustments_with_flat_percent_last(adjustments) ⇒ Object
Instance Method Details
#render_child_taxons_section(taxon, preferences: CHILD_TAXONS_SECTION_DEFAULT_PREFERENCES) ⇒ Object
子カテゴリを「注目カテゴリ」セクションとして描画する。 taxon ページの商品グリッド (_product_grid.html.erb) から呼ばれる。
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/helpers/spree/base_helper_decorator.rb', line 10 def render_child_taxons_section(taxon, preferences: CHILD_TAXONS_SECTION_DEFAULT_PREFERENCES) return if taxon.blank? children = taxon.children return if children.blank? section = Spree::PageSections::FeaturedTaxons.build (preferences || {}).each do |key, value| section.send("preferred_#{key}=", value) end section.links = children.map do |child| Spree::PageLink.build(label: child.name, linkable: child) end render('spree/page_sections/featured_taxons', section: ChildTaxonsSection.new(section)) end |
#sort_adjustments_with_flat_percent_last(adjustments) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/helpers/spree/base_helper_decorator.rb', line 46 def sort_adjustments_with_flat_percent_last(adjustments) adjustments.sort_by do |adj| if adj.adjustable_type == 'Spree::Order' && adj.source_type == 'Spree::PaymentMethod' 3 elsif adj.source_type == 'Spree::PromotionAction' && adj.source&.calculator&.is_a?(Spree::Calculator::FlatPercentOrderTotal) 2 elsif adj.source_type == 'Spree::PromotionAction' 1 else 0 end end end |