first commit

This commit is contained in:
2024-07-15 11:28:08 +02:00
commit f52d538ea5
21891 changed files with 6161164 additions and 0 deletions

View File

@@ -0,0 +1,214 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<?php
$custom_attributes = array( 'style' => 'width:100%;' );
if ( $disabled ) {
$custom_attributes['disabled'] = 'disabled';
}
?>
<?php foreach ( $parcels as $key => $parcel ) : ?>
<div>
<?php if ( $status == 'new' ) : ?>
<?php
$params = array(
'type' => 'select',
'options' => $package_weights,
'class' => array('easypack_parcel'),
'input_class' => array('easypack_parcel_weight'),
'label' => __( 'Parcel', EasyPack::$text_domain ) . ' ',
);
woocommerce_form_field('parcel[' . $key . '][weight]', $params, $parcel['package_weight'] );
_e( 'Dimensions (max 60x40x40)', EasyPack::$text_domain );
?>
<div>
<?php
$params = array(
'type' => 'number',
'class' => 'easypack_parcel_width',
'input_class' => 'easypack_parcel_width',
'label' => __( 'Width', EasyPack::$text_domain ) . ' ',
'custom_attributes' => array( 'min' => '1', 'max' => '60' ),
'style' => 'max-width: 70px;',
'id' => 'parcel[' . $key . '][width]',
'value' => $parcel['package_width'],
'description' => 'cm'
);
woocommerce_wp_text_input( $params )
?>
<?php
$params = array(
'type' => 'number',
'class' => 'easypack_parcel_height',
'input_class' => 'easypack_parcel_height',
'label' => __( 'Height', EasyPack::$text_domain ) . ' ',
'custom_attributes' => array( 'min' => '1', 'max' => '40' ),
'style' => 'max-width: 70px;',
'id' => 'parcel[' . $key . '][height]',
'value' => $parcel['package_height'],
'description' => 'cm'
);
woocommerce_wp_text_input( $params )
?>
<?php
$params = array(
'type' => 'number',
'class' => 'easypack_parcel_length',
'input_class' => 'easypack_parcel_length',
'label' => __( 'Length', EasyPack::$text_domain ) . ' ',
'custom_attributes' => array( 'min' => '1', 'max' => '40' ),
'style' => 'max-width: 70px;',
'id' => 'parcel[' . $key . '][length]',
'value' => $parcel['package_length'],
'description' => 'cm'
);
woocommerce_wp_text_input( $params )
?>
</div>
<?php
?>
<?php else : ?>
<?php if ( $status == "Processing" ) : ?>
<?php _e( 'Processing', EasyPack::$text_domain ); ?>
<?php else : ?>
<?php _e( 'Weight', EasyPack::$text_domain ); ?> <?php echo $parcel['package_weight']; ?> <?php _e( 'kg', EasyPack::$text_domain ); ?>
, <?php _e( 'dimensions', EasyPack::$text_domain ); ?> <?php echo $parcel['package_width']; ?>x<?php echo $parcel['package_height']; ?>x<?php echo $parcel['package_length']; ?>
<?php _e( 'cm', EasyPack::$text_domain ); ?>:
<?php echo $parcel['crossborder_data']['tracking_number']; ?>
<?php endif; ?>
<?php endif; ?>
</div>
<?php endforeach; ?>
<?php
$custom_attributes = array( 'style' => 'width:100%;' );
if ( $disabled ) {
$custom_attributes['disabled'] = 'disabled';
}
$params = array(
'type' => 'select',
'options' => $send_methods,
'class' => array('wc-enhanced-select'),
'custom_attributes' => $custom_attributes,
'label' => __('Send method', EasyPack::$text_domain ),
);
woocommerce_form_field('easypack_send_method', $params, $send_method );
?>
<p>
<?php if ( $status == 'new' ) : ?>
<button id="easypack_send_parcels" class="button button-primary"><?php _e('Send parcel', EasyPack::$text_domain ); ?></button>
<?php endif; ?>
<?php if ( $status == 'created' ) : ?>
<button id="easypack_cancel_parcels" class="button"><?php _e('Cancel parcels', EasyPack::$text_domain ); ?></button>
<?php endif; ?>
<?php if ( $status == 'ReadyToBeSent' || $status == 'prepared' ) : ?>
<a href="<?php echo $stickers_url; ?>" id="easypack_get_stickers" class="button button-primary" target="_blank"><?php _e('Get sticker(s)', EasyPack::$text_domain ); ?></a>
<?php endif; ?>
<?php if ( $tracking_url ) : ?>
<a href="<?php echo $tracking_url; ?>" class="button" target="_blank"><?php _e('Track shipment', EasyPack::$text_domain ); ?></a>
<?php endif; ?>
<?php if ( $status == 'Processing' ) : ?>
<?php _e( 'Processing', EasyPack::$text_domain ); ?>
<?php endif; ?>
<span id="easypack_spinner" class="spinner"></span>
</p>
<p id="easypack_error"></p>
<a href="#" download id="easypack_download" hidden></a>
<script type="text/javascript">
if ( jQuery().select2 ) {
jQuery("#parcel_machine_id").select2();
}
jQuery('#easypack_send_parcels').click(function () {
jQuery('#easypack_error').html('');
jQuery(this).attr('disabled',true);
jQuery("#easypack_spinner").addClass("is-active");
var parcels = [];
jQuery('select.easypack_parcel_weight').each(function(i) {
var parent_div = jQuery(this).parent().parent();
parcels[i] = {
'weight' : jQuery(this).val(),
'width' : jQuery(parent_div).find('.easypack_parcel_width').val(),
'height' : jQuery(parent_div).find('.easypack_parcel_height').val(),
'length' : jQuery(parent_div).find('.easypack_parcel_length').val(),
};
})
var data = {
action: 'easypack',
easypack_action: 'crossborder_courier_create_package',
security: easypack_nonce,
order_id: <?php echo $order_id; ?>,
parcels: parcels,
send_method: jQuery('#easypack_send_method').val(),
};
console.log(data);
jQuery.post(ajaxurl, data, function(response) {
console.log(response);
if ( response != 0 ) {
response = JSON.parse(response);
console.log(response);
if (response.status == 'ok' ) {
jQuery("#easypack_parcel_machines .inside").html(response.content);
return false;
}
else {
//alert(response.message);
jQuery('#easypack_error').html(response.message);
}
}
else {
jQuery('#easypack_error').html('Invalid response.');
}
jQuery("#easypack_spinner").removeClass("is-active");
jQuery('#easypack_send_parcels').attr('disabled',false);
});
return false;
});
function crossborder_processing() {
console.log(jQuery('#easypack_status').val());
if ( jQuery('#easypack_status').val() == 'Processing' ) {
jQuery("#easypack_spinner").addClass("is-active");
var data = {
action: 'easypack',
easypack_action: 'crossborder_courier_processing',
security: easypack_nonce,
order_id: <?php echo $order_id; ?>,
};
jQuery.post(ajaxurl, data, function(response) {
console.log(response);
if ( response != 0 ) {
response = JSON.parse(response);
console.log(response);
if (response.status == 'ok' ) {
jQuery("#easypack_parcel_machines .inside").html(response.content);
return false;
}
else {
jQuery("#easypack_parcel_machines .inside").html(response.content);
//alert(response.message);
jQuery('#easypack_error').html(response.message);
}
}
else {
//alert('Bad response.');
jQuery('#easypack_error').html('Invalid response.');
}
jQuery("#easypack_spinner").removeClass("is-active");
jQuery('#easypack_cancel_parcels').attr('disabled',false);
});
}
}
crossborder_processing();
</script>

