Quantcast
Channel: Maris Labs
Viewing all articles
Browse latest Browse all 19

Hyperlinking Tracking Numbers in Magento

$
0
0

In:
<magento_root>/app/design/frontend/base/default/template/email/order/shipment

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
/**
 * ... all that license bull ...
 */

?>
<?php $_shipment=$this->getShipment() ?>
<?php $_order=$this->getOrder() ?>
<?php if ($_shipment && $_order && $_shipment->getAllTracks()): ?>
<table cellspacing="0" cellpadding="0" border="0" width="650" style="border:1px solid #EAEAEA;">
    <thead>
        <tr>
            <th align="left" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Shipped By') ?></th>
            <th align="center" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Tracking Number') ?></th>
        </tr>
    </thead>
    <tbody>
    <?php $i=0; foreach ($_shipment->getAllTracks() as $_item): $i++ ?>
    <?php
    $service = $_item->getTitle();
    $tracking_number = $_item->getNumber();
    $tracking_url = '';
    switch ($service) {
            case 'DHL':
                    $tracking_url = 'http://webtrack.dhlglobalmail.com/?mobile=&trackingnumber='.$tracking_number;
                    break;
            case 'Federal Express':
                    $tracking_url = 'http://www.fedex.com/Tracking?action=track&tracknumbers='.$tracking_number;
                    break;
            case 'United Parcel Service':
                    $tracking_url = 'http://wwwapps.ups.com/WebTracking/track?track=yes&trackNums='.$tracking_number;
                    break;
            case 'United States Postal Service':
                    $tracking_url = 'https://tools.usps.com/go/TrackConfirmAction_input?qtc_tLabels1='.$tracking_number;
                    break;
    }
    ?>
        <tr <?php echo $i%2?'bgcolor="#F6F6F6"':'' ?>>
            <td align="left" valign="top" style="padding:3px 9px"><?php echo $_item->getTitle() ?></td>
            <td align="center" valign="top" style="padding:3px 9px"><a href = "<?php print $tracking_url; ?>"><?php echo $_item->getNumber() ?></a></td>
        </tr>
    <?php endforeach ?>
    </tbody>
</table>
<?php endif; ?>

Viewing all articles
Browse latest Browse all 19

Trending Articles