Class: Spree::StockReservations::Extend

Inherits:
Object
  • Object
show all
Includes:
Spree::ServiceModule::Base
Defined in:
app/services/spree/stock_reservations/extend.rb

Instance Method Summary collapse

Methods included from Spree::ServiceModule::Base

prepended

Instance Method Details

#call(order:) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'app/services/spree/stock_reservations/extend.rb', line 6

def call(order:)
  return success(order) unless Spree::Config[:stock_reservations_enabled]

  expires_at = Time.current + Spree::StockReservation.ttl_for(order)

  Spree::StockReservation
    .where(order_id: order.id)
    .update_all(expires_at: expires_at, updated_at: Time.current)

  success(order)
end