public function voidShipment(\FS\Components\Order\ShoppingOrder $order) { $options = $this->getApplicationContext()->getComponent('\\FS\\Components\\Options'); $notifier = $this->getApplicationContext()->getComponent('\\FS\\Components\\Notifier'); $shipment = $order->getAttribute('flagship_shipping_raw'); $shipmentId = $order->getAttribute('flagship_shipping_shipment_id'); if (!$shipment || !$shipmentId) { $notifier->warning(sprintf('Unable to access shipment with FlagShip ID (%s)', $shipmentId)); return; } $client = $this->getApplicationContext()->getComponent('\\FS\\Components\\Http\\Client'); $response = $client->delete('/ship/shipments/' . $shipmentId); if (!$response->isSuccessful()) { $notifier->warning(sprintf('Unable to void shipment with FlagShip ID (%s)', $shipmentId)); return; } if (empty($shipment['pickup'])) { $order->deleteAttribute('flagship_shipping_raw'); return; } $this->voidPickup($order); $order->deleteAttribute('flagship_shipping_raw'); }