| 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 |
if ( ! defined('ABSPATH')) exit; // Exit if accessed directly |
| 7 |
|
| 8 |
?> |
| 9 |
<!DOCTYPE html> |
| 10 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
| 11 |
<head> |
| 12 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| 13 |
<?php |
| 14 |
wp_enqueue_script( |
| 15 |
'wcpostnl-export', |
| 16 |
WooCommerce_PostNL()->plugin_url() . '/assets/js/wcmp-admin.js', |
| 17 |
array('jquery', 'thickbox', 'wp-color-picker'), |
| 18 |
WC_POSTNL_VERSION |
| 19 |
); |
| 20 |
wp_localize_script( |
| 21 |
'wcpostnl-export', |
| 22 |
'wc_postnl', |
| 23 |
array( |
| 24 |
'ajax_url' => admin_url('admin-ajax.php'), |
| 25 |
'nonce' => wp_create_nonce('wc_postnl'), |
| 26 |
'download_display' => isset(WooCommerce_PostNL()->general_settings['download_display']) |
| 27 |
? WooCommerce_PostNL()->general_settings['download_display'] : '', |
| 28 |
) |
| 29 |
); |
| 30 |
|
| 31 |
wp_enqueue_style( |
| 32 |
'wcmp-admin-styles', |
| 33 |
WooCommerce_PostNL()->plugin_url() . '/assets/css/wcmp-admin-styles.css', |
| 34 |
array(), |
| 35 |
WC_POSTNL_VERSION, |
| 36 |
'all' |
| 37 |
); |
| 38 |
|
| 39 |
// Legacy styles (WC 2.1+ introduced MP6 style with larger buttons) |
| 40 |
if (version_compare(WOOCOMMERCE_VERSION, '2.1', '<=')) { |
| 41 |
wp_enqueue_style( |
| 42 |
'wcmp-admin-styles-legacy', |
| 43 |
WooCommerce_PostNL()->plugin_url() . '/assets/css/wcmp-admin-styles-legacy.css', |
| 44 |
array(), |
| 45 |
WC_POSTNL_VERSION, |
| 46 |
'all' |
| 47 |
); |
| 48 |
} |
| 49 |
|
| 50 |
wp_enqueue_style('wp-color-picker'); |
| 51 |
wp_enqueue_style('wcpostnl-admin-styles'); |
| 52 |
wp_enqueue_style('colors'); |
| 53 |
wp_enqueue_style('media'); |
| 54 |
wp_enqueue_script('jquery'); |
| 55 |
do_action('admin_print_styles'); |
| 56 |
do_action('admin_print_scripts'); |
| 57 |
?> |
| 58 |
</head> |
| 59 |
<body> |
| 60 |
<?php |
| 61 |
$target_url = wp_nonce_url(admin_url('admin-ajax.php?action=wc_postnl&request=add_return&modal=true'), 'wc_postnl'); |
| 62 |
?> |
| 63 |
<form method="post" class="page-form wcmp_bulk_options_form" action="<?php echo $target_url; ?>"> |
| 64 |
<table class="widefat"> |
| 65 |
<thead> |
| 66 |
<tr> |
| 67 |
<th><?php _e('Export options', 'woocommerce-postnl'); ?></th> |
| 68 |
</tr> |
| 69 |
</thead> |
| 70 |
<tbody> |
| 71 |
<?php |
| 72 |
$c = true; |
| 73 |
foreach ($order_ids as $order_id) : |
| 74 |
$order = WCX::get_order($order_id); |
| 75 |
// skip non-postnl destinations |
| 76 |
$shipping_country = WCX_Order::get_prop($order, 'shipping_country'); |
| 77 |
if ( ! WooCommerce_PostNL()->export->is_postnl_destination($shipping_country)) { |
| 78 |
continue; |
| 79 |
} |
| 80 |
$shipment_options = WooCommerce_PostNL()->export->get_options($order); |
| 81 |
$recipient = WooCommerce_PostNL()->export->get_recipient($order); |
| 82 |
$postnl_options_extra = WCX_Order::get_meta($order, '_postnl_shipment_options_extra'); |
| 83 |
$package_types = WooCommerce_PostNL()->export->get_package_types($dialog); |
| 84 |
$parcel_weight = WooCommerce_PostNL()->export->get_parcel_weight($order); |
| 85 |
?> |
| 86 |
<tr class="order-row <?php echo (($c = !$c)?'alternate':'');?>"> |
| 87 |
<td> |
| 88 |
<table style="width: 100%"> |
| 89 |
<tr> |
| 90 |
<td colspan="2"><strong><?php _e('Order', 'woocommerce-postnl'); ?> <?php echo $order->get_order_number(); ?></strong></td> |
| 91 |
</tr> |
| 92 |
<tr> |
| 93 |
<td class="ordercell"> |
| 94 |
<table class="widefat"> |
| 95 |
<thead> |
| 96 |
<tr> |
| 97 |
<th>#</th> |
| 98 |
<th><?php _e('Product name', 'woocommerce-postnl'); ?></th> |
| 99 |
<th align="right"><?php _e('Weight (kg)', 'woocommerce-postnl'); ?></th> |
| 100 |
</tr> |
| 101 |
</thead> |
| 102 |
<tbody> |
| 103 |
<?php |
| 104 |
$items = $order->get_items(); |
| 105 |
foreach ($items as $item_id => $item) { |
| 106 |
?> |
| 107 |
<tr> |
| 108 |
<td><?php echo $item['qty'].'x'; ?></td> |
| 109 |
<td><?php echo $this->get_item_display_name ($item, $order) ?></td> |
| 110 |
<td align="right"><?php echo number_format($this->get_item_weight_kg($item, $order), 3, ',', ' '); ?></td> |
| 111 |
</tr> |
| 112 |
<?php } ?> |
| 113 |
<tr> |
| 114 |
<td> </td> |
| 115 |
<td><?php _e('Empty parcel weight', 'woocommerce-postnl'); ?></td> |
| 116 |
<td align="right"><?php echo number_format(((isset(WooCommerce_PostNL()->general_settings['empty_parcel_weight'])) ? preg_replace("/\D/","",$this->settings['verpakkingsgewicht'])/1000 : 0), 3, ',', ' '); ?></td> |
| 117 |
</tr> |
| 118 |
</tbody> |
| 119 |
<tfoot> |
| 120 |
<tr> |
| 121 |
<td> </td> |
| 122 |
<td><?php _e('Total weight', 'woocommerce-postnl'); ?></td> |
| 123 |
<td align="right"><?php echo number_format($parcel_weight, 3, ',', ' ');?></td> |
| 124 |
</tr> |
| 125 |
</tfoot> |
| 126 |
</table> |
| 127 |
</td> |
| 128 |
<td><?php |
| 129 |
if ($shipping_country == 'NL' && (empty($recipient['street']) || empty($recipient['number']))) { ?> |
| 130 |
<p><span style="color:red"><?php _e('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.', 'woocommerce-postnl'); ?></span></p> |
| 131 |
</td> |
| 132 |
</tr> <!-- last row --> |
| 133 |
<?php |
| 134 |
} else { // required address data is available |
| 135 |
// print address |
| 136 |
echo '<p>'.$order->get_formatted_shipping_address().'<br/>'.WCX_Order::get_prop($order, 'billing_phone').'<br/>'.WCX_Order::get_prop($order, 'billing_email').'</p>'; |
| 137 |
?> |
| 138 |
</td> |
| 139 |
</tr> |
| 140 |
<tr> |
| 141 |
<td colspan="2" class="wcmp_shipment_options"> |
| 142 |
<?php |
| 143 |
$skip_save = true; // don't show save button for each order |
| 144 |
if ($dialog == 'shipment') { |
| 145 |
include('wcmp-order-shipment-options.php'); |
| 146 |
} elseif ($dialog == 'return') { |
| 147 |
include('wcmp-order-return-shipment-options.php'); |
| 148 |
} |
| 149 |
?> |
| 150 |
</td> |
| 151 |
</tr> |
| 152 |
<?php } // end else ?> |
| 153 |
</table> |
| 154 |
</td> |
| 155 |
</tr> |
| 156 |
<?php endforeach; ?> |
| 157 |
</tbody> |
| 158 |
</table> |
| 159 |
<input type="hidden" name="action" value="wc_postnl"> |
| 160 |
<div class="wcmp_save_shipment_settings"> |
| 161 |
<?php |
| 162 |
if ($dialog == 'shipment') { |
| 163 |
$button_text = __('Export to PostNL', 'woocommerce-postnl'); |
| 164 |
} else if ($dialog == 'return') { |
| 165 |
$button_text = __('Send email', 'woocommerce-postnl'); |
| 166 |
} |
| 167 |
?> |
| 168 |
|
| 169 |
<input type="submit" value="<?php echo $button_text; ?>" class="button save wcmp_export"> |
| 170 |
<img src="<?php echo WooCommerce_PostNL()->plugin_url() . '/assets/img/wpspin_light.gif';?>" class="wcmp_spinner"/> |
| 171 |
</div> |
| 172 |
</form> |
| 173 |
<script type="text/javascript"> |
| 174 |
jQuery(document).ready(function($) { |
| 175 |
$('.button-wcpostnl').click(function() { |
| 176 |
$('.waiting').show(); |
| 177 |
}); |
| 178 |
}); |
| 179 |
</script> |
| 180 |
|
| 181 |
</body> |
| 182 |
</html> |
| 183 |
|