Module: Spree::BaseHelper

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

Instance Method Summary collapse

Instance Method Details



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

def link_to_cart(text = t('cart'))
  return "" if current_page?(cart_path)
  css_class = nil
  if current_order.nil? or current_order.line_items.empty?
    text = "#{text}: (#{t('empty')})"
    css_class = 'empty'
  else
    text = "#{text}: (#{current_order.item_count}) #{order_price(current_order)}"
    css_class = 'full'
  end
  link_to text, cart_path, :class => css_class
end

#logo(image_path = ) ⇒ Object



83
84
85
# File 'app/helpers/spree/base_helper.rb', line 83

def (image_path=Spree::Config[:logo])
  link_to image_tag(image_path), root_path
end

#meta_data_tagsObject



58
59
60
61
62
63
64
65
66
67
68
# File 'app/helpers/spree/base_helper.rb', line 58

def 
  return unless self.respond_to?(:object) && object
  "".tap do |tags|
    if object.respond_to?(:meta_keywords) and object.meta_keywords.present?
      tags << tag('meta', :name => 'keywords', :content => object.meta_keywords) + "\n"
    end
    if object.respond_to?(:meta_description) and object.meta_description.present?
      tags << tag('meta', :name => 'description', :content => object.meta_description) + "\n"
    end
  end
end

#order_price(order, options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/helpers/spree/base_helper.rb', line 16

def order_price(order, options={})
  options.assert_valid_keys(:format_as_currency, :show_vat_text, :show_price_inc_vat)
  options.reverse_merge! :format_as_currency => true, :show_vat_text => true

  # overwrite show_vat_text if show_price_inc_vat is false
  options[:show_vat_text] = Spree::Config[:show_price_inc_vat]

  amount =  order.item_total
  amount += Calculator::Vat.calculate_tax(order) if Spree::Config[:show_price_inc_vat]

  options.delete(:format_as_currency) ? number_to_currency(amount) : amount
end

#stylesheet_pathsObject



74
75
76
77
78
79
80
81
# File 'app/helpers/spree/base_helper.rb', line 74

def stylesheet_paths
  paths = Spree::Config[:stylesheets]
  if (paths.blank?)
    []
  else
    paths.split(',')
  end
end

#stylesheet_tags(paths = stylesheet_paths) ⇒ Object



70
71
72
# File 'app/helpers/spree/base_helper.rb', line 70

def stylesheet_tags(paths=stylesheet_paths)
  paths.blank? ? '' : stylesheet_link_tag(paths, :cache => true)
end

#todays_short_dateObject



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

def todays_short_date
  utc_to_local(Time.now.utc).to_ordinalized_s(:stub)
end

#variant_options(v, allow_back_orders = , include_style = true) ⇒ Object

human readable list of variant options



39
40
41
42
43
# File 'app/helpers/spree/base_helper.rb', line 39

def variant_options(v, allow_back_orders = Spree::Config[:allow_backorders], include_style = true)
  list = v.options_text
  list = include_style ? "<span class =\"out-of-stock\">(" + t("out_of_stock") + ") #{list}</span>" : "#{t("out_of_stock")} #{list}" unless (allow_back_orders || v.in_stock?)
  list
end

#yesterdays_short_dateObject



33
34
35
# File 'app/helpers/spree/base_helper.rb', line 33

def yesterdays_short_date
  utc_to_local(Time.now.utc.yesterday).to_ordinalized_s(:stub)
end