Module: SolidusVolumePricing::Spree::BaseHelperDecorator

Defined in:
app/decorators/helpers/solidus_volume_pricing/spree/base_helper_decorator.rb

Class Method Summary collapse

Class Method Details

.prepended(base) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/decorators/helpers/solidus_volume_pricing/spree/base_helper_decorator.rb', line 6

def self.prepended(base)
  base.module_eval do
    def display_volume_price(variant, quantity = 1, user = nil)
      price_display(variant, quantity: quantity, user: user).price_string
    end

    def display_volume_price_earning_percent(variant, quantity = 1, user = nil)
      price_display(variant, quantity: quantity, user: user).earning_percent_string
    end

    def display_volume_price_earning_amount(variant, quantity = 1, user = nil)
      price_display(variant, quantity: quantity, user: user).earning_amount_string
    end

    private

    def price_display(variant, quantity:, user:)
      SolidusVolumePricing::PriceDisplay.new(variant, quantity: quantity, user: user)
    end
  end
end