Sha256: 52e29cfd68385521ec9d5580c73b7712ed95f481bc2deeab7e15550d7d43037d
Contents?: true
Size: 1.11 KB
Versions: 12
Compression:
Stored size: 1.11 KB
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 # returns the price of the product to show for display purposes def product_price(product_or_variant, options={}) ActiveSupport::Deprecation.warn('product_price is deprecated and no longer calculates tax. Use number_to_currency instead.', caller) end # converts line breaks in product description into <p> tags (for html display purposes) def product_description(product) raw(product.description.gsub(/^(.*)$/, '<p>\1</p>')) end def variant_images_hash(product) product.variant_images.inject({}) { |h, img| (h[img.viewable_id] ||= []) << img; h } end end end
Version data entries
12 entries across 12 versions & 1 rubygems