View File

@@ -0,0 +1,224 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<?php
$custom_attributes = array( 'style' => 'width:100%;' );
if ( $disabled ) {
$custom_attributes['disabled'] = 'disabled';
}
$params = array(
'type' => 'select',
'options' => $parcel_machines,
'class' => array('wc-enhanced-select'),
'custom_attributes' => $custom_attributes,
'label' => __('Selected parcel locker', EasyPack::$text_domain ),
);
woocommerce_form_field('parcel_machine_id', $params, $parcel_machine_id );
?>
<?php foreach ( $parcels as $key => $parcel ) : ?>
<div>
<?php if ( $status == 'new' ) : ?>
<?php
$params = array(
'type' => 'select',
'options' => $package_weights,
'class' => array('easypack_parcel_weight'),
'input_class' => array('easypack_parcel_weight'),
'label' => __( 'Parcel', EasyPack::$text_domain ) . ' ',
);
woocommerce_form_field('parcel[' . $key . '][weight]', $params, $parcel['package_weight'] );
_e( 'Dimensions (max 64x41x38)', EasyPack::$text_domain );
?>
<div>
<?php
$params = array(
'type' => 'number',
'class' => 'easypack_parcel_width',
'input_class' => 'easypack_parcel_width',
'label' => __( 'Width', EasyPack::$text_domain ) . ' ',
'custom_attributes' => array( 'min' => '1', 'max' => '64' ),
'style' => 'max-width: 70px;',
'id' => 'parcel[' . $key . '][width]',
'value' => $parcel['package_width'],
'description' => 'cm'
);
woocommerce_wp_text_input( $params )
?>
<?php
$params = array(
'type' => 'number',
'class' => 'easypack_parcel_height',
'input_class' => 'easypack_parcel_height',
'label' => __( 'Height', EasyPack::$text_domain ) . ' ',
'custom_attributes' => array( 'min' => '1', 'max' => '41' ),
'style' => 'max-width: 70px;',
'id' => 'parcel[' . $key . '][height]',
'value' => $parcel['package_height'],
'description' => 'cm'
);
woocommerce_wp_text_input( $params )
?>
<?php
$params = array(
'type' => 'number',
'class' => 'easypack_parcel_length',
'input_class' => 'easypack_parcel_length',
'label' => __( 'Length', EasyPack::$text_domain ) . ' ',
'custom_attributes' => array( 'min' => '1', 'max' => '38' ),
'style' => 'max-width: 70px;',
'id' => 'parcel[' . $key . '][length]',
'value' => $parcel['package_length'],
'description' => 'cm'
);
woocommerce_wp_text_input( $params )
?>
</div>
<?php
?>
<?php else : ?>
<?php if ( $status == "Processing" ) : ?>
<?php _e( 'Processing', EasyPack::$text_domain ); ?>
<?php else : ?>
<?php _e( 'Weight', EasyPack::$text_domain ); ?> <?php echo $parcel['package_weight']; ?> <?php _e( 'kg', EasyPack::$text_domain ); ?>
, <?php _e( 'dimensions', EasyPack::$text_domain ); ?> <?php echo $parcel['package_width']; ?>x<?php echo $parcel['package_height']; ?>x<?php echo $parcel['package_length']; ?>
<?php _e( 'cm', EasyPack::$text_domain ); ?>:
<?php echo $parcel['crossborder_data']['tracking_number']; ?>
<?php endif; ?>
<?php endif; ?>
</div>
<?php endforeach; ?>
<?php
$custom_attributes = array( 'style' => 'width:100%;' );
if ( $disabled ) {
$custom_attributes['disabled'] = 'disabled';
}
$params = array(
'type' => 'select',
'options' => $send_methods,
'class' => array('wc-enhanced-select'),
'custom_attributes' => $custom_attributes,
'label' => __('Send method', EasyPack::$text_domain ),
);
woocommerce_form_field('easypack_send_method', $params, $send_method );
?>
<p>
<?php if ( $status == 'new' ) : ?>
<button id="easypack_send_parcels" class="button button-primary"><?php _e('Send parcel', EasyPack::$text_domain ); ?></button>
<?php endif; ?>
<?php if ( $status == 'created' ) : ?>
<button id="easypack_cancel_parcels" class="button"><?php _e('Cancel parcels', EasyPack::$text_domain ); ?></button>
<?php endif; ?>
<?php if ( $status == 'ReadyToBeSent' || $status == 'prepared' ) : ?>
<a href="<?php echo $stickers_url; ?>" id="easypack_get_stickers" class="button button-primary" target="_blank"><?php _e('Get sticker(s)', EasyPack::$text_domain ); ?></a>
<?php endif; ?>
<?php if ( $tracking_url ) : ?>
<a href="<?php echo $tracking_url; ?>" class="button" target="_blank"><?php _e('Track shipment', EasyPack::$text_domain ); ?></a>
<?php endif; ?>
<?php if ( $status == 'Processing' ) : ?>
<?php _e( 'Processing', EasyPack::$text_domain ); ?>
<?php endif; ?>
<span id="easypack_spinner" class="spinner"></span>
</p>
<p id="easypack_error"></p>
<a href="#" download id="easypack_download" hidden></a>
<script type="text/javascript">
if ( jQuery().select2 ) {
jQuery("#parcel_machine_id").select2();
}
jQuery('#easypack_send_parcels').click(function () {
jQuery('#easypack_error').html('');
jQuery(this).attr('disabled',true);
jQuery("#easypack_spinner").addClass("is-active");
var parcels = [];
jQuery('select.easypack_parcel_weight').each(function(i) {
var parent_div = jQuery(this).parent().parent();
parcels[i] = {
'weight' : jQuery(this).val(),
'width' : jQuery(parent_div).find('.easypack_parcel_width').val(),
'height' : jQuery(parent_div).find('.easypack_parcel_height').val(),
'length' : jQuery(parent_div).find('.easypack_parcel_length').val(),
};
})
var data = {
action: 'easypack',
easypack_action: 'crossborder_parcel_machines_create_package',
security: easypack_nonce,
order_id: <?php echo $order_id; ?>,
parcel_machine_id: jQuery('#parcel_machine_id').val(),
parcels: parcels,
send_method: jQuery('#easypack_send_method').val(),
};
jQuery.post(ajaxurl, data, function(response) {
console.log(response);
if ( response != 0 ) {
response = JSON.parse(response);
console.log(response);
if (response.status == 'ok' ) {
jQuery("#easypack_parcel_machines .inside").html(response.content);
return false;
}
else {
//alert(response.message);
jQuery('#easypack_error').html(response.message);
}
}
else {
//alert('Bad response.');
jQuery('#easypack_error').html('Invalid response.');
}
jQuery("#easypack_spinner").removeClass("is-active");
jQuery('#easypack_send_parcels').attr('disabled',false);
});
return false;
});
function crossborder_processing() {
console.log(jQuery('#easypack_status').val());
if ( jQuery('#easypack_status').val() == 'Processing' ) {
jQuery("#easypack_spinner").addClass("is-active");
var data = {
action: 'easypack',
easypack_action: 'crossborder_parcel_machines_processing',
security: easypack_nonce,
order_id: <?php echo $order_id; ?>,
};
jQuery.post(ajaxurl, data, function(response) {
console.log(response);
if ( response != 0 ) {
response = JSON.parse(response);
console.log(response);
if (response.status == 'ok' ) {
jQuery("#easypack_parcel_machines .inside").html(response.content);
return false;
}
else {
jQuery("#easypack_parcel_machines .inside").html(response.content);
//alert(response.message);
jQuery('#easypack_error').html(response.message);
}
}
else {
//alert('Bad response.');
jQuery('#easypack_error').html('Invalid response.');
}
jQuery("#easypack_spinner").removeClass("is-active");
jQuery('#easypack_cancel_parcels').attr('disabled',false);
});
}
}
crossborder_processing();
</script>

