Sha256: d2bb57a8e243427e3eec840fea193ec73721ca98129311479129429cf9407ef3
Contents?: true
Size: 1.29 KB
Versions: 10
Compression:
Stored size: 1.29 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? format('%.2f', 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? format('%.2f', 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
10 entries across 10 versions & 1 rubygems