Sha256: bce32618415599395a1b6d455fa0de4df66cac9762871b20f7d648577033a577
Contents?: true
Size: 846 Bytes
Versions: 17
Compression:
Stored size: 846 Bytes
Contents
module Spree class WishedItem < Spree::Base if defined?(Spree::Webhooks) include Spree::Webhooks::HasWebhooks end extend DisplayMoney money_methods :total, :price belongs_to :variant, class_name: 'Spree::Variant' belongs_to :wishlist, class_name: 'Spree::Wishlist' has_one :product, class_name: 'Spree::Product', through: :variant validates :variant, :wishlist, presence: true validates :variant, uniqueness: { scope: [:wishlist] } validates :quantity, numericality: { only_integer: true, greater_than: 0 } def price(currency) variant.amount_in(currency[:currency]) end def total(currency) variant_price = variant.amount_in(currency[:currency]) if variant_price.nil? variant_price else quantity * variant_price end end end end
Version data entries
17 entries across 17 versions & 1 rubygems