File tree Expand file tree Collapse file tree 3 files changed +67
-3
lines changed Expand file tree Collapse file tree 3 files changed +67
-3
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magento, Inc. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+ declare (strict_types=1 );
7
+
8
+ namespace Magento \Sales \Block \Email \Shipment ;
9
+
10
+ use Magento \Framework \View \Element \Template ;
11
+ use Magento \Framework \View \Element \Template \Context ;
12
+ use Magento \Sales \Model \Order \Shipment \Track as TrackModel ;
13
+ use Magento \Shipping \Helper \Data as ShippingHelper ;
14
+
15
+ /**
16
+ * Shipment track info for email
17
+ */
18
+ class Track extends Template
19
+ {
20
+ /**
21
+ * @var ShippingHelper
22
+ */
23
+ private $ helper ;
24
+
25
+ /**
26
+ * @param Context $context
27
+ * @param ShippingHelper $helper
28
+ * @param array $data
29
+ */
30
+ public function __construct (
31
+ Context $ context ,
32
+ ShippingHelper $ helper ,
33
+ array $ data = []
34
+ ) {
35
+ parent ::__construct ($ context , $ data );
36
+ $ this ->helper = $ helper ;
37
+ }
38
+
39
+ /**
40
+ * Get Shipping tracking URL
41
+ *
42
+ * @param TrackModel $track
43
+ * @return string
44
+ */
45
+ public function getTrackingUrl (TrackModel $ track ): string
46
+ {
47
+ return $ this ->helper ->getTrackingPopupUrlBySalesModel ($ track );
48
+ }
49
+
50
+ /**
51
+ * Get Shipping tracking URL escaped
52
+ *
53
+ * @param TrackModel $track
54
+ * @return string
55
+ */
56
+ public function getTrackingUrlEscaped (TrackModel $ track ): string
57
+ {
58
+ return $ this ->escapeUrl ($ this ->getTrackingUrl ($ track ));
59
+ }
60
+ }
Original file line number Diff line number Diff line change 8
8
<page xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : noNamespaceSchemaLocation =" urn:magento:framework:View/Layout/etc/page_configuration.xsd" >
9
9
<update handle =" sales_email_order_shipment_renderers" />
10
10
<body >
11
- <block class =" Magento\Framework\View\Element\Template " name =" sales.order.email.shipment.track" template =" Magento_Sales::email/shipment/track.phtml" />
11
+ <block class =" Magento\Sales\Block\Email\Shipment\Track " name =" sales.order.email.shipment.track" template =" Magento_Sales::email/shipment/track.phtml" />
12
12
</body >
13
13
</page >
Original file line number Diff line number Diff line change 3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
-
7
6
?>
7
+ <?php /* @var \Magento\Sales\Block\Email\Shipment\Track $block */ ?>
8
8
<?php $ _shipment = $ block ->getShipment () ?>
9
9
<?php
10
10
/* @var \Magento\Sales\Model\Order $_order */
@@ -24,7 +24,11 @@ $_order = $block->getOrder() ?>
24
24
<?php foreach ($ trackCollection as $ _item ) : ?>
25
25
<tr>
26
26
<td><?= $ block ->escapeHtml ($ _item ->getTitle ()) ?> :</td>
27
- <td><?= $ block ->escapeHtml ($ _item ->getNumber ()) ?> </td>
27
+ <td>
28
+ <a href="<?= $ block ->getTrackingUrlEscaped ($ _item ) ?> " target="_blank">
29
+ <?= $ block ->escapeHtml ($ _item ->getNumber ()) ?>
30
+ </a>
31
+ </td>
28
32
</tr>
29
33
<?php endforeach ?>
30
34
</tbody>
You can’t perform that action at this time.
0 commit comments