PluginProbe
PostNL for WooCommerce / 4.0.0
PostNL for WooCommerce v4.0.0
5.9.12 5.9.11 5.9.10 5.9.9 5.9.8 5.9.7 5.9.6 trunk 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 3.1.4 3.1.5 3.1.6 3.1.7 4.0.0 4.0.1 4.0.2 4.3.2 4.3.3 4.4.0 4.4.1 All 72 releases
woo-postnl / includes / admin / views / html-order-shipment-summary.php

html-order-shipment-summary.php in PostNL for WooCommerce 4.0.0, at includes/admin/views/html-order-shipment-summary.php

90 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * The shipment summary that shows when you click (i) in an order.
5 */
6
7 use MyParcelNL\Sdk\src\Support\Arr;
8 use WPO\WC\PostNL\Compatibility\WC_Core as WCX;
9
10 if (! defined('ABSPATH')) {
11 exit;
12 } // Exit if accessed directly
13
14 $order_id = $_POST["order_id"];
15 $shipment_id = $_POST["shipment_id"];
16
17 $order = WCX::get_order($order_id);
18
19 $shipments = WCPOST()->export->getShipmentData([$shipment_id], $order);
20 $deliveryOptions = WCPOST_Admin::getDeliveryOptionsFromOrder($order);
21
22 $option_strings = [
23 "signature" => __("Signature on delivery", "woocommerce-postnl"),
24 "only_recipient" => __("Only recipient", "woocommerce-postnl"),
25 ];
26
27 $firstShipment = $shipments[$shipment_id];
28
29 /**
30 * Show options only for the first shipment as they are all the same.
31 */
32 $insurance = Arr::get($firstShipment, "shipment.options.insurance");
33 $labelDescription = Arr::get($firstShipment, "shipment.options.label_description");
34
35 echo '<ul class="wcpn__shipment-summary">';
36
37 /**
38 * Package type
39 */
40 printf(
41 '%s: %s',
42 __("Shipment type", "woocommerce-postnl"),
43 WCPN_Data::getPackageTypeHuman(Arr::get($firstShipment, "shipment.options.package_type"))
44 );
45
46 foreach ($option_strings as $key => $label) {
47 if (Arr::get($firstShipment, "shipment.options.$key")
48 && (int) Arr::get($firstShipment, "shipment.options.$key") === 1) {
49 printf('<li class="%s">%s</li>', $key, $label);
50 }
51 }
52
53 if ($insurance) {
54 $price = number_format(Arr::get($insurance, "amount") / 100, 2);
55 printf('<li>%s: € %s</li>', __("Insured for", "woocommerce-postnl"), $price);
56 }
57
58 if ($labelDescription) {
59 printf(
60 '<li>%s: %s</li>',
61 __("Label description", "woocommerce-postnl"),
62 $labelDescription
63 );
64 }
65 echo '</ul>';
66
67 echo "<hr>";
68
69 /**
70 * Do show the Track & Trace status for all shipments.
71 */
72 foreach ($shipments as $shipment_id => $shipment) {
73 $trackTrace = Arr::get($shipment, "track_trace");
74
75 /**
76 * Show Track & Trace status.
77 */
78 if (! $trackTrace) {
79 continue;
80 }
81
82 printf(
83 '<a href="%2$s" target="_blank" title="%3$s">%3$s</a><br/> %1$s: %4$s<br/>',
84 __("Status", "woocommerce-postnl"),
85 WCPOST_Admin::getTrackTraceUrl($order_id, $trackTrace),
86 $trackTrace,
87 Arr::get($shipment, "status")
88 );
89 }
90