Sha256: 6b3c6e0e675c684a413b2fbd54e73eaa22fe378fcb2270a9d1ac5f148f0a7505
Contents?: true
Size: 1.26 KB
Versions: 36
Compression:
Stored size: 1.26 KB
Contents
module Spree module Api module V2 module DisplayMoneyHelper extend ActiveSupport::Concern class_methods do def find_price(product_or_variant, currency) product_or_variant.price_in(currency) end def price(product_or_variant, currency) price = find_price(product_or_variant, currency) return nil if price.new_record? price.amount end def display_price(product_or_variant, currency) price = find_price(product_or_variant, currency) return nil if price.new_record? Spree::Money.new(price.amount, currency: currency).to_s end def compare_at_price(product_or_variant, currency) price = find_price(product_or_variant, currency) return nil if price.new_record? || price.compare_at_amount.blank? price.compare_at_amount end def display_compare_at_price(product_or_variant, currency) price = find_price(product_or_variant, currency) return nil if price.new_record? || price.compare_at_amount.blank? Spree::Money.new(price.compare_at_amount, currency: currency).to_s end end end end end end
Version data entries
36 entries across 36 versions & 3 rubygems