View File

@@ -0,0 +1,191 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$first_parcel = true;
?>
<?php
$custom_attributes = array( 'style' => 'width:100%;' );
if ( $disabled ) {
$custom_attributes['disabled'] = 'disabled';
}
woocommerce_wp_text_input([
'id' => 'parcel_machine_id',
'label' => __('Selected parcel locker', EasyPack::$text_domain ),
'desc_tip' => false,
'value' => $parcel_machine_id,
'custom_attributes' => $custom_attributes,
'class' => 'settings-geowidget',
]);
?>
<p><?php _e( 'Parcels', EasyPack::$text_domain ); ?>
<ol id="easypack_parcels">
<?php foreach ( $parcels as $parcel ) : ?>
<li>
<?php if ( $status == 'new' ) : ?>
<?php
$params = array(
'type' => 'select',
'options' => $package_sizes,
'class' => array('easypack_parcel'),
'input_class' => array('easypack_parcel'),
'label' => '',
);
woocommerce_form_field('parcel[]', $params, $parcel['package_size'] );
?>
<?php if ( $status == 'new' && ! $first_parcel ) : ?>
<button class="button easypack_remove_parcel"><?php _e( 'Remove', EasyPack::$text_domain ); ?></button>
<?php endif; ?>
<?php else : ?>
<?php _e( 'Size', EasyPack::$text_domain ); ?> <?php echo $package_sizes_display[$parcel['package_size']]; ?>:
<?php echo $parcel['easypack_data']['id']; ?>
<?php endif; ?>
</li>
<?php $first_parcel = false; ?>
<?php endforeach; ?>
</ol>
<?php if ( $status == 'new' ) : ?>
<button class="button easypack_add_parcel"><?php _e( 'Add parcel', EasyPack::$text_domain ); ?></button>
<?php endif; ?>
</p>
<?php
$custom_attributes = array( 'style' => 'width:100%;' );
if ( $disabled || $send_method_disabled ) {
$custom_attributes['disabled'] = 'disabled';
}
$params = array(
'type' => 'select',
'options' => $send_methods,
'class' => array('wc-enhanced-select'),
'custom_attributes' => $custom_attributes,
'label' => __( 'Send method', EasyPack::$text_domain ),
);
woocommerce_form_field('easypack_send_method', $params, $send_method );
?>
<p>
<?php if ( $status == 'new' ) : ?>
<button id="easypack_send_parcels" class="button button-primary"><?php _e('Send parcels', EasyPack::$text_domain ); ?></button>
<?php endif; ?>
<?php if ( EasyPack_API()->api_country() == 'PL' ) : ?>
<?php if ( $status == 'created' ) : ?>
<button id="easypack_cancel_parcels" class="button"><?php _e('Cancel parcels', EasyPack::$text_domain ); ?></button>
<?php endif; ?>
<?php endif; ?>
<?php if ( EasyPack_API()->api_country() == 'PL' ) : ?>
<?php if ( $status == 'created' || $status == 'prepared' ) : ?>
<a href="<?php echo $stickers_url; ?>" id="easypack_get_stickers" class="button button-primary" target="_blank"><?php _e('Get sticker(s)', EasyPack::$text_domain ); ?></a>
<?php endif; ?>
<?php endif; ?>
<?php if ( false) : ?>
<a href="<?php echo $tracking_url; ?>" class="button" target="_blank"><?php _e('Track shipment', EasyPack::$text_domain ); ?></a>
<?php endif; ?>
<span id="easypack_spinner" class="spinner"></span>
</p>
<p id="easypack_error"></p>
<a href="#" download id="easypack_download" hidden></a>
<script type="text/javascript">
jQuery(".easypack_add_parcel").click(function() {
var ul = jQuery('#easypack_parcels');
var li = ul.find('li:first').clone(true)
li.append('<button class="button easypack_remove_parcel"><?php _e( 'Remove', EasyPack::$text_domain ); ?></button>');
li.appendTo(ul);
return false;
});
jQuery("#easypack_parcels").on("click", ".easypack_remove_parcel", function() {
jQuery(this).parent().remove();
return false;
})
jQuery('#easypack_send_parcels').click(function () {
jQuery('#easypack_error').html('');
jQuery(this).attr('disabled',true);
jQuery("#easypack_spinner").addClass("is-active");
var parcels = [];
jQuery('select.easypack_parcel').each(function(i) {
parcels[i] = jQuery(this).val();
})
var data = {
action : 'easypack',
easypack_action : 'parcel_machines_create_package',
security : easypack_nonce,
order_id : <?php echo $order_id; ?>,
parcel_machine_id : jQuery('#parcel_machine_id').val(),
parcels : parcels,
send_method : jQuery('#easypack_send_method').val(),
};
jQuery.post(ajaxurl, data, function(response) {
console.log(response);
if ( response != 0 ) {
response = JSON.parse(response);
console.log(response);
if (response.status == 'ok' ) {
jQuery("#easypack_parcel_machines .inside").html(response.content);
return false;
}
else {
//alert(response.message);
jQuery('#easypack_error').html(response.message);
}
}
else {
//alert('Bad response.');
jQuery('#easypack_error').html('Invalid response.');
}
jQuery("#easypack_spinner").removeClass("is-active");
jQuery('#easypack_send_parcels').attr('disabled',false);
});
return false;
});
jQuery('#easypack_cancel_parcels').click(function () {
jQuery('#easypack_error').html('');
jQuery(this).attr('disabled',true);
jQuery("#easypack_spinner").addClass("is-active");
var data = {
action : 'easypack',
easypack_action : 'parcel_machines_cancel_package',
security : easypack_nonce,
order_id : <?php echo $order_id; ?>,
};
jQuery.post(ajaxurl, data, function(response) {
console.log(response);
if ( response != 0 ) {
response = JSON.parse(response);
console.log(response);
if (response.status == 'ok' ) {
jQuery("#easypack_parcel_machines .inside").html(response.content);
return false;
}
else {
//alert(response.message);
jQuery('#easypack_error').html(response.message);
}
}
else {
//alert('Bad response.');
jQuery('#easypack_error').html('Invalid response.');
}
jQuery("#easypack_spinner").removeClass("is-active");
jQuery('#easypack_cancel_parcels').attr('disabled',false);
});
return false;
});
</script>

