Module: Spree::ProductsHelper

Defined in:
app/helpers/spree/products_helper.rb

Instance Method Summary collapse

Instance Method Details

#get_taxonomiesObject



29
30
31
# File 'app/helpers/spree/products_helper.rb', line 29

def get_taxonomies
  @taxonomies ||= Spree::Taxonomy.includes(:root => :children)
end

#line_item_description(variant) ⇒ Object



20
21
22
23
24
25
26
27
# File 'app/helpers/spree/products_helper.rb', line 20

def line_item_description(variant)
  description = variant.product.description
  if description.present?
    truncate(strip_tags(description.gsub(' ', ' ')), :length => 100)
  else
    t(:product_has_no_description)
  end
end

#product_description(product) ⇒ Object

converts line breaks in product description into <p> tags (for html display purposes)



16
17
18
# File 'app/helpers/spree/products_helper.rb', line 16

def product_description(product)
  raw(product.description.gsub(/(.*?)\r?\n\r?\n/m, '<p>\1</p>'))
end

#variant_price_diff(variant) ⇒ Object

returns the formatted change in price (from the master price) for the specified variant (or simply return the variant price if no master price was supplied)



5
6
7
8
9
10
11
12
13
# File 'app/helpers/spree/products_helper.rb', line 5

def variant_price_diff(variant)
  diff = variant.price - variant.product.price
  return nil if diff == 0
  if diff > 0
    "(#{t(:add)}: #{Spree::Money.new(diff.abs)})"
  else
    "(#{t(:subtract)}: #{Spree::Money.new(diff.abs)})"
  end
end