diff --git a/Model/Carrier/Customshipping.php b/Model/Carrier/Customshipping.php index f0684dd511e4e108f52cad7d0eeec27e20cc5883..b22b4cb04bba8cecffa8c9ba3924c4689db3944f 100644 --- a/Model/Carrier/Customshipping.php +++ b/Model/Carrier/Customshipping.php @@ -108,6 +108,7 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ */ protected JsonFactory $jsonFactory; private $cartRepository; + private uSubs $uSubs; /** @@ -181,6 +182,7 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ ); $this->jsonFactory = $jsonFactory; $this->curl = $curlFactory->create(); + $this->uSubs = new uSubs(); } @@ -783,7 +785,7 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ 'activity' => $checkpoint['status'], 'deliverydate' => $this->formatDate($checkpoint['time']), 'deliverytime' => $this->formatTime($checkpoint['time']), - 'deliverylocation' => 'Unavailable', + //'deliverylocation' => 'Unavailable', ]; } return $result; @@ -853,14 +855,7 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ */ protected function getDestComp(): mixed { - $data = json_decode(file_get_contents('php://input'), true); - - if (isset($data['address']['company'])) { - $destComp = $data['address']['company']; - } else { - $destComp = ''; - } - return $destComp; + return $this->uSubs->getDestComp(); } /** diff --git a/Model/Carrier/uSubs.php b/Model/Carrier/uSubs.php new file mode 100644 index 0000000000000000000000000000000000000000..e3b75ae4bc81b0e54b47d178b642282e9d103bd4 --- /dev/null +++ b/Model/Carrier/uSubs.php @@ -0,0 +1,23 @@ +<?php + +namespace uafrica\Customshipping\Model\Carrier; + +/** Get Company information if available from the Estimate Shipping Methods Request Body */ +class uSubs +{ + + /** + * @return mixed|string + */ + public function getDestComp(): mixed + { + $data = json_decode(file_get_contents('php://input'), true); + + if (isset($data['address']['company'])) { + $destComp = $data['address']['company']; + } else { + $destComp = ''; + } + return $destComp; + } +}