View File

@@ -0,0 +1,244 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$first_parcel = true;
?>
<?php
$custom_attributes = array( 'style' => 'width:100%;' );
if ( $disabled ) {
$custom_attributes['disabled'] = 'disabled';
}
woocommerce_wp_text_input([
'id' => 'parcel_machine_id',
'label' => __('Selected parcel locker', EasyPack::$text_domain ),
'desc_tip' => false,
'value' => $parcel_machine_id,
'custom_attributes' => $custom_attributes,
'class' => 'settings-geowidget',
]);
?>
<p><?php _e( 'Parcels', EasyPack::$text_domain ); ?>
<ol id="easypack_parcels">
<?php foreach ( $parcels as $parcel ) : ?>
<li>
<?php if ( $status == 'new' ) : ?>
<?php
$params = array(
'type' => 'select',
'options' => $package_sizes,
'class' => array('easypack_parcel'),
'input_class' => array('easypack_parcel'),
'label' => '',
);
woocommerce_form_field('parcel[]', $params, $parcel['package_size'] );
?>
<?php _e( 'COD amount: ', EasyPack::$text_domain ); ?>
<input class="easypack_cod_amount" type="number" style="" value="<?php echo $parcel['cod_amount']; ?>" placeholder="0.00" step="any" min="0" name="cod_amount[]">
<?php if ( $status == 'new' && ! $first_parcel ) : ?>
<button class="button easypack_remove_parcel"><?php _e( 'Remove', EasyPack::$text_domain ); ?></button>
<?php endif; ?>
<?php else : ?>
<?php _e( 'Size', EasyPack::$text_domain ); ?> <?php echo $package_sizes_display[$parcel['package_size']]; ?>:
<?php echo $parcel['easypack_data']['id']; ?><br/>
<?php _e( 'COD amount', EasyPack::$text_domain ); ?> <?php echo $parcel['easypack_data']['cod_amount']; ?>
<?php endif; ?>
</li>
<?php $first_parcel = false; ?>
<?php endforeach; ?>
</ol>
<?php if ( $status == 'new' ) : ?>
<button class="button easypack_add_parcel"><?php _e( 'Add parcel', EasyPack::$text_domain ); ?></button>
<?php endif; ?>
</p>
<?php
$custom_attributes = array( 'style' => 'width:100%;' );
if ( $disabled || $send_method_disabled ) {
$custom_attributes['disabled'] = 'disabled';
}
$params = array(
'type' => 'select',
'options' => $send_methods,
'class' => array('wc-enhanced-select'),
'custom_attributes' => $custom_attributes,
'label' => __('Send method', EasyPack::$text_domain ),
);
woocommerce_form_field('easypack_send_method', $params, $send_method );
?>
<p>
<?php if ( $status == 'new' ) : ?>
<button id="easypack_send_parcels" class="button button-primary"><?php _e('Send parcels', EasyPack::$text_domain ); ?></button>
<?php endif; ?>
<?php if ( EasyPack_API()->api_country() == 'PL' ) : ?>
<?php if ( $status == 'created' ) : ?>
<button id="easypack_cancel_parcels" class="button"><?php _e('Cancel parcels', EasyPack::$text_domain ); ?></button>
<?php endif; ?>
<?php endif; ?>
<?php if ( EasyPack_API()->api_country() == 'PL' ) : ?>
<?php if ( $status == 'created' || $status == 'prepared' ) : ?>
<a href="<?php echo $stickers_url; ?>" id="easypack_get_stickers" class="button button-primary" target="_blank"><?php _e('Get sticker(s)', EasyPack::$text_domain ); ?></a>
<?php endif; ?>
<?php endif; ?>
<?php if ( $tracking_url ) : ?>
<a href="<?php echo $tracking_url; ?>" class="button" target="_blank"><?php _e('Track shipment', EasyPack::$text_domain ); ?></a>
<?php endif; ?>
<span id="easypack_spinner" class="spinner"></span>
</p>
<p id="easypack_error"></p>
<a href="#" download id="easypack_download" hidden></a>
<script type="text/javascript">
jQuery(".easypack_add_parcel").click(function() {
var ul = jQuery('#easypack_parcels');
var li = ul.find('li:first').clone(true)
li.append('<button class="button easypack_remove_parcel"><?php _e( 'Remove', EasyPack::$text_domain ); ?></button>');
li.appendTo(ul);
li.find(".easypack_cod_amount").val(0);
return false;
});
jQuery("#easypack_parcels").on("click", ".easypack_remove_parcel", function() {
jQuery(this).parent().remove();
return false;
})
jQuery('#easypack_send_parcels').click(function () {
jQuery('#easypack_error').html('');
jQuery(this).attr('disabled',true);
jQuery("#easypack_spinner").addClass("is-active");
var parcels = [];
jQuery('select.easypack_parcel').each(function(i) {
parcels[i] = jQuery(this).val();
})
var cod_amounts = [];
jQuery('input.easypack_cod_amount').each(function(i) {
cod_amounts[i] = jQuery(this).val();
})
var data = {
action : 'easypack',
easypack_action : 'parcel_machines_cod_create_package',
security : easypack_nonce,
order_id : <?php echo $order_id; ?>,
parcel_machine_id : jQuery('#parcel_machine_id').val(),
parcels : parcels,
cod_amounts : cod_amounts,
send_method : jQuery('#easypack_send_method').val(),
};
jQuery.post(ajaxurl, data, function(response) {
console.log(response);
if ( response != 0 ) {
response = JSON.parse(response);
console.log(response);
if (response.status == 'ok' ) {
jQuery("#easypack_parcel_machines .inside").html(response.content);
return false;
}
else {
//alert(response.message);
jQuery('#easypack_error').html(response.message);
}
}
else {
//alert('Bad response.');
jQuery('#easypack_error').html('Invalid response.');
}
jQuery("#easypack_spinner").removeClass("is-active");
jQuery('#easypack_send_parcels').attr('disabled',false);
});
return false;
});
jQuery('#easypack_cancel_parcels').click(function () {
jQuery('#easypack_error').html('');
jQuery(this).attr('disabled',true);
jQuery("#easypack_spinner").addClass("is-active");
var data = {
action : 'easypack',
easypack_action : 'parcel_machines_cod_cancel_package',
security : easypack_nonce,
order_id : <?php echo $order_id; ?>,
};
jQuery.post(ajaxurl, data, function(response) {
console.log(response);
if ( response != 0 ) {
response = JSON.parse(response);
console.log(response);
if (response.status == 'ok' ) {
jQuery("#easypack_parcel_machines .inside").html(response.content);
return false;
}
else {
//alert(response.message);
jQuery('#easypack_error').html(response.message);
}
}
else {
//alert('Bad response.');
jQuery('#easypack_error').html('Invalid response.');
}
jQuery("#easypack_spinner").removeClass("is-active");
jQuery('#easypack_cancel_parcels').attr('disabled',false);
});
return false;
});
jQuery('#easypack_get_stickers1').click(function () {
jQuery('#easypack_error').html('');
jQuery(this).attr('disabled',true);
jQuery("#easypack_spinner").addClass("is-active");
var data = {
action : 'easypack',
easypack_action : 'parcel_machines_get_stickers',
security : easypack_nonce,
order_id : <?php echo $order_id; ?>,
};
jQuery.post(ajaxurl, data, function(response) {
console.log(response);
if ( response != 0 ) {
response = JSON.parse(response);
console.log(response);
if (response.status == 'ok' ) {
var url = response.url;
//alert(url);
jQuery("#easypack_download").attr( "href", url );
jQuery("#easypack_download").click();
/*
if ( jQuery('#easypack_download').length ){
jQuery('#easypack_download').attr('src',url);
}
else {
jQuery('<iframe>', { id:'easypack_download', src:url }).hide().appendTo('body');
}
*/
jQuery("#easypack_spinner").removeClass("is-active");
jQuery('#easypack_get_stickers').attr('disabled',false);
return false;
}
else {
//alert(response.message);
jQuery('#easypack_error').html(response.message);
}
}
else {
//alert('Bad response.');
jQuery('#easypack_error').html('Invalid response.');
}
jQuery("#easypack_spinner").removeClass("is-active");
jQuery('#easypack_get_stickers').attr('disabled',false);
});
return false;
});
</script>

