Sha256: aa8c0633b8425d25f623cd90004a19662fc022d494894e04efe4b27080acd55b

Contents?: true

Size: 521 Bytes

Versions: 2

Compression:

Stored size: 521 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::Cart::Recalculate
        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

2 entries across 2 versions & 1 rubygems

Version Path
spree_core-3.7.0.rc2 app/services/spree/cart/set_quantity.rb
spree_core-3.7.0.rc1 app/services/spree/cart/set_quantity.rb