Sha256: 55b883ca0aa874ead841eac326e53083187994efec4f89004eb56f6ff8a0fe21
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
Spree::Variant.class_eval do delegate :bottle_size, :default_case, :default_wholesale_case_price, :percent_alcohol, :varietal, :vintage, :volume_amount, :volume_unit, to: :product def brand_key brand = product.taxons.joins(:taxonomy).find_by(spree_taxonomies: { name: 'Brand' }) brand.try(:brand_key) end def product_key [sku, option_values_ids].compact.join('-') end ## # Ship Compliant necessary attributes: # # bottle_size: 750ml # default_case: 12 # default_wholesale_case_price: 670 # percent_alcohol: 5% # varietal: 'Cabernet Sauvignon' # vintage: 2003 # volume_amount: 750 # volume_unit: milliliter ## def bottle_size product.option_types.find_by(presentation: 'Bottle Size').try(:presentation) end def default_case product.property('default_case') || 1 end def default_wholesale_case_price product.property('default_wholesale_case_price') end def percent_alcohol product.property('percent_alcohol') end def varietal product.property('varietal') end def vintage product.property('vintage') end def volume_amount product.property('volume_amount') end def volume_unit product.property('volume_unit') end private def option_values_ids values = option_values.includes(:option_type).sort_by do |option_value| option_value.option_type.position end values.to_a.map! do |ov| "#{ov.id}" end values.any? ? values.join('-') : nil end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
solidus_ship_compliant-1.0.0 | app/models/spree/variant_decorator.rb |