| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* This template is for the Track & Trace information in the PostNL meta box in a single order/ |
| 5 |
*/ |
| 6 |
|
| 7 |
/** |
| 8 |
* @var array $consignments |
| 9 |
* @var int $order_id |
| 10 |
* @var bool $downloadDisplay |
| 11 |
*/ |
| 12 |
|
| 13 |
$shipments = []; |
| 14 |
|
| 15 |
try { |
| 16 |
$shipments = WCPOST()->export->getShipmentData(array_keys($consignments), $order); |
| 17 |
} catch (Exception $e) { |
| 18 |
$message = $e->getMessage(); |
| 19 |
} |
| 20 |
|
| 21 |
if (isset($message)) { |
| 22 |
echo "<p>$message</p>"; |
| 23 |
} |
| 24 |
|
| 25 |
/** |
| 26 |
* Don't render the table if no shipments have been exported. |
| 27 |
*/ |
| 28 |
if (! count($shipments)) { |
| 29 |
return; |
| 30 |
} |
| 31 |
|
| 32 |
?> |
| 33 |
|
| 34 |
<table class="wcpn__table--track-trace"> |
| 35 |
<thead> |
| 36 |
<tr> |
| 37 |
<th><?php _e("Track & Trace", "woocommerce-postnl"); ?></th> |
| 38 |
<th><?php _e("Status", "woocommerce-postnl"); ?></th> |
| 39 |
<th> </th> |
| 40 |
</tr> |
| 41 |
</thead> |
| 42 |
<tbody> |
| 43 |
<?php |
| 44 |
|
| 45 |
foreach ($shipments as $shipment_id => $shipment): |
| 46 |
$consignment = $shipments[$shipment_id]; |
| 47 |
|
| 48 |
?> |
| 49 |
<tr> |
| 50 |
<td class="wcpn__order__track-trace"> |
| 51 |
<?php WCPOST_Admin::renderTrackTraceLink($shipment, $order_id); ?> |
| 52 |
</td> |
| 53 |
<td class="wcpn__order__status"> |
| 54 |
<?php WCPOST_Admin::renderStatus($shipment, $order_id) ?> |
| 55 |
</td> |
| 56 |
<td class="wcpn__td--create-label"> |
| 57 |
<?php |
| 58 |
$action = WCPN_Export::EXPORT; |
| 59 |
$getLabels = WCPN_Export::GET_LABELS; |
| 60 |
|
| 61 |
$order = wc_get_order($order_id); |
| 62 |
$returnShipmentId = $order->get_meta(WCPOST_Admin::META_RETURN_SHIPMENT_IDS); |
| 63 |
|
| 64 |
WCPOST_Admin::renderAction( |
| 65 |
admin_url("admin-ajax.php?action=$action&request=$getLabels&shipment_ids=$shipment_id&return_shipment_id=$returnShipmentId"), |
| 66 |
__("Print PostNL label", "woocommerce-postnl"), |
| 67 |
WCPOST()->plugin_url() . "/assets/img/postnl-print.png" |
| 68 |
); |
| 69 |
?> |
| 70 |
</td> |
| 71 |
</tr> |
| 72 |
<?php endforeach ?> |
| 73 |
</tbody> |
| 74 |
</table> |
| 75 |
|