Sha256: 251e22433d4bf87b5e53f83ca2cd30ab336c1ea4b58d7465cdeddfd4d4c75967
Contents?: true
Size: 765 Bytes
Versions: 30
Compression:
Stored size: 765 Bytes
Contents
module Spree module Cart class Destroy prepend Spree::ServiceModule::Base def call(order:) run :check_if_can_be_destroyed run :cancel_shipments run :void_payments run :destroy_order end private def check_if_can_be_destroyed(order:) return failure(Spree.t(:cannot_be_destroyed)) unless order&.can_be_destroyed? success(order: order) end def cancel_shipments(order:) order.shipments.each(&:cancel!) success(order: order) end def void_payments(order:) order.payments.each(&:void!) success(order: order) end def destroy_order(order:) order.destroy success(order) end end end end
Version data entries
30 entries across 30 versions & 1 rubygems