Module: CartHelper
- Defined in:
- app/helpers/cart_helper.rb
Overview
Methods for display Cart (in totality, by product, …).
Instance Method Summary collapse
-
#link_to_add_cart(product, name = 'add_to_cart', url = {:controller => 'cart', :action => 'add_product'}, options = nil) ⇒ Object
Extension of link_to(name, options = {}, html_options = nil) with a Product object of first parameter.
-
#link_to_cart(name = I18n.t('cart', :count => 1), url = {:controller => 'cart'}, options = nil) ⇒ Object
Extension of link_to(name, options = {}, html_options = nil).
-
#link_to_cart_empty(mini = false, name = I18n.t('empty_cart').capitalize, url = {:controller => 'cart', :action => 'empty'}, options = {:confirm => I18n.t(:confirm_empty_cart)}) ⇒ Object
Extension of link_to(name, options = {}, html_options = nil).
Instance Method Details
#link_to_add_cart(product, name = 'add_to_cart', url = {:controller => 'cart', :action => 'add_product'}, options = nil) ⇒ Object
Extension of link_to(name, options = {}, html_options = nil) with a Product object of first parameter
Parameters
-
:product
- a Product object -
:name
- name, <i> -
:url
- url, => ‘cart’, :action => ‘add_product’ by default -
options
the html options
37 38 39 |
# File 'app/helpers/cart_helper.rb', line 37 def link_to_add_cart(product, name='add_to_cart', url={:controller => 'cart', :action => 'add_product'}, =nil) link_to I18n.t(name).capitalize, url.merge({:id => product.id}), end |
#link_to_cart(name = I18n.t('cart', :count => 1), url = {:controller => 'cart'}, options = nil) ⇒ Object
Extension of link_to(name, options = {}, html_options = nil)
Parameters
-
:name
- name, “Cart” by default -
:url
- url, => ‘cart’ by default -
options
the html options
23 24 25 26 27 28 |
# File 'app/helpers/cart_helper.rb', line 23 def link_to_cart(name=I18n.t('cart', :count => 1), url={:controller => 'cart'}, =nil) #unless cart.nil? # name = "#{name} (#{cart.size} #{I18n.t('product', :count => cart.size)})" #end link_to name.capitalize, {:controller => 'cart'}, end |
#link_to_cart_empty(mini = false, name = I18n.t('empty_cart').capitalize, url = {:controller => 'cart', :action => 'empty'}, options = {:confirm => I18n.t(:confirm_empty_cart)}) ⇒ Object
Extension of link_to(name, options = {}, html_options = nil)
Parameters
-
:name
- name -
:url
- url, => ‘cart’, :action => ‘empty’ by default -
options
the html options
9 10 11 12 13 14 15 |
# File 'app/helpers/cart_helper.rb', line 9 def link_to_cart_empty(mini=false,name=I18n.t('empty_cart').capitalize, url={:controller => 'cart', :action => 'empty'}, ={:confirm => I18n.t(:confirm_empty_cart)}) if mini link_to_remote name, { :update => 'cart', :url => url }.merge() else link_to name, url, end end |