| 1 |
<?php |
| 2 |
|
| 3 |
use Sendy\WooCommerce\Enums\ProcessingMethod; |
| 4 |
|
| 5 |
if (! defined('ABSPATH')) { |
| 6 |
exit; |
| 7 |
} |
| 8 |
|
| 9 |
/** |
| 10 |
* @var WC_Order $order |
| 11 |
* @var array<string,string> $shops |
| 12 |
* @var array<string,string> $preferences |
| 13 |
*/ |
| 14 |
|
| 15 |
?> |
| 16 |
|
| 17 |
<?php if (! $order->meta_exists('_sendy_shipment_id')): ?> |
| 18 |
<p><b><?php esc_html_e('Shop', 'sendy')?> </b></p> |
| 19 |
|
| 20 |
<input type="hidden" id="sendy-create-shipment-nonce" name="sendy_create_shipment_nonce" value="<?php echo esc_html(wp_create_nonce('sendy_create_shipment'))?>"> |
| 21 |
|
| 22 |
<select id="sendy-metabox-shop-dropdown" style="width: 100%"> |
| 23 |
<?php foreach ($shops as $id => $sendy_shop) : ?> |
| 24 |
<option value="<?php echo esc_html($id); ?>" <?php selected($id, get_option('sendy_previously_used_shop_id')) ?>><?php echo esc_html($sendy_shop)?> </option> |
| 25 |
<?php endforeach; ?> |
| 26 |
</select> |
| 27 |
|
| 28 |
<?php if (get_option('sendy_processing_method') === ProcessingMethod::WooCommerce) : ?> |
| 29 |
|
| 30 |
<p><b><?php esc_html_e('Shipping preference', 'sendy')?> </b></p> |
| 31 |
|
| 32 |
<select id="sendy-metabox-preference-dropdown" style="width: 100%"> |
| 33 |
<?php foreach ($preferences as $id => $sendy_preference) : ?> |
| 34 |
<option value="<?php echo esc_html($id); ?>" <?php selected($id, get_option('sendy_previously_used_preference_id')) ?>><?php echo esc_html($sendy_preference)?> </option> |
| 35 |
<?php endforeach; ?> |
| 36 |
</select> |
| 37 |
|
| 38 |
<p><b><?php esc_html_e('Amount of packages', 'sendy')?> </b></p> |
| 39 |
|
| 40 |
<input id="sendy-metabox-amount" type="number" step="1" value="<?php echo esc_html(get_option('sendy_previously_used_amount', 1)); ?>" style="width: 100%;"> |
| 41 |
|
| 42 |
<?php endif; ?> |
| 43 |
|
| 44 |
<p> |
| 45 |
<button class="button button-primary" id="sendy-metabox-create-shipment-button"> |
| 46 |
<?php esc_html_e('Create shipment', 'sendy'); ?> |
| 47 |
</button> |
| 48 |
</p> |
| 49 |
<?php else: ?> |
| 50 |
<?php if ($order->meta_exists('_sendy_packages') && is_array($order->get_meta('_sendy_packages')) && ! empty($order->get_meta('_sendy_packages'))) : ?> |
| 51 |
<p><b><?php esc_html_e('Track and trace', 'sendy'); ?></b></p> |
| 52 |
|
| 53 |
<?php foreach ($order->get_meta('_sendy_packages') as $sendy_package) : ?> |
| 54 |
<a href="<?php echo esc_url($sendy_package['tracking_url'])?>" target="_blank"> |
| 55 |
<span><?php echo esc_html($sendy_package['package_number']); ?></span> |
| 56 |
</a> |
| 57 |
<?php endforeach; ?> |
| 58 |
|
| 59 |
<input type="hidden" id="sendy-print-labels-nonce" value="<?php echo esc_attr(wp_create_nonce('sendy_print_labels')); ?>"> |
| 60 |
|
| 61 |
<p> |
| 62 |
<button class="button button-primary" id="sendy-metabox-print-labels-button" data-order-id="<?php echo esc_attr($order->get_id()); ?>"> |
| 63 |
<?php if (count($order->get_meta('_sendy_packages')) == 1) : ?> |
| 64 |
<?php esc_html_e('Print label', 'sendy'); ?> |
| 65 |
<?php else : ?> |
| 66 |
<?php esc_html_e('Print labels', 'sendy'); ?> |
| 67 |
<?php endif; ?> |
| 68 |
</button> |
| 69 |
</p> |
| 70 |
<?php else : ?> |
| 71 |
<a href="<?php echo esc_url(sprintf("https://app.sendy.nl/shipment/%s/edit", $order->get_meta('_sendy_shipment_id'))); ?>" target="_blank"> |
| 72 |
Zending bewerken |
| 73 |
</a> |
| 74 |
<?php endif; ?> |
| 75 |
<?php endif; ?> |
| 76 |
|
| 77 |
|