431 lines
12 KiB
PHP
431 lines
12 KiB
PHP
<?php
|
|
/**
|
|
* Order metabox content.
|
|
*
|
|
* @var $order \WC_Order
|
|
* @var $disabled bool
|
|
* @var $dpd_sender_address_id string
|
|
* @var $sender_address_options array
|
|
* @var $tracking_url string
|
|
* @var $dpd_package_number string
|
|
* @var $label_url string
|
|
* @var $label_avaliable bool
|
|
* @var $dpd_pickup bool
|
|
* @var $pickup_points array
|
|
* @var $dpd_pickup_point_id string
|
|
* @package WooCommerce DPD
|
|
*/
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit; /* Exit if accessed directly */
|
|
}
|
|
|
|
?>
|
|
<div class="dpd-package">
|
|
<?php
|
|
$key = 'dpd_product';
|
|
$args = [
|
|
'label' => __( 'Usługa DPD', 'woocommerce-dpd' ),
|
|
'id' => 'dpd_product_' . $id,
|
|
'type' => 'select',
|
|
'options' => WPDesk_WooCommerce_DPD::get_products(),
|
|
'class' => [ 'dpd-product', 'dpd-hidden' ],
|
|
'input_class' => [ 'dpd-product' ],
|
|
];
|
|
$value = '';
|
|
if ( isset( $dpd_product ) ) {
|
|
$value = $dpd_product;
|
|
}
|
|
if ( $disabled ) {
|
|
$args['custom_attributes'] = [ 'disabled' => 'disabled' ];
|
|
}
|
|
woocommerce_form_field( $key, $args, $value );
|
|
|
|
?>
|
|
|
|
<hr class="dpd-hidden"/>
|
|
|
|
<?php
|
|
$key = 'dpd_sender_address_id';
|
|
$args = [
|
|
'label' => __( 'Adres nadawcy', 'woocommerce-dpd' ),
|
|
'id' => 'dpd_sender_address_id' . $id,
|
|
'type' => 'select',
|
|
'options' => $sender_address_options,
|
|
'class' => [ 'dpd-sender-address-id' ],
|
|
'input_class' => [ 'dpd-sender-address-id' ],
|
|
];
|
|
$value = '';
|
|
if ( isset( $dpd_sender_address_id ) ) {
|
|
$value = $dpd_sender_address_id;
|
|
}
|
|
if ( $disabled ) {
|
|
$args['custom_attributes'] = [ 'disabled' => 'disabled' ];
|
|
}
|
|
woocommerce_form_field( $key, $args, $value );
|
|
?>
|
|
|
|
<div class="dpd_package_data">
|
|
<h4>
|
|
<?php
|
|
// Translators: package number.
|
|
echo esc_html( sprintf( __( 'Paczka %1$s', 'woocommerce-dpd' ), 1 ) );
|
|
?>
|
|
</h4>
|
|
<div class="dpd-weight">
|
|
<?php
|
|
$key = 'dpd_package_weight';
|
|
$args = [
|
|
'label' => __( 'Waga [kg]', 'woocommerce-dpd' ),
|
|
'id' => 'dpd_package_weight_' . $id,
|
|
'type' => 'number',
|
|
];
|
|
$value = '';
|
|
if ( isset( $dpd_package_weight ) ) {
|
|
$value = $dpd_package_weight;
|
|
}
|
|
if ( $disabled ) {
|
|
$args['custom_attributes'] = [ 'disabled' => 'disabled' ];
|
|
}
|
|
woocommerce_form_field( $key, $args, $value );
|
|
?>
|
|
</div>
|
|
<div class="dpd-dimensions">
|
|
<label><?php echo esc_html( __( 'Wymiary (dł / wys / gł) [cm]', 'woocommerce-dpd' ) ); ?></label>
|
|
<?php
|
|
$key = 'dpd_package_width';
|
|
$args = [
|
|
'type' => 'number',
|
|
'id' => 'dpd_package_width_' . $id,
|
|
];
|
|
$value = '';
|
|
if ( isset( $dpd_package_width ) ) {
|
|
$value = $dpd_package_width;
|
|
}
|
|
if ( $disabled ) {
|
|
$args['custom_attributes'] = [ 'disabled' => 'disabled' ];
|
|
}
|
|
woocommerce_form_field( $key, $args, $value );
|
|
?>
|
|
<?php
|
|
$key = 'dpd_package_height';
|
|
$args = [
|
|
'label' => '/',
|
|
'type' => 'number',
|
|
'id' => 'dpd_package_height_' . $id,
|
|
];
|
|
$value = '';
|
|
if ( isset( $dpd_package_height ) ) {
|
|
$value = $dpd_package_height;
|
|
}
|
|
if ( $disabled ) {
|
|
$args['custom_attributes'] = [ 'disabled' => 'disabled' ];
|
|
}
|
|
woocommerce_form_field( $key, $args, $value );
|
|
?>
|
|
<?php
|
|
$key = 'dpd_package_depth';
|
|
$args = [
|
|
'label' => '/',
|
|
'type' => 'number',
|
|
'id' => 'dpd_package_depth_' . $id,
|
|
];
|
|
$value = '';
|
|
if ( isset( $dpd_package_depth ) ) {
|
|
$value = $dpd_package_depth;
|
|
}
|
|
if ( $disabled ) {
|
|
$args['custom_attributes'] = [ 'disabled' => 'disabled' ];
|
|
}
|
|
woocommerce_form_field( $key, $args, $value );
|
|
?>
|
|
</div>
|
|
</div>
|
|
<hr/>
|
|
<?php $count_additional = 1; ?>
|
|
<?php if ( isset( $additional_packages ) ) : ?>
|
|
<?php foreach ( $additional_packages as $additional_key => $additional_package ) : ?>
|
|
<?php $count_additional++; ?>
|
|
<?php // Translators: package number. ?>
|
|
<?php $additional_package_label = sprintf( __( 'Paczka %s', 'woocommerce-dpd' ), $count_additional ); ?>
|
|
<?php include __DIR__ . '/order-metabox-additional-package.php'; ?>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
<?php if ( ! $disabled ) : ?>
|
|
<p id="dpd_add_package_<?php echo esc_attr( $id ); ?>">
|
|
<a data-id="<?php echo esc_attr( $id ); ?>"
|
|
data-count_additional="<?php echo esc_attr( $count_additional ); ?>"
|
|
class="button dpd-button dpd-button-add-package"><?php echo esc_html( __( 'Dodaj paczkę', 'woocommerce-dpd' ) ); ?>
|
|
</a>
|
|
<span class="dpd-spinner spinner shipping-spinner"></span>
|
|
</p>
|
|
<hr/>
|
|
<div class="dpd_additional_package_template" id="dpd_additional_package_template_<?php echo esc_attr( $id ); ?>"
|
|
style="display: none;">
|
|
<?php $additional_key = '_additional_key_'; ?>
|
|
<?php $count_additional = '_count_additional_'; ?>
|
|
<?php $additional_package_label = __( 'Nowa paczka', 'woocommerce-dpd' ); ?>
|
|
<?php include __DIR__ . '/order-metabox-additional-package.php'; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php
|
|
$key = 'dpd_declared_value';
|
|
$args = [
|
|
'label' => __( 'Zadeklarowana wartość', 'woocommerce-dpd' ),
|
|
'id' => 'dpd_declared_value_' . $id,
|
|
'type' => 'checkbox',
|
|
'input_class' => [ 'dpd-declared_value' ],
|
|
];
|
|
$value = '0';
|
|
if ( isset( $dpd_declared_value ) ) {
|
|
$value = $dpd_declared_value;
|
|
}
|
|
if ( $disabled ) {
|
|
$args['input_class'][] = 'dpd-disabled';
|
|
}
|
|
woocommerce_form_field( $key, $args, $value );
|
|
?>
|
|
<?php
|
|
$key = 'dpd_declared_value_value';
|
|
$args = [
|
|
'label' => __( 'Zadeklarowana kwota', 'woocommerce-dpd' ),
|
|
'id' => 'dpd_declared_value_value_' . $id,
|
|
'type' => 'number',
|
|
'class' => [ 'dpd-declared_value-value' ],
|
|
'custom_attributes' => [
|
|
'min' => 0,
|
|
'step' => '0.01',
|
|
],
|
|
];
|
|
$value = '';
|
|
if ( isset( $dpd_declared_value_value ) ) {
|
|
$value = $dpd_declared_value_value;
|
|
} else {
|
|
$value = $order->get_total();
|
|
}
|
|
if ( $disabled ) {
|
|
$args['custom_attributes']['disabled'] = 'disabled';
|
|
}
|
|
woocommerce_form_field( $key, $args, $value );
|
|
?>
|
|
<?php
|
|
$key = 'dpd_cod';
|
|
$args = [
|
|
'label' => __( 'Pobranie', 'woocommerce-dpd' ),
|
|
'id' => 'dpd_cod_' . $id,
|
|
'type' => 'checkbox',
|
|
'input_class' => [ 'dpd-cod' ],
|
|
];
|
|
$value = '0';
|
|
if ( isset( $dpd_cod ) ) {
|
|
$value = $dpd_cod;
|
|
}
|
|
if ( $disabled ) {
|
|
$args['input_class'][] = 'dpd-disabled';
|
|
}
|
|
woocommerce_form_field( $key, $args, $value );
|
|
?>
|
|
<?php
|
|
$key = 'dpd_cod_value';
|
|
$args = [
|
|
'label' => __( 'Kwota pobrania', 'woocommerce-dpd' ),
|
|
'id' => 'dpd_cod_value_' . $id,
|
|
'type' => 'number',
|
|
'class' => [ 'dpd-cod-value' ],
|
|
'custom_attributes' => [
|
|
'min' => 0,
|
|
'step' => '0.01',
|
|
],
|
|
];
|
|
$value = '';
|
|
if ( isset( $dpd_cod_value ) ) {
|
|
$value = $dpd_cod_value;
|
|
} else {
|
|
$value = $order->get_total();
|
|
}
|
|
if ( $disabled ) {
|
|
$args['custom_attributes']['disabled'] = 'disabled';
|
|
}
|
|
woocommerce_form_field( $key, $args, $value );
|
|
?>
|
|
<?php
|
|
$key = 'dpd_saturday';
|
|
$args = [
|
|
'label' => __( 'Doręczenie w sobotę', 'woocommerce-dpd' ),
|
|
'id' => 'dpd_saturday_' . $id,
|
|
'type' => 'checkbox',
|
|
'input_class' => [ 'dpd-saturday' ],
|
|
];
|
|
$value = '0';
|
|
if ( isset( $dpd_saturday ) ) {
|
|
$value = $dpd_saturday;
|
|
}
|
|
if ( $disabled ) {
|
|
$args['input_class'][] = 'dpd-disabled';
|
|
}
|
|
woocommerce_form_field( $key, $args, $value );
|
|
?>
|
|
|
|
<?php
|
|
$key = 'dpd_next_day';
|
|
$args = [
|
|
'label' => __( 'Dostawa następnego dnia (Next Day)', 'woocommerce-dpd' ),
|
|
'id' => $key . '_' . $id,
|
|
'type' => 'checkbox',
|
|
'input_class' => [ $key ],
|
|
];
|
|
$value = '0';
|
|
if ( isset( $dpd_next_day ) ) {
|
|
$value = $dpd_next_day;
|
|
}
|
|
if ( $disabled ) {
|
|
$args['input_class'][] = 'dpd-disabled';
|
|
}
|
|
woocommerce_form_field( $key, $args, $value );
|
|
?>
|
|
|
|
<?php
|
|
$key = 'dpd_pickup';
|
|
$args = [
|
|
'label' => __( 'Doręczenie do punktu odbioru', 'woocommerce-dpd' ),
|
|
'id' => 'dpd_pickup_' . $id,
|
|
'type' => 'checkbox',
|
|
'input_class' => [ 'dpd-pickup' ],
|
|
];
|
|
|
|
if ( $disabled ) {
|
|
$args['custom_attributes'] = [ 'disabled' => 'disabled' ];
|
|
}
|
|
woocommerce_form_field( $key, $args, (int) $dpd_pickup );
|
|
?>
|
|
|
|
<?php
|
|
$key = 'dpd_pickup_point_id';
|
|
$args = [
|
|
'id' => 'dpd_pickup_point_id_' . $id,
|
|
'type' => 'select',
|
|
'input_class' => [ 'dpd-pickup-value' ],
|
|
'options' => $pickup_points,
|
|
];
|
|
|
|
if ( $disabled ) {
|
|
$args['custom_attributes'] = [ 'disabled' => 'disabled' ];
|
|
}
|
|
woocommerce_form_field( $key, $args, $dpd_pickup_point_id );
|
|
?>
|
|
|
|
<?php
|
|
$key = 'dpd_package_content';
|
|
$args = [
|
|
'label' => __( 'Zawartość', 'woocommerce-dpd' ),
|
|
'id' => 'dpd_package_content_' . $id,
|
|
'type' => 'text',
|
|
];
|
|
$value = '';
|
|
if ( isset( $dpd_package_content ) ) {
|
|
$value = $dpd_package_content;
|
|
}
|
|
if ( $disabled ) {
|
|
$args['custom_attributes'] = [ 'disabled' => 'disabled' ];
|
|
}
|
|
woocommerce_form_field( $key, $args, $value );
|
|
?>
|
|
<?php
|
|
$key = 'dpd_ref';
|
|
$args = [
|
|
'label' => __( 'Numer referencyjny', 'woocommerce-dpd' ),
|
|
'id' => 'dpd_ref_' . $id,
|
|
'type' => 'text',
|
|
];
|
|
$value = '';
|
|
if ( isset( $dpd_ref ) ) {
|
|
$value = $dpd_ref;
|
|
} else {
|
|
$value = str_replace( '[order_number]', $order->get_order_number(), $value );
|
|
$value = str_replace( '[shop_name]', get_bloginfo( 'name' ), $value );
|
|
$value = str_replace( '[shop_url]', home_url(), $value );
|
|
}
|
|
if ( $disabled ) {
|
|
$args['custom_attributes'] = [ 'disabled' => 'disabled' ];
|
|
}
|
|
woocommerce_form_field( $key, $args, $value );
|
|
?>
|
|
<?php if ( isset( $dpd_status ) && 'ok' === $dpd_status ) : ?>
|
|
<p>
|
|
<?php echo esc_html( __( 'Przesyłka: ', 'woocommerce-dpd' ) ); ?> <a target="_blank"
|
|
href="<?php echo esc_attr( $tracking_url ); ?>"><?php echo esc_html( $dpd_package_number ); ?></a>
|
|
</p>
|
|
<p>
|
|
<a
|
|
target="_blank" href='<?php echo esc_attr( $label_url ); ?>' data-id="<?php echo esc_attr( $id ); ?>"
|
|
class="button button-primary dpd-button"><?php echo esc_html( __( 'Pobierz etykietę', 'woocommerce-dpd' ) ); ?></a>
|
|
<span class="spinner dpd-spinner shipping-spinner"></span>
|
|
<a
|
|
data-id="<?php echo esc_attr( $id ); ?>"
|
|
class="dpd-button dpd-button-delete-created button-shipping"><?php echo esc_html( __( 'Anuluj', 'woocommerce-dpd' ) ); ?></a>
|
|
</p>
|
|
<?php endif; ?>
|
|
<?php if ( $label_avaliable ) : ?>
|
|
<?php if ( apply_filters( 'flexible_printing', false ) && isset( $settings['flexible_printing_integration'] ) && 'yes' === $settings['flexible_printing_integration'] ) : ?>
|
|
<p>
|
|
<?php
|
|
echo apply_filters( // phpcs: XSS OK.
|
|
'flexible_printing_print_button',
|
|
'',
|
|
'dpd',
|
|
[
|
|
'content' => 'print',
|
|
'id' => $dpd_package_number,
|
|
'icon' => true,
|
|
// Translators: printer.
|
|
'label' => __( 'Drukuj na: %1$s', 'woocommerce-dpd' ),
|
|
'data' => [
|
|
'shippment_id' => $id,
|
|
'dpd_package_number' => $dpd_package_number,
|
|
],
|
|
]
|
|
);
|
|
?>
|
|
</p>
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
<?php if ( $label_avaliable ) : ?>
|
|
<?php if ( apply_filters( 'flexible_printing', false ) ) : ?>
|
|
<p>
|
|
<?php
|
|
echo apply_filters( // phpcs: XSS OK.
|
|
'flexible_printing_print_button',
|
|
'',
|
|
'dpd',
|
|
[
|
|
'content' => 'print',
|
|
'id' => str_replace( ', ', '-', $dpd_package_number ),
|
|
'icon' => true,
|
|
// Translators: printer.
|
|
'label' => __( 'Drukuj na: %1$s', 'woocommerce-dpd' ),
|
|
'data' => [
|
|
'shippment_id' => $id,
|
|
'dpd_package_number' => $dpd_package_number,
|
|
],
|
|
]
|
|
);
|
|
?>
|
|
</p>
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
<?php if ( ! $disabled ) : ?>
|
|
<p>
|
|
<button data-id="<?php echo esc_attr( $id ); ?>"
|
|
class="button button-primary dpd-button dpd-button-create button-shipping"><?php echo esc_html( __( 'Utwórz', 'woocommerce-dpd' ) ); ?></button>
|
|
<button data-id="<?php echo esc_attr( $id ); ?>"
|
|
class="button dpd-button dpd-button-save button-shipping"><?php echo esc_html( __( 'Zapisz', 'woocommerce-dpd' ) ); ?></button>
|
|
<span class="spinner dpd-spinner shipping-spinner"></span>
|
|
</p>
|
|
<?php endif; ?>
|
|
</div>
|
|
<script type="text/javascript">
|
|
jQuery(document).ready(function () {
|
|
dpd_init();
|
|
})
|
|
</script>
|