diff --git a/.idea/csv-editor.xml b/.idea/csv-editor.xml new file mode 100644 index 0000000000000000000000000000000000000000..24b6446b0b8b01e2df781370444530e768210330 --- /dev/null +++ b/.idea/csv-editor.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="CsvFileAttributes"> + <option name="attributeMap"> + <map> + <entry key="$PROJECT_DIR$/uafrica/Customshipping/i18n/en_US.csv"> + <value> + <Attribute> + <option name="separator" value="," /> + </Attribute> + </value> + </entry> + </map> + </option> + </component> +</project> \ No newline at end of file diff --git a/uafrica/Customshipping/Model/Carrier/Customshipping.php b/uafrica/Customshipping/Model/Carrier/Customshipping.php index b761996a6b81f552947fe4b5ebe0b2a270fdbe1e..90d34817eaf4428f2236569025eb9070ab8e4ad2 100644 --- a/uafrica/Customshipping/Model/Carrier/Customshipping.php +++ b/uafrica/Customshipping/Model/Carrier/Customshipping.php @@ -55,7 +55,7 @@ class Customshipping extends AbstractCarrier implements CarrierInterface - //TODO: REFACTO THIS + //TODO: REFACTOR THIS /** * @var \Magento\Framework\Controller\Result\JsonFactory */ @@ -114,6 +114,20 @@ class Customshipping extends AbstractCarrier implements CarrierInterface { return true; } + //Make getracking available with fake data + /** + * @param string $tracking + * @return DataObject + */ + public function getTrackingInfo($tracking): DataObject + { + // $result = $this->_trackFactory->create(); + $result = new DataObject(); + $result->setUrl('https://api.dev.ship.uafrica.com/tracking?channel=localhost&tracking_reference=UADPCTGF'); + $result->setTracking($tracking); + $result->setCarrierTitle($this->getConfigData('title')); + return $result; + } /** * Collect and get rates for storefront diff --git a/uafrica/Customshipping/Plugin/Block/DataProviders/Tracking/ChangeTitle.php b/uafrica/Customshipping/Plugin/Block/DataProviders/Tracking/ChangeTitle.php new file mode 100644 index 0000000000000000000000000000000000000000..854d22746bbd8f28e33d27357d47098d9e741610 --- /dev/null +++ b/uafrica/Customshipping/Plugin/Block/DataProviders/Tracking/ChangeTitle.php @@ -0,0 +1,32 @@ +<?php + +namespace uafrica\Customshipping\Plugin\Block\DataProviders\Tracking; + +use uafrica\Customshipping\Model\Carrier; +use Magento\Shipping\Model\Tracking\Result\Status; +use Magento\Shipping\Block\DataProviders\Tracking\DeliveryDateTitle as Subject; + + +/** + * Plugin to change delivery date title with UAfrica customized value + */ + +class ChangeTitle +{ + /** + * Title modification in case if UAfrica used as carrier + * + * @param Subject $subject + * @param \Magento\Framework\Phrase|string $result + * @param Status $trackingStatus + * @return \Magento\Framework\Phrase|string + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterGetTitle(Subject $subject, $result, Status $trackingStatus) + { + if ($trackingStatus->getCarrier() === Carrier::CODE) { + $result = __('Expected Delivery:'); + } + return $result; + } +}