Sha256: 00d9bc5483eb5b78c9df24485acfbb9eb2a5ec1566c7153a235334deffb2713d
Contents?: true
Size: 773 Bytes
Versions: 20
Compression:
Stored size: 773 Bytes
Contents
module Spree class Promotion module Actions class CreateItemAdjustments < PromotionAction include Spree::CalculatedAdjustments include Spree::AdjustmentSource before_validation -> { self.calculator ||= Calculator::PercentOnLineItem.new } def perform(options = {}) order = options[:order] promotion = options[:promotion] create_unique_adjustments(order, order.line_items) do |line_item| promotion.line_item_actionable?(order, line_item) end end def compute_amount(line_item) return 0 unless promotion.line_item_actionable?(line_item.order, line_item) [line_item.amount, compute(line_item)].min * -1 end end end end end
Version data entries
20 entries across 20 versions & 1 rubygems