View File

@@ -0,0 +1,103 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$field = $this->get_field_key( $key );
?>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="woocommerce_easypack-parcel-machines_rates"><?php echo $data['title']; ?></label>
</th>
<td class="forminp">
<table id="<?php echo esc_attr( $field ); ?>" class="easypack_rates wc_input_table sortable widefat">
<thead>
<tr>
<th class="sort">&nbsp;</th>
<th class="price"><?php _e( 'Min', EasyPack::$text_domain ); ?></th>
<th class="price"><?php _e( 'Max', EasyPack::$text_domain ); ?></th>
<th class="price"><?php _e( 'Cost', EasyPack::$text_domain ); ?></th>
<th class="price"><?php _e( '%', EasyPack::$text_domain ); ?>&nbsp;<span class="tips" data-tip="<?php esc_attr_e( 'The commission is added to the shipping cost according to the formula: [value of the cart] * [%] + [shipping cost].', EasyPack::$text_domain ); ?>">[?]</span></th>
<th class="action"><?php _e( 'Action', EasyPack::$text_domain ); ?></th>
</tr>
</thead>
<tbody>
<?php $count = 0; ?>
<?php foreach ( $rates as $key => $rate) : $count++; ?>
<tr>
<td class="sort"></td>
<td class="price">
<input class="input-text regular-input" type="number" style="" value="<?php echo $rate['min']; ?>" placeholder="0.00" step="any" min="0" name=rates['<?php echo $count; ?>'][min]>
</td>
<td class="price">
<input class="input-text regular-input" type="number" style="" value="<?php echo $rate['max']; ?>" placeholder="0.00" step="any" min="0" name=rates['<?php echo $count; ?>'][max]>
</td>
<td class="price">
<input class="input-text regular-input" type="number" style="" value="<?php echo $rate['cost']; ?>" placeholder="0.00" step="any" min="0" name=rates['<?php echo $count; ?>'][cost]>
</td>
<td class="price">
<input class="input-text regular-input" type="number" style="" value="<?php echo $rate['percent']; ?>" placeholder="0.00" step="any" min="0" name=rates['<?php echo $count; ?>'][percent]>
</td>
<td class="action">
<a id="delete_rate_<?php echo $count; ?>" href="#" class="button delete_rate" data-id="<?php echo $count; ?>"><?php _e( 'Delete row', EasyPack::$text_domain ); ?></a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot>
<tr>
<th colspan="6">
<a id="insert_rate" href="#" class="button plus insert"><?php _e( 'Insert row', EasyPack::$text_domain ); ?></a>
</th>
</tr>
</tfoot>
</table>
<script type="text/javascript">
function append_row( id ) {
var code = '<tr class="new">\
<td class="sort"></td>\
<td>\
<input id="rates_'+id+'_min" class="input-text regular-input" type="number" style="" value="" placeholder="0.00" step="any" min="0" name=rates[' + id + '][min]>\
</td>\
<td>\
<input class="input-text regular-input" type="number" style="" value="" placeholder="0.00" step="any" min="0" name=rates[' + id + '][max]>\
</td>\
<td>\
<input class="input-text regular-input" type="number" style="" value="" placeholder="0.00" step="any" min="0" name=rates[' + id + '][cost]>\
</td>\
<td>\
<input class="input-text regular-input" type="number" style="" value="<?php echo $commission; ?>" placeholder="0.00" step="any" min="0" name=rates[' + id + '][percent]>\
</td>\
<td>\
<a id="delete_rate_'+id+'" href="#" class="button delete_rate" data-id="'+id+'"><?php _e( 'Delete row', EasyPack::$text_domain ); ?></a>\
</td>\
</tr>';
var $tbody = jQuery('.easypack_rates').find('tbody');
$tbody.append( code );
}
jQuery(document).ready(function() {
var $tbody = jQuery('.easypack_rates').find('tbody');
var append_id = $tbody.find('tr').size();
var size = $tbody.find('tr').size();
if ( size == 0 ) {
append_id = append_id+1;
append_row(append_id);
}
jQuery('#insert_rate').click(function() {
append_id = append_id+1;
append_row(append_id);
jQuery('#rates_'+append_id+'_min').focus();
return false;
});
jQuery(document).on('click', '.delete_rate', function() {
if (confirm('<?php _e( 'Are you sure?' , EasyPack::$text_domain ); ?>')) {
jQuery(this).closest('tr').remove();
}
return false;
});
});
</script>
</td>
</tr>

