Sha256: a3fed56c9175edf31ab3a20311558ddab190651039db0ed6bc3a936512e2d50a
Contents?: true
Size: 1.15 KB
Versions: 88
Compression:
Stored size: 1.15 KB
Contents
module Spree class ShipmentHandler class << self def factory(shipment) # Do we have a specialized shipping-method-specific handler? e.g: # Given shipment.shipping_method = Spree::ShippingMethod::DigitalDownload # do we have Spree::ShipmentHandler::DigitalDownload? if sm_handler = "Spree::ShipmentHandler::#{shipment.shipping_method.name.split('::').last}".safe_constantize sm_handler.new(shipment) else new(shipment) end end end def initialize(shipment) @shipment = shipment end def perform @shipment.inventory_units.each &:ship! @shipment.process_order_payments if Spree::Config[:auto_capture_on_dispatch] @shipment.touch :shipped_at update_order_shipment_state send_shipped_email end private def send_shipped_email ShipmentMailer.shipped_email(@shipment.id).deliver_later end def update_order_shipment_state order = @shipment.order new_state = OrderUpdater.new(order).update_shipment_state order.update_columns(shipment_state: new_state, updated_at: Time.current) end end end
Version data entries
88 entries across 88 versions & 1 rubygems