| 1 |
<?php |
| 2 |
|
| 3 |
use WPO\WC\PostNL\Compatibility\WC_Core as WCX; |
| 4 |
use WPO\WC\PostNL\Compatibility\Order as WCX_Order; |
| 5 |
|
| 6 |
defined('ABSPATH') or die(); |
| 7 |
|
| 8 |
include('html-start.php'); |
| 9 |
|
| 10 |
/** |
| 11 |
* @var array $order_ids |
| 12 |
*/ |
| 13 |
|
| 14 |
$add_return = WCPN_Export::ADD_RETURN; |
| 15 |
$export = WCPN_Export::EXPORT; |
| 16 |
|
| 17 |
$order_ids_string = implode(';', $order_ids); |
| 18 |
|
| 19 |
$target_url = wp_nonce_url( |
| 20 |
admin_url("admin-ajax.php?action=$export&request=$add_return&modal=true&order_ids=$order_ids_string"), |
| 21 |
WCPOST::NONCE_ACTION |
| 22 |
); |
| 23 |
|
| 24 |
?> |
| 25 |
<form |
| 26 |
method="post" |
| 27 |
class="page-form wcpn__bulk-options wcpn__return-dialog" |
| 28 |
action="<?php echo $target_url; ?>"> |
| 29 |
<table class="widefat"> |
| 30 |
<thead> |
| 31 |
<tr> |
| 32 |
<th><?php _e("Export options", "woocommerce-postnl"); ?></th> |
| 33 |
</tr> |
| 34 |
</thead> |
| 35 |
<tbody> |
| 36 |
<?php |
| 37 |
$c = true; |
| 38 |
foreach ($order_ids as $order_id) : |
| 39 |
$order = WCX::get_order($order_id); |
| 40 |
// skip non-postnl destinations |
| 41 |
$shipping_country = WCX_Order::get_prop($order, 'shipping_country'); |
| 42 |
if (! WCPN_Country_Codes::isAllowedDestination($shipping_country)) { |
| 43 |
continue; |
| 44 |
} |
| 45 |
|
| 46 |
$recipient = WCPN_Export::getRecipientFromOrder($order); |
| 47 |
$package_types = WCPN_Data::getPackageTypes(); |
| 48 |
?> |
| 49 |
<tr class="order-row <?php echo(($c = ! $c) ? 'alternate' : ''); ?>"> |
| 50 |
<td> |
| 51 |
<table style="width: 100%"> |
| 52 |
<tr> |
| 53 |
<td colspan="2"> |
| 54 |
<strong> |
| 55 |
<?php echo __("Order", "woocommerce-postnl") . $order->get_order_number(); ?> |
| 56 |
</strong> |
| 57 |
</td> |
| 58 |
</tr> |
| 59 |
<tr> |
| 60 |
<td class="ordercell"> |
| 61 |
<table class="widefat"> |
| 62 |
<thead> |
| 63 |
<tr> |
| 64 |
<th>#</th> |
| 65 |
<th><?php _e("Product name", "woocommerce-postnl"); ?></th> |
| 66 |
<th align="right"><?php _e("Weight (kg)", "woocommerce-postnl"); ?></th> |
| 67 |
</tr> |
| 68 |
</thead> |
| 69 |
<tbody> |
| 70 |
<?php foreach ($order->get_items() as $item_id => $item) : ?> |
| 71 |
<tr> |
| 72 |
<td><?php echo $item['qty'] . 'x'; ?></td> |
| 73 |
<td><?php echo WCPN_Export::get_item_display_name($item, $order) ?></td> |
| 74 |
<td align="right"> |
| 75 |
<?php echo wc_format_weight( |
| 76 |
WCPN_Export::getItemWeightKg($item, $order) |
| 77 |
); ?> |
| 78 |
</td> |
| 79 |
</tr> |
| 80 |
<?php endforeach; ?> |
| 81 |
</tbody> |
| 82 |
<tfoot> |
| 83 |
<tr> |
| 84 |
<td> </td> |
| 85 |
<td><?php _e("Total weight", "woocommerce-postnl"); ?></td> |
| 86 |
<td align="right"><?php echo wc_format_weight( |
| 87 |
$order->get_meta(WCPOST_Admin::META_ORDER_WEIGHT) |
| 88 |
); ?></td> |
| 89 |
</tr> |
| 90 |
</tfoot> |
| 91 |
</table> |
| 92 |
</td> |
| 93 |
<td> |
| 94 |
<?php |
| 95 |
if ($shipping_country === 'NL' |
| 96 |
&& (empty($recipient['street']) |
| 97 |
|| empty($recipient['number']))) { ?> |
| 98 |
<p><span style="color:red"><?php __( |
| 99 |
"This order does not contain valid street and house number data and cannot be exported because of this! This order was probably placed before the PostNL plugin was activated. The address data can still be manually entered in the order screen.", |
| 100 |
"woocommerce-postnl" |
| 101 |
); ?></span></p> |
| 102 |
</td> |
| 103 |
</tr> <!-- last row --> |
| 104 |
<?php |
| 105 |
} else { // required address data is available |
| 106 |
// print address |
| 107 |
echo '<p>' . $order->get_formatted_shipping_address() . '<br/>' . WCX_Order::get_prop( |
| 108 |
$order, |
| 109 |
'billing_phone' |
| 110 |
) . '<br/>' . WCX_Order::get_prop($order, 'billing_email') . '</p>'; |
| 111 |
?> |
| 112 |
</td></tr> |
| 113 |
<tr> |
| 114 |
<td |
| 115 |
colspan="2" |
| 116 |
class="wcpn__shipment-options"> |
| 117 |
<?php |
| 118 |
$skip_save = true; // dont show save button for each order |
| 119 |
if (isset($dialog) && $dialog === 'shipment') { |
| 120 |
include('html-order-shipment-options.php'); |
| 121 |
} else { |
| 122 |
include('html-order-return-shipment-options.php'); |
| 123 |
} |
| 124 |
?> |
| 125 |
</td> |
| 126 |
</tr> |
| 127 |
<?php } // end else |
| 128 |
?> |
| 129 |
</table> |
| 130 |
</td> |
| 131 |
</tr> |
| 132 |
<?php endforeach; ?> |
| 133 |
</tbody> |
| 134 |
</table> |
| 135 |
<div> |
| 136 |
<?php |
| 137 |
if (isset($dialog) && $dialog === 'shipment') { |
| 138 |
$button_text = __("Export to PostNL", "woocommerce-postnl"); |
| 139 |
} else { |
| 140 |
$button_text = __("Send email", "woocommerce-postnl"); |
| 141 |
} |
| 142 |
?> |
| 143 |
<div class="wcpn__d--flex"> |
| 144 |
<input |
| 145 |
type="submit" |
| 146 |
value="<?php echo $button_text; ?>" |
| 147 |
class="button wcpn__return-dialog__save"> |
| 148 |
<?php WCPOST_Admin::renderSpinner() ?> |
| 149 |
</div> |
| 150 |
</div> |
| 151 |
</form> |
| 152 |
|
| 153 |
<?php |
| 154 |
|
| 155 |
include('html-end.php'); |
| 156 |
|