-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3806 from magento-tango/MAGETWO-98328
MAGETWO-98328: Update FedEx Shipping Dates behavior in Tracking Popup
- Loading branch information
Showing
6 changed files
with
127 additions
and
2 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
app/code/Magento/Fedex/Plugin/Block/DataProviders/Tracking/ChangeTitle.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Fedex\Plugin\Block\DataProviders\Tracking; | ||
|
||
use Magento\Fedex\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 FedEx customized value | ||
*/ | ||
class ChangeTitle | ||
{ | ||
/** | ||
* Title modification in case if FedEx 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; | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
app/code/Magento/Fedex/Plugin/Block/Tracking/PopupDeliveryDate.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Fedex\Plugin\Block\Tracking; | ||
|
||
use Magento\Shipping\Block\Tracking\Popup; | ||
use Magento\Fedex\Model\Carrier; | ||
use Magento\Shipping\Model\Tracking\Result\Status; | ||
|
||
/** | ||
* Plugin to update delivery date value in case if Fedex used | ||
*/ | ||
class PopupDeliveryDate | ||
{ | ||
/** | ||
* Show only date for expected delivery in case if Fedex is a carrier | ||
* | ||
* @param Popup $subject | ||
* @param string $result | ||
* @param string $date | ||
* @param string $time | ||
* @return string | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function afterFormatDeliveryDateTime(Popup $subject, $result, $date, $time) | ||
{ | ||
if ($this->getCarrier($subject) === Carrier::CODE) { | ||
$result = $subject->formatDeliveryDate($date); | ||
} | ||
return $result; | ||
} | ||
|
||
/** | ||
* Retrieve carrier name from tracking info | ||
* | ||
* @param Popup $subject | ||
* @return string | ||
*/ | ||
private function getCarrier(Popup $subject): string | ||
{ | ||
foreach ($subject->getTrackingInfo() as $trackingData) { | ||
foreach ($trackingData as $trackingInfo) { | ||
if ($trackingInfo instanceof Status) { | ||
$carrier = $trackingInfo->getCarrier(); | ||
return $carrier; | ||
} | ||
} | ||
} | ||
return ''; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
app/code/Magento/Shipping/Block/DataProviders/Tracking/DeliveryDateTitle.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Shipping\Block\DataProviders\Tracking; | ||
|
||
use Magento\Framework\View\Element\Block\ArgumentInterface; | ||
use Magento\Shipping\Model\Tracking\Result\Status; | ||
|
||
/** | ||
* Extension point to provide ability to change tracking details titles | ||
*/ | ||
class DeliveryDateTitle implements ArgumentInterface | ||
{ | ||
/** | ||
* Returns Title in case if carrier defined | ||
* | ||
* @param Status $trackingStatus | ||
* @return \Magento\Framework\Phrase|string | ||
*/ | ||
public function getTitle(Status $trackingStatus) | ||
{ | ||
return $trackingStatus->getCarrier() ? __('Delivered on:') : ''; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters