Sha256: bb5668ee246346cd07589914a5192ee7d8424c04c5b40122c540ce022d7f7ef2
Contents?: true
Size: 837 Bytes
Versions: 2
Compression:
Stored size: 837 Bytes
Contents
module Spree module ProductsHelper # returns the formatted change in price (from the master price) for the specified variant (or simply return # the variant price if no master price was supplied) def variant_price_diff(variant) diff = variant.price - variant.product.price return nil if diff == 0 if diff > 0 "(#{t(:add)}: #{number_to_currency diff.abs})" else "(#{t(:subtract)}: #{number_to_currency diff.abs})" end end # converts line breaks in product description into <p> tags (for html display purposes) def product_description(product) raw(product.description.gsub(/(.*?)\n\n/m, '<p>\1</p>\n\n')) end def variant_images_hash(product) product.variant_images.inject({}) { |h, img| (h[img.viewable_id] ||= []) << img; h } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spree_core-1.1.2 | app/helpers/spree/products_helper.rb |
spree_core-1.1.2.rc1 | app/helpers/spree/products_helper.rb |