View File

@@ -0,0 +1,64 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$field = $this->get_field_key( $key );
?>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="woocommerce_easypack--cross-border-parcel-machines_rates"><?php echo $data['title']; ?></label>
<img class="help_tip" data-tip=" <?php _e( 'You can edit and set your own prices that will be seen when the customer is placing the order. If the products do not have a defined weight, the cost will be calculated incorrectly.', EasyPack::$text_domain ); ?>" src="<?php echo plugins_url( 'woocommerce/assets/images/help.png' ); ?>" height="16" width="16" />
</th>
<td class="forminp">
<table id="<?php echo esc_attr( $field ); ?>" class="easypack_rates wc_input_table sortable widefat">
<thead>
<tr>
<th class="country"><?php _e( 'Country', EasyPack::$text_domain ); ?></th>
<th class="price"><?php _e( '1 kg', EasyPack::$text_domain ); ?></th>
<th class="price"><?php _e( '2 kg', EasyPack::$text_domain ); ?></th>
<th class="price"><?php _e( '5 kg', EasyPack::$text_domain ); ?></th>
<th class="price"><?php _e( '10 kg', EasyPack::$text_domain ); ?></th>
<th class="price"><?php _e( '15 kg', EasyPack::$text_domain ); ?></th>
<th class="price"><?php _e( '20 kg', EasyPack::$text_domain ); ?></th>
<th class="price"><?php _e( '25 kg', EasyPack::$text_domain ); ?></th>
</tr>
</thead>
<tbody>
<?php $count = 0; ?>
<?php foreach ( $rates as $rate) : $count++; $key = $rate['country_code']; ?>
<tr>
<td class="country">
<strong><?php echo $countries[$key]; ?></strong>
</td>
<td class="price">
<input class="input-text regular-input" type="number" style="" value="<?php echo $rate['kg_1']; ?>" placeholder="0.00" step="any" min="0" name=rates[<?php echo $key; ?>][kg_1]>
</td>
<td class="price">
<input class="input-text regular-input" type="number" style="" value="<?php echo $rate['kg_2']; ?>" placeholder="0.00" step="any" min="0" name=rates[<?php echo $key; ?>][kg_2]>
</td>
<td class="price">
<input class="input-text regular-input" type="number" style="" value="<?php echo $rate['kg_5']; ?>" placeholder="0.00" step="any" min="0" name=rates[<?php echo $key; ?>][kg_5]>
</td>
<td class="price">
<input class="input-text regular-input" type="number" style="" value="<?php echo $rate['kg_10']; ?>" placeholder="0.00" step="any" min="0" name=rates[<?php echo $key; ?>][kg_10]>
</td>
<td class="price">
<input class="input-text regular-input" type="number" style="" value="<?php echo $rate['kg_15']; ?>" placeholder="0.00" step="any" min="0" name=rates[<?php echo $key; ?>][kg_15]>
</td>
<td class="price">
<input class="input-text regular-input" type="number" style="" value="<?php echo $rate['kg_20']; ?>" placeholder="0.00" step="any" min="0" name=rates[<?php echo $key; ?>][kg_20]>
</td>
<td class="price">
<input class="input-text regular-input" type="number" style="" value="<?php echo $rate['kg_25']; ?>" placeholder="0.00" step="any" min="0" name=rates[<?php echo $key; ?>][kg_25]>
</td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot>
</tfoot>
</table>
</td>
</tr>

