Class: Spree::Promotion::Actions::CreateQuantityAdjustments::PartialLineItem

Inherits:
Object
  • Object
show all
Defined in:
app/models/spree/promotion/actions/create_quantity_adjustments.rb

Overview

Used specifically for PercentOnLineItem calculator. That calculator uses ‘line_item.amount`, however we might not necessarily want to discount the entire amount. This class allows us to determine the discount per quantity and then calculate the adjustment amount the way we normally do for flat rate adjustments.

Instance Method Summary collapse

Constructor Details

#initialize(line_item) ⇒ PartialLineItem

Returns a new instance of PartialLineItem.



124
125
126
# File 'app/models/spree/promotion/actions/create_quantity_adjustments.rb', line 124

def initialize(line_item)
  @line_item = line_item
end

Instance Method Details

#amountObject



128
129
130
# File 'app/models/spree/promotion/actions/create_quantity_adjustments.rb', line 128

def amount
  @line_item.price
end

#currencyObject



136
137
138
# File 'app/models/spree/promotion/actions/create_quantity_adjustments.rb', line 136

def currency
  @line_item.currency
end

#orderObject



132
133
134
# File 'app/models/spree/promotion/actions/create_quantity_adjustments.rb', line 132

def order
  @line_item.order
end