Sha256: a949f821d8d4d3665a1479219c275d6a259b47edb6ad6d0ae3e923d6884c8836

Contents?: true

Size: 792 Bytes

Versions: 66

Compression:

Stored size: 792 Bytes

Contents

module Spree
  module PromotionHandler
    # Used for activating promotions with shipping rules
    class FreeShipping
      attr_reader :order, :order_promo_ids
      attr_accessor :error, :success

      def initialize(order)
        @order = order
        @order_promo_ids = order.promotions.pluck(:id)
      end

      def activate
        promotions.each do |promotion|
          next if promotion.code.present? && !order_promo_ids.include?(promotion.id)

          if promotion.eligible?(order)
            promotion.activate(order: order)
          end
        end
      end

      private

      def promotions
        Spree::Promotion.active.where(
          id: Spree::Promotion::Actions::FreeShipping.pluck(:promotion_id),
          path: nil
        )
      end
    end
  end
end

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
spree_core-3.2.9 app/models/spree/promotion_handler/free_shipping.rb
spree_core-3.1.14 app/models/spree/promotion_handler/free_shipping.rb
spree_core-3.3.6 app/models/spree/promotion_handler/free_shipping.rb
spree_core-3.2.8 app/models/spree/promotion_handler/free_shipping.rb
spree_core-3.1.13 app/models/spree/promotion_handler/free_shipping.rb
spree_core-3.3.5 app/models/spree/promotion_handler/free_shipping.rb
spree_core-3.3.4 app/models/spree/promotion_handler/free_shipping.rb
spree_core-3.2.7 app/models/spree/promotion_handler/free_shipping.rb
spree_core-3.1.12 app/models/spree/promotion_handler/free_shipping.rb
spree_core-3.3.3 app/models/spree/promotion_handler/free_shipping.rb
spree_core-3.2.6 app/models/spree/promotion_handler/free_shipping.rb
spree_core-3.1.11 app/models/spree/promotion_handler/free_shipping.rb
spree_core-3.1.10 app/models/spree/promotion_handler/free_shipping.rb
spree_core-3.3.2 app/models/spree/promotion_handler/free_shipping.rb
spree_core-3.2.5 app/models/spree/promotion_handler/free_shipping.rb
spree_core-3.1.9 app/models/spree/promotion_handler/free_shipping.rb
spree_core-3.3.1 app/models/spree/promotion_handler/free_shipping.rb
spree_core-3.2.4 app/models/spree/promotion_handler/free_shipping.rb
spree_core-3.1.8 app/models/spree/promotion_handler/free_shipping.rb
spree_core-3.3.0 app/models/spree/promotion_handler/free_shipping.rb