View File

@@ -0,0 +1,63 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$field = $this->get_field_key( $key );
?>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="woocommerce_easypack--cross-border-parcel-machines_rates"><?php echo $data['title']; ?></label>
<img class="help_tip" data-tip=" <?php _e( 'You can edit and set your own prices that will be seen when the customer is placing the order. If the products do not have a defined weight, the cost will be calculated incorrectly.', EasyPack::$text_domain ); ?>" src="<?php echo plugins_url( 'woocommerce/assets/images/help.png' ); ?>" height="16" width="16" />
</th>
<td class="forminp">
<table id="<?php echo esc_attr( $field ); ?>" class="easypack_rates wc_input_table sortable widefat">
<thead>
<tr>
<th class="country"><?php _e( 'Country', EasyPack::$text_domain ); ?></th>
<th class="price"><?php _e( '1 kg', EasyPack::$text_domain ); ?></th>
<th class="price"><?php _e( '2 kg', EasyPack::$text_domain ); ?></th>
<th class="price"><?php _e( '5 kg', EasyPack::$text_domain ); ?></th>
<th class="price"><?php _e( '10 kg', EasyPack::$text_domain ); ?></th>
<th class="price"><?php _e( '15 kg', EasyPack::$text_domain ); ?></th>
<th class="price"><?php _e( '20 kg', EasyPack::$text_domain ); ?></th>
</tr>
</thead>
<tbody>
<?php $count = 0; ?>
<?php foreach ( $rates as $key => $rate) : $count++; ?>
<tr>
<td class="country">
<strong><?php echo $countries[$key]; ?></strong>
</td>
<td class="price">
<input class="input-text regular-input" type="number" style="" value="<?php echo $rate['kg_1']; ?>" placeholder="0.00" step="any" min="0" name=rates[<?php echo $key; ?>][kg_1]>
</td>
<td class="price">
<input class="input-text regular-input" type="number" style="" value="<?php echo $rate['kg_2']; ?>" placeholder="0.00" step="any" min="0" name=rates[<?php echo $key; ?>][kg_2]>
</td>
<td class="price">
<input class="input-text regular-input" type="number" style="" value="<?php echo $rate['kg_5']; ?>" placeholder="0.00" step="any" min="0" name=rates[<?php echo $key; ?>][kg_5]>
</td>
<td class="price">
<input class="input-text regular-input" type="number" style="" value="<?php echo $rate['kg_10']; ?>" placeholder="0.00" step="any" min="0" name=rates[<?php echo $key; ?>][kg_10]>
</td>
<td class="price">
<input class="input-text regular-input" type="number" style="" value="<?php echo $rate['kg_15']; ?>" placeholder="0.00" step="any" min="0" name=rates[<?php echo $key; ?>][kg_15]>
</td>
<td class="price">
<input class="input-text regular-input" type="number" style="" value="<?php echo $rate['kg_20']; ?>" placeholder="0.00" step="any" min="0" name=rates[<?php echo $key; ?>][kg_20]>
</td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot>
</tfoot>
</table>
</td>
</tr>

View File

@@ -0,0 +1,99 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$field = $this->get_field_key( $key );
?>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="woocommerce_easypack_parcel_machines_rates"><?php echo $data['title']; ?></label>
</th>
<td class="forminp">
<table id="<?php echo esc_attr( $field ); ?>" class="easypack_rates wc_input_table sortable widefat">
<thead>
<tr>
<th class="sort">&nbsp;</th>
<th><?php _e( 'Min', EasyPack::$text_domain ); ?></th>
<th><?php _e( 'Max', EasyPack::$text_domain ); ?></th>
<th><?php _e( 'Cost', EasyPack::$text_domain ); ?></th>
<th><?php _e( 'Action', EasyPack::$text_domain ); ?></th>
</tr>
</thead>
<tbody>
<?php $count = 0; ?>
<?php foreach ( $rates as $key => $rate) : $count++; ?>
<tr>
<td class="sort"></td>
<td>
<input class="input-text regular-input" type="number" style="" value="<?php echo $rate['min']; ?>" placeholder="0.00" step="any" min="0" name=rates['<?php echo $count; ?>'][min]>
</td>
<td>
<input class="input-text regular-input" type="number" style="" value="<?php echo $rate['max']; ?>" placeholder="0.00" step="any" min="0" name=rates['<?php echo $count; ?>'][max]>
</td>
<td>
<input class="input-text regular-input" type="number" style="" value="<?php echo $rate['cost']; ?>" placeholder="0.00" step="any" min="0" name=rates['<?php echo $count; ?>'][cost]>
</td>
<td>
<a id="delete_rate_<?php echo $count; ?>" href="#" class="button delete_rate" data-id="<?php echo $count; ?>"><?php _e( 'Delete row', EasyPack::$text_domain ); ?></a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot>
<tr>
<th colspan="5">
<a id="insert_rate" href="#" class="button plus insert"><?php _e( 'Insert row', EasyPack::$text_domain ); ?></a>
</th>
</tr>
</tfoot>
</table>
<script type="text/javascript">
function append_row( id ) {
var code = '<tr class="new">\
<td class="sort"></td>\
<td>\
<input id="rates_'+id+'_min" class="input-text regular-input" type="number" style="" value="" placeholder="0.00" step="any" min="0" name=rates[' + id + '][min]>\
</td>\
<td>\
<input class="input-text regular-input" type="number" style="" value="" placeholder="0.00" step="any" min="0" name=rates[' + id + '][max]>\
</td>\
<td>\
<input class="input-text regular-input" type="number" style="" value="" placeholder="0.00" step="any" min="0" name=rates[' + id + '][cost]>\
</td>\
<td>\
<a id="delete_rate_'+id+'" href="#" class="button delete_rate" data-id="'+id+'"><?php _e( 'Delete row', EasyPack::$text_domain ); ?></a>\
</td>\
</tr>';
var $tbody = jQuery('.easypack_rates').find('tbody');
$tbody.append( code );
}
jQuery(document).ready(function() {
var $tbody = jQuery('.easypack_rates').find('tbody');
var append_id = $tbody.find('tr').size();
var size = $tbody.find('tr').size();
if ( size == 0 ) {
append_id = append_id+1;
append_row(append_id);
}
jQuery('#insert_rate').click(function() {
append_id = append_id+1;
append_row(append_id);
jQuery('#rates_'+append_id+'_min').focus();
return false;
});
jQuery(document).on('click', '.delete_rate', function() {
if (confirm('<?php _e( 'Are you sure?' , EasyPack::$text_domain ); ?>')) {
jQuery(this).closest('tr').remove();
}
return false;
});
});
</script>
</td>
</tr>