Module: Spree::BaseHelper
- Defined in:
- app/helpers/spree/base_helper.rb
Instance Method Summary collapse
- #link_to_cart(text = t('cart')) ⇒ Object
- #logo(image_path = ) ⇒ Object
- #meta_data_tags ⇒ Object
- #order_price(order, options = {}) ⇒ Object
- #stylesheet_paths ⇒ Object
- #stylesheet_tags(paths = stylesheet_paths) ⇒ Object
- #todays_short_date ⇒ Object
-
#variant_options(v, allow_back_orders = , include_style = true) ⇒ Object
human readable list of variant options.
- #yesterdays_short_date ⇒ Object
Instance Method Details
#link_to_cart(text = t('cart')) ⇒ Object
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 logo(image_path=Spree::Config[:logo]) link_to image_tag(image_path), root_path end |
#meta_data_tags ⇒ Object
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 || if object.respond_to?(:meta_keywords) and object..present? << tag('meta', :name => 'keywords', :content => object.) + "\n" end if object.respond_to?(:meta_description) and object..present? << tag('meta', :name => 'description', :content => object.) + "\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, ={}) .assert_valid_keys(:format_as_currency, :show_vat_text, :show_price_inc_vat) .reverse_merge! :format_as_currency => true, :show_vat_text => true # overwrite show_vat_text if show_price_inc_vat is false [: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] .delete(:format_as_currency) ? number_to_currency(amount) : amount end |
#stylesheet_paths ⇒ Object
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 (paths=stylesheet_paths) paths.blank? ? '' : stylesheet_link_tag(paths, :cache => true) end |
#todays_short_date ⇒ Object
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 (v, allow_back_orders = Spree::Config[:allow_backorders], include_style = true) list = v. 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_date ⇒ Object
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 |