Module: Bodega::CartHelper

Defined in:
app/helpers/bodega/cart_helper.rb

Instance Method Summary collapse

Instance Method Details

#button_to_cart(product, label = 'Add to Cart', options = {}, &block) ⇒ Object



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

def button_to_cart(product, label = 'Add to Cart', options = {}, &block)
  unless options.key? :disabled
    options[:disabled] = !product.in_stock?
  end
  form_contents = hidden_field_tag('order_product[product_type]', product.class)
  form_contents << hidden_field_tag('order_product[product_id]', product.id) +
  if block_given?
    form_contents << capture(&block)
  end
  form_contents << button_tag(label, options)
  form_tag(bodega.add_to_order_path) { form_contents }
end