Sha256: 86ed9e12ac3e69fe5bf20de40074e6c9224358dfd03f00f71278590403bf13a4

Contents?: true

Size: 553 Bytes

Versions: 100

Compression:

Stored size: 553 Bytes

Contents

module Spree
  module Cart
    class SetQuantity
      prepend Spree::ServiceModule::Base

      def call(order:, line_item:, quantity: nil)
        ActiveRecord::Base.transaction do
          run :change_item_quantity
          run Spree::Dependencies.cart_recalculate_service.constantize
        end
      end

      private

      def change_item_quantity(order:, line_item:, quantity: nil)
        return failure(line_item) unless line_item.update(quantity: quantity)

        success(order: order, line_item: line_item)
      end
    end
  end
end

Version data entries

100 entries across 100 versions & 1 rubygems

Version Path
spree_core-3.7.10 app/services/spree/cart/set_quantity.rb
spree_core-4.0.3 app/services/spree/cart/set_quantity.rb
spree_core-3.7.9 app/services/spree/cart/set_quantity.rb
spree_core-4.0.2 app/services/spree/cart/set_quantity.rb
spree_core-3.7.8 app/services/spree/cart/set_quantity.rb
spree_core-4.0.1 app/services/spree/cart/set_quantity.rb
spree_core-3.7.7 app/services/spree/cart/set_quantity.rb
spree_core-4.0.0 app/services/spree/cart/set_quantity.rb
spree_core-4.0.0.rc3 app/services/spree/cart/set_quantity.rb
spree_core-3.7.6 app/services/spree/cart/set_quantity.rb
spree_core-3.7.5 app/services/spree/cart/set_quantity.rb
spree_core-4.0.0.rc2 app/services/spree/cart/set_quantity.rb
spree_core-4.0.0.rc1 app/services/spree/cart/set_quantity.rb
spree_core-4.0.0.beta app/services/spree/cart/set_quantity.rb
spree_core-3.7.4 app/services/spree/cart/set_quantity.rb
spree_core-3.7.3 app/services/spree/cart/set_quantity.rb
spree_core-3.7.2 app/services/spree/cart/set_quantity.rb
spree_core-3.7.1 app/services/spree/cart/set_quantity.rb
spree_core-3.7.0 app/services/spree/cart/set_quantity.rb
spree_core-3.7.0.rc3 app/services/spree/cart/set_quantity.rb