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