Sha256: 62510335cc6a7b9689af891f3d1d036deb0fa96473db9af3b179aa8faeb214ef

Contents?: true

Size: 778 Bytes

Versions: 3

Compression:

Stored size: 778 Bytes

Contents

# frozen_string_literal: true

module SolidusLegacyPromotions
  module SpreeOrderDecorator
    module ClassMethods
      def allowed_ransackable_associations
        super + ["promotions", "order_promotions"]
      end
    end

    def self.prepended(base)
      base.has_many :order_promotions, class_name: 'Spree::OrderPromotion', dependent: :destroy
      base.has_many :promotions, through: :order_promotions
    end

    def apply_shipping_promotions(_event = nil)
      Spree::Config.promotions.shipping_promotion_handler_class.new(self).activate
      recalculate
    end

    def shipping_discount
      shipment_adjustments.credit.eligible.sum(:amount) * - 1
    end

    Spree::Order.prepend(self)
    Spree::Order.singleton_class.prepend self::ClassMethods
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
solidus_legacy_promotions-4.4.2 app/decorators/solidus_legacy_promotions/models/spree_order_decorator.rb
solidus_legacy_promotions-4.4.1 app/decorators/solidus_legacy_promotions/models/spree_order_decorator.rb
solidus_legacy_promotions-4.4.0 app/decorators/solidus_legacy_promotions/models/spree_order_decorator.rb