Sha256: 2b6cdf5e1b78f0c58e8f9cefa8f688301f1b51bf851200c9065cb69214285f5a

Contents?: true

Size: 633 Bytes

Versions: 1

Compression:

Stored size: 633 Bytes

Contents

module PiggybakVariantsHelper
  def variant_cart_form(object, options = {:controls => 'radio_buttons'})
    render "piggybak_variants/cart/#{options[:controls]}_form", :object => object
  end

  def options_for_klass(klass)
    options = ::PiggybakVariants::OptionConfiguration.where(klass: klass).collect { |oc| oc.option }
  end

  def variant_map(object)
    map = {}
    object.variants.available.each do |variant|
      map[variant.option_values.hash_ordered.map { |ov| ov.id }.join('_')] = { :id => variant.piggybak_sellable.id, :price => number_to_currency(variant.piggybak_sellable.price) }
    end
    map.to_json
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
piggybak_variants-0.1.1 app/helpers/piggybak_variants_helper.rb