version, '2.1', '>=') ? "wc-settings" : "woocommerce_settings"; // Don't forget to exit() because wp_redirect doesn't exit automatically exit( wp_redirect( admin_url( 'admin.php?page=' . $setting_value . '&tab=shipping§ion=az_dhlexpress' ) ) ); } } add_action( 'activated_plugin', 'hit_woo_dhl_express_plugin_activation' ); // Include the main WooCommerce class. if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { if( !class_exists('a2z_dhlexpress_parent') ){ Class a2z_dhlexpress_parent { private $errror = ''; public function __construct() { add_action( 'woocommerce_shipping_init', array($this,'a2z_dhlexpress_init') ); add_action( 'init', array($this,'hit_order_status_update') ); add_filter( 'woocommerce_shipping_methods', array($this,'a2z_dhlexpress_method') ); add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'a2z_dhlexpress_plugin_action_links' ) ); add_action( 'add_meta_boxes', array($this, 'create_dhl_shipping_meta_box' )); add_action( 'save_post', array($this, 'hit_create_dhl_shipping'), 10, 1 ); add_action( 'save_post', array($this, 'hit_create_dhl_return_shipping'), 10, 1 ); add_filter( 'bulk_actions-edit-shop_order', array($this, 'hit_bulk_order_menu'), 10, 1 ); add_filter( 'handle_bulk_actions-edit-shop_order', array($this, 'hit_bulk_create_order'), 10, 3 ); add_action( 'admin_notices', array($this, 'shipo_bulk_label_action_admin_notice' ) ); add_filter( 'woocommerce_product_data_tabs', array($this,'hit_product_data_tab') ); add_action( 'woocommerce_process_product_meta', array($this,'hit_save_product_options' )); add_filter( 'woocommerce_product_data_panels', array($this,'hit_product_option_view') ); add_action( 'admin_menu', array($this, 'hit_dhl_menu_page' )); add_filter( 'manage_edit-shop_order_columns', array($this, 'a2z_wc_new_order_column') ); // add_action( 'woocommerce_checkout_order_processed', array( $this, 'hit_wc_checkout_order_processed' ) ); // add_action( 'woocommerce_thankyou', array( $this, 'hit_wc_checkout_order_processed' ) ); add_action( 'woocommerce_order_status_processing', array( $this, 'hit_wc_checkout_order_processed' ) ); add_action('woocommerce_order_details_after_order_table', array( $this, 'dhl_track' ) ); add_action( 'manage_shop_order_posts_custom_column', array( $this, 'show_buttons_to_downlaod_shipping_label') ); add_action('admin_print_styles', array($this, 'hits_admin_scripts')); $general_settings = get_option('a2z_dhl_main_settings'); $general_settings = empty($general_settings) ? array() : $general_settings; if(isset($general_settings['a2z_dhlexpress_v_enable']) && $general_settings['a2z_dhlexpress_v_enable'] == 'yes' ){ add_action( 'woocommerce_product_options_shipping', array($this,'hit_choose_vendor_address' )); add_action( 'woocommerce_process_product_meta', array($this,'hit_save_product_meta' )); // Edit User Hooks add_action( 'edit_user_profile', array($this,'hit_define_dhl_credentails') ); add_action( 'edit_user_profile_update', array($this, 'save_user_fields' )); } } public function hits_admin_scripts() { global $wp_scripts; wp_enqueue_script('wc-enhanced-select'); wp_enqueue_script('chosen'); wp_enqueue_style('woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css'); } function a2z_wc_new_order_column( $columns ) { $columns['hit_dhlexpress'] = 'DHL Express'; return $columns; } function show_buttons_to_downlaod_shipping_label( $column ) { global $post; if ( 'hit_dhlexpress' === $column ) { $order = wc_get_order( $post->ID ); $json_data = get_option('hit_dhl_values_'.$post->ID); if(!empty($json_data)){ $array_data = json_decode( $json_data, true ); // echo '
';print_r($array_data);die();
if(isset($array_data[0])){
foreach ($array_data as $key => $value) {
echo ' ';
echo '
';
}
}else{
echo ' ';
echo ' ';
}
}else{
echo '-';
}
}
}
function hit_dhl_menu_page() {
$general_settings = get_option('a2z_dhl_main_settings');
if (isset($general_settings['a2z_dhlexpress_integration_key']) && !empty($general_settings['a2z_dhlexpress_integration_key'])) {
add_menu_page(__( 'DHL Labels', 'a2z_dhlexpress' ), 'DHL Labels', 'manage_options', 'hit-dhl-labels', array($this,'my_label_page_contents'), '', 6);
}
add_submenu_page( 'options-general.php', 'DHL Express Config', 'DHL Express Config', 'manage_options', 'hit-dhl-express-configuration', array($this, 'my_admin_page_contents') );
}
function my_label_page_contents(){
$general_settings = get_option('a2z_dhl_main_settings');
$url = site_url();
if (isset($general_settings['a2z_dhlexpress_integration_key']) && !empty($general_settings['a2z_dhlexpress_integration_key'])) {
echo "";
}
}
function my_admin_page_contents(){
include_once('controllors/views/a2z_dhlexpress_settings_view.php');
}
public function hit_product_data_tab( $tabs) {
$tabs['hits_product_options'] = array(
'label' => __( 'HITShipo - DHL Options', 'a2z_dhlexpress' ),
'target' => 'hit_dhl_product_options',
// 'class' => array( 'show_if_simple', 'show_if_variable' ),
);
return $tabs;
}
public function hit_save_product_options( $post_id ){
if( isset($_POST['hits_dhl_cc']) ){
$cc = sanitize_text_field($_POST['hits_dhl_cc']);
update_post_meta( $post_id, 'hits_dhl_cc', (string) esc_html( $cc ) );
// print_r($post_id);die();
}
if( isset($_POST['hits_dhl_export_reason']) ){
$cc = sanitize_text_field($_POST['hits_dhl_export_reason']);
update_post_meta( $post_id, 'hits_dhl_export_reason', (string) esc_html( $cc ) );
// print_r($post_id);die();
}
if( isset($_POST['hits_dhl_desc']) ){
$cc = sanitize_text_field($_POST['hits_dhl_desc']);
update_post_meta( $post_id, 'hits_dhl_desc', (string) esc_html( $cc ) );
// print_r($post_id);die();
}
if( isset($_POST['hits_dhl_danger_good_content_id']) ){
$cc = sanitize_text_field($_POST['hits_dhl_danger_good_content_id']);
update_post_meta( $post_id, 'hits_dhl_danger_good_content_id', (string) esc_html( $cc ) );
// print_r($post_id);die();
}
if( isset($_POST['hits_dhl_danger_good_label_description']) ){
$cc = sanitize_text_field($_POST['hits_dhl_danger_good_label_description']);
update_post_meta( $post_id, 'hits_dhl_danger_good_label_description', (string) esc_html( $cc ) );
// print_r($post_id);die();
}
if( isset($_POST['hits_dhl_danger_good_un_code']) ){
$cc = sanitize_text_field($_POST['hits_dhl_danger_good_un_code']);
update_post_meta( $post_id, 'hits_dhl_danger_good_un_code', (string) esc_html( $cc ) );
// print_r($post_id);die();
}
}
public function hit_product_option_view(){
global $woocommerce, $post;
$hits_dhl_saved_cc = get_post_meta( $post->ID, 'hits_dhl_cc', true);
$hits_dhl_saved_export_reason = get_post_meta( $post->ID, 'hits_dhl_export_reason', true);
$hits_dhl_saved_desc = get_post_meta( $post->ID, 'hits_dhl_desc', true);
$hits_dhl_saved_Dgs_contentid = get_post_meta( $post->ID, 'hits_dhl_danger_good_content_id', true);
$hits_dhl_saved_Dgs_label_desicribtion = get_post_meta( $post->ID, 'hits_dhl_danger_good_label_description', true);
$hits_dhl_saved_Dgs_un_code = get_post_meta( $post->ID, 'hits_dhl_danger_good_un_code', true);
?>
";print_r($actions);die();
$actions['create_label_shipo'] = __( 'Create Labels - HITShipo', 'a2z_dhlexpress' );
return $actions;
}
public function hit_bulk_create_order($redirect_to, $action, $order_ids){
$success = 0;
$failed = 0;
$failed_ids = [];
if($action == "create_label_shipo"){
if(!empty($order_ids)){
$create_shipment_for = "default";
$service_code = "N";
$ship_content = 'Shipment Content';
$pickup_mode = 'manual';
foreach($order_ids as $key => $order_id){
$order = wc_get_order( $order_id );
if($order){
$order_data = $order->get_data();
$order_id = $order_data['id'];
$order_currency = $order_data['currency'];
$order_shipping_first_name = $order_data['shipping']['first_name'];
$order_shipping_last_name = $order_data['shipping']['last_name'];
$order_shipping_company = empty($order_data['shipping']['company']) ? $order_data['shipping']['first_name'] : $order_data['shipping']['company'];
$order_shipping_address_1 = $order_data['shipping']['address_1'];
$order_shipping_address_2 = $order_data['shipping']['address_2'];
$order_shipping_city = $order_data['shipping']['city'];
$order_shipping_state = $order_data['shipping']['state'];
$order_shipping_postcode = $order_data['shipping']['postcode'];
$order_shipping_country = $order_data['shipping']['country'];
$order_shipping_phone = $order_data['billing']['phone'];
$order_shipping_email = $order_data['billing']['email'];
$items = $order->get_items();
$pack_products = array();
$general_settings = get_option('a2z_dhl_main_settings',array());
if($general_settings['a2z_dhlexpress_country'] != $order_shipping_country){
$service_code = "P";
}
foreach ( $items as $item ) {
$product_data = $item->get_data();
$product = array();
$product['product_name'] = str_replace('"', '', $product_data['name']);
$product['product_quantity'] = $product_data['quantity'];
$product['product_id'] = $product_data['product_id'];
$saved_cc = get_post_meta( $product_data['product_id'], 'hits_dhl_cc', true);
if(!empty($saved_cc)){
$product['commodity_code'] = $saved_cc;
}
$saved_desc = get_post_meta( $product_data['product_id'], 'hits_dhl_desc', true);
if(!empty($saved_desc)){
$product['invoice_desc'] = $saved_desc;
}
$dgs_contentid = get_post_meta( $product_data['product_id'], 'hits_dhl_danger_good_content_id', true);
if(!empty($dgs_contentid)){
$product['danger_good_contentid'] = $dgs_contentid;
}
$dgs_label_des = get_post_meta( $product_data['product_id'], 'hits_dhl_danger_good_label_description', true);
if(!empty($dgs_label_des)){
$product['danger_good_label_desci'] = $dgs_label_des;
}
$dgs_uncode = get_post_meta( $product_data['product_id'], 'hits_dhl_danger_good_un_code', true);
if(!empty($dgs_uncode)){
$product['danger_good_uncode'] = $dgs_uncode;
}
$product_variation_id = $item->get_variation_id();
if(empty($product_variation_id)){
$getproduct = wc_get_product( $product_data['product_id'] );
}else{
$getproduct = wc_get_product( $product_variation_id );
}
$woo_weight_unit = get_option('woocommerce_weight_unit');
$woo_dimension_unit = get_option('woocommerce_dimension_unit');
$dhl_mod_weight_unit = $dhl_mod_dim_unit = '';
if(!empty($general_settings['a2z_dhlexpress_weight_unit']) && $general_settings['a2z_dhlexpress_weight_unit'] == 'KG_CM')
{
$dhl_mod_weight_unit = 'kg';
$dhl_mod_dim_unit = 'cm';
}elseif(!empty($general_settings['a2z_dhlexpress_weight_unit']) && $general_settings['a2z_dhlexpress_weight_unit'] == 'LB_IN')
{
$dhl_mod_weight_unit = 'lbs';
$dhl_mod_dim_unit = 'in';
}
else
{
$dhl_mod_weight_unit = 'kg';
$dhl_mod_dim_unit = 'cm';
}
$product['sku'] = $getproduct->get_sku();
$product['price'] = (isset($product_data['total']) && isset($product_data['quantity'])) ? number_format(($product_data['total'] / $product_data['quantity']), 2) : 0;
if ($woo_dimension_unit != $dhl_mod_dim_unit) {
$prod_width = $getproduct->get_width();
$prod_height = $getproduct->get_height();
$prod_depth = $getproduct->get_length();
//wc_get_dimension( $dimension, $to_unit, $from_unit );
$product['width'] = round(wc_get_dimension( $prod_width, $dhl_mod_dim_unit, $woo_dimension_unit ), 2);
$product['height'] = round(wc_get_dimension( $prod_height, $dhl_mod_dim_unit, $woo_dimension_unit ), 2);
$product['depth'] = round(wc_get_dimension( $prod_depth, $dhl_mod_dim_unit, $woo_dimension_unit ), 2);
}else {
$product['width'] = $getproduct->get_width();
$product['height'] = $getproduct->get_height();
$product['depth'] = $getproduct->get_length();
}
if ($woo_weight_unit != $dhl_mod_weight_unit) {
$prod_weight = $getproduct->get_weight();
$product['weight'] = round(wc_get_weight( $prod_weight, $dhl_mod_weight_unit, $woo_weight_unit ), 2);
}else{
$product['weight'] = $getproduct->get_weight();
}
$pack_products[] = $product;
}
// $desination_country = (isset($order_data['shipping']['country']) && $order_data['shipping']['country'] != '') ? $order_data['shipping']['country'] : $order_data['billing']['country'];
// if(isset($general_settings['a2z_dhlexpress_country']) && $general_settings["a2z_dhlexpress_country"] == $desination_country && $general_settings["a2z_dhlexpress_country"] !='null'){
// $service_code = $general_settings['a2z_dhlexpress_Domestic_service'];
// }elseif(isset($general_settings['a2z_dhlexpress_country']) && $general_settings["a2z_dhlexpress_country"] != $desination_country && $general_settings["a2z_dhlexpress_country"] !='null'){
// $service_code = $general_settings['a2z_dhlexpress_international_service'];
// }
$custom_settings = array();
$custom_settings['default'] = array(
'a2z_dhlexpress_site_id' => $general_settings['a2z_dhlexpress_site_id'],
'a2z_dhlexpress_site_pwd' => $general_settings['a2z_dhlexpress_site_pwd'],
'a2z_dhlexpress_acc_no' => $general_settings['a2z_dhlexpress_acc_no'],
'a2z_dhlexpress_import_no' => $general_settings['a2z_dhlexpress_import_no'],
'a2z_dhlexpress_shipper_name' => $general_settings['a2z_dhlexpress_shipper_name'],
'a2z_dhlexpress_company' => $general_settings['a2z_dhlexpress_company'],
'a2z_dhlexpress_mob_num' => $general_settings['a2z_dhlexpress_mob_num'],
'a2z_dhlexpress_email' => $general_settings['a2z_dhlexpress_email'],
'a2z_dhlexpress_address1' => $general_settings['a2z_dhlexpress_address1'],
'a2z_dhlexpress_address2' => $general_settings['a2z_dhlexpress_address2'],
'a2z_dhlexpress_city' => $general_settings['a2z_dhlexpress_city'],
'a2z_dhlexpress_state' => $general_settings['a2z_dhlexpress_state'],
'a2z_dhlexpress_zip' => $general_settings['a2z_dhlexpress_zip'],
'a2z_dhlexpress_country' => $general_settings['a2z_dhlexpress_country'],
'a2z_dhlexpress_gstin' => $general_settings['a2z_dhlexpress_gstin'],
'a2z_dhlexpress_con_rate' => $general_settings['a2z_dhlexpress_con_rate'],
'service_code' => $service_code,
'a2z_dhlexpress_label_email' => $general_settings['a2z_dhlexpress_label_email'],
);
$vendor_settings = array();
if(isset($general_settings['a2z_dhlexpress_v_enable']) && $general_settings['a2z_dhlexpress_v_enable'] == 'yes' && isset($general_settings['a2z_dhlexpress_v_labels']) && $general_settings['a2z_dhlexpress_v_labels'] == 'yes'){
// Multi Vendor Enabled
foreach ($pack_products as $key => $value) {
$product_id = $value['product_id'];
$dhl_account = get_post_meta($product_id,'dhl_express_address', true);
if(empty($dhl_account) || $dhl_account == 'default'){
$dhl_account = 'default';
if (!isset($vendor_settings[$dhl_account])) {
$vendor_settings[$dhl_account] = $custom_settings['default'];
}
$vendor_settings[$dhl_account]['products'][] = $value;
}
if($dhl_account != 'default'){
$user_account = get_post_meta($dhl_account,'a2z_dhl_vendor_settings', true);
$user_account = empty($user_account) ? array() : $user_account;
if(!empty($user_account)){
if(!isset($vendor_settings[$dhl_account])){
$vendor_settings[$dhl_account] = $custom_settings['default'];
if($user_account['a2z_dhlexpress_site_id'] != '' && $user_account['a2z_dhlexpress_site_pwd'] != '' && $user_account['a2z_dhlexpress_acc_no'] != ''){
$vendor_settings[$dhl_account]['a2z_dhlexpress_site_id'] = $user_account['a2z_dhlexpress_site_id'];
if($user_account['a2z_dhlexpress_site_pwd'] != ''){
$vendor_settings[$dhl_account]['a2z_dhlexpress_site_pwd'] = $user_account['a2z_dhlexpress_site_pwd'];
}
if($user_account['a2z_dhlexpress_acc_no'] != ''){
$vendor_settings[$dhl_account]['a2z_dhlexpress_acc_no'] = $user_account['a2z_dhlexpress_acc_no'];
}
$vendor_settings[$dhl_account]['a2z_dhlexpress_import_no'] = !empty($user_account['a2z_dhlexpress_import_no']) ? $user_account['a2z_dhlexpress_import_no'] : '';
}
if ($user_account['a2z_dhlexpress_address1'] != '' && $user_account['a2z_dhlexpress_city'] != '' && $user_account['a2z_dhlexpress_state'] != '' && $user_account['a2z_dhlexpress_zip'] != '' && $user_account['a2z_dhlexpress_country'] != '' && $user_account['a2z_dhlexpress_shipper_name'] != '') {
if($user_account['a2z_dhlexpress_shipper_name'] != ''){
$vendor_settings[$dhl_account]['a2z_dhlexpress_shipper_name'] = $user_account['a2z_dhlexpress_shipper_name'];
}
if($user_account['a2z_dhlexpress_company'] != ''){
$vendor_settings[$dhl_account]['a2z_dhlexpress_company'] = $user_account['a2z_dhlexpress_company'];
}
if($user_account['a2z_dhlexpress_mob_num'] != ''){
$vendor_settings[$dhl_account]['a2z_dhlexpress_mob_num'] = $user_account['a2z_dhlexpress_mob_num'];
}
if($user_account['a2z_dhlexpress_email'] != ''){
$vendor_settings[$dhl_account]['a2z_dhlexpress_email'] = $user_account['a2z_dhlexpress_email'];
}
if ($user_account['a2z_dhlexpress_address1'] != '') {
$vendor_settings[$dhl_account]['a2z_dhlexpress_address1'] = $user_account['a2z_dhlexpress_address1'];
}
$vendor_settings[$dhl_account]['a2z_dhlexpress_address2'] = $user_account['a2z_dhlexpress_address2'];
if($user_account['a2z_dhlexpress_city'] != ''){
$vendor_settings[$dhl_account]['a2z_dhlexpress_city'] = $user_account['a2z_dhlexpress_city'];
}
if($user_account['a2z_dhlexpress_state'] != ''){
$vendor_settings[$dhl_account]['a2z_dhlexpress_state'] = $user_account['a2z_dhlexpress_state'];
}
if($user_account['a2z_dhlexpress_zip'] != ''){
$vendor_settings[$dhl_account]['a2z_dhlexpress_zip'] = $user_account['a2z_dhlexpress_zip'];
}
if($user_account['a2z_dhlexpress_country'] != ''){
$vendor_settings[$dhl_account]['a2z_dhlexpress_country'] = $user_account['a2z_dhlexpress_country'];
}
$vendor_settings[$dhl_account]['a2z_dhlexpress_gstin'] = $user_account['a2z_dhlexpress_gstin'];
$vendor_settings[$dhl_account]['a2z_dhlexpress_con_rate'] = $user_account['a2z_dhlexpress_con_rate'];
}
if(isset($general_settings['a2z_dhlexpress_v_email']) && $general_settings['a2z_dhlexpress_v_email'] == 'yes'){
$user_dat = get_userdata($dhl_account);
$vendor_settings[$dhl_account]['a2z_dhlexpress_label_email'] = $user_dat->data->user_email;
}
if($order_data['shipping']['country'] != $vendor_settings[$dhl_account]['a2z_dhlexpress_country']){
$vendor_settings[$dhl_account]['service_code'] = empty($service_code) ? $user_account['a2z_dhlexpress_def_inter'] : $service_code;
}else{
$vendor_settings[$dhl_account]['service_code'] = empty($service_code) ? $user_account['a2z_dhlexpress_def_dom'] : $service_code;
}
}
$vendor_settings[$dhl_account]['products'][] = $value;
}
}
}
}
if(empty($vendor_settings)){
$custom_settings['default']['products'] = $pack_products;
}else{
$custom_settings = $vendor_settings;
}
if(!empty($general_settings) && isset($general_settings['a2z_dhlexpress_integration_key']) && isset($custom_settings[$create_shipment_for])){
$mode = 'live';
if(isset($general_settings['a2z_dhlexpress_test']) && $general_settings['a2z_dhlexpress_test']== 'yes'){
$mode = 'test';
}
$execution = 'manual';
$boxes_to_shipo = array();
if (isset($general_settings['a2z_dhlexpress_packing_type']) && $general_settings['a2z_dhlexpress_packing_type'] == "box") {
if (isset($general_settings['a2z_dhlexpress_boxes']) && !empty($general_settings['a2z_dhlexpress_boxes'])) {
foreach ($general_settings['a2z_dhlexpress_boxes'] as $box) {
if ($box['enabled'] != 1) {
continue;
}else {
$boxes_to_shipo[] = $box;
}
}
}
}
global $dhl_core;
$frm_curr = get_option('woocommerce_currency');
$to_curr = isset($dhl_core[$custom_settings[$create_shipment_for]['a2z_dhlexpress_country']]) ? $dhl_core[$custom_settings[$create_shipment_for]['a2z_dhlexpress_country']]['currency'] : '';
$curr_con_rate = ( isset($custom_settings[$create_shipment_for]['a2z_dhlexpress_con_rate']) && !empty($custom_settings[$create_shipment_for]['a2z_dhlexpress_con_rate']) ) ? $custom_settings[$create_shipment_for]['a2z_dhlexpress_con_rate'] : 0;
if (!empty($frm_curr) && !empty($to_curr) && ($frm_curr != $to_curr) ) {
if (isset($general_settings['a2z_dhlexpress_auto_con_rate']) && $general_settings['a2z_dhlexpress_auto_con_rate'] == "yes") {
$current_date = date('m-d-Y', time());
$ex_rate_data = get_option('a2z_dhl_ex_rate'.$create_shipment_for);
$ex_rate_data = !empty($ex_rate_data) ? $ex_rate_data : array();
if (empty($ex_rate_data) || (isset($ex_rate_data['date']) && $ex_rate_data['date'] != $current_date) ) {
if (isset($custom_settings[$create_shipment_for]['a2z_dhlexpress_country']) && !empty($custom_settings[$create_shipment_for]['a2z_dhlexpress_country']) && isset($general_settings['a2z_dhlexpress_integration_key']) && !empty($general_settings['a2z_dhlexpress_integration_key'])) {
$ex_rate_Request = json_encode(array('integrated_key' => $general_settings['a2z_dhlexpress_integration_key'],
'from_curr' => $frm_curr,
'to_curr' => $to_curr));
$ex_rate_url = "https://app.hitshipo.com/get_exchange_rate.php";
// $ex_rate_url = "http://localhost/hitshipo/get_exchange_rate.php";
$ex_rate_response = wp_remote_post( $ex_rate_url , array(
'method' => 'POST',
'timeout' => 45,
'redirection' => 5,
'httpversion' => '1.0',
'blocking' => true,
'headers' => array('Content-Type' => 'application/json; charset=utf-8'),
'body' => $ex_rate_Request,
'sslverify' => FALSE
)
);
$ex_rate_result = ( is_array($ex_rate_response) && isset($ex_rate_response['body'])) ? json_decode($ex_rate_response['body'], true) : array();
if ( !empty($ex_rate_result) && isset($ex_rate_result['ex_rate']) && $ex_rate_result['ex_rate'] != "Not Found" ) {
$ex_rate_result['date'] = $current_date;
update_option('a2z_dhl_ex_rate'.$create_shipment_for, $ex_rate_result);
}else {
if (!empty($ex_rate_data)) {
$ex_rate_data['date'] = $current_date;
update_option('a2z_dhl_ex_rate'.$create_shipment_for, $ex_rate_data);
}
}
}
}
$get_ex_rate = get_option('a2z_dhl_ex_rate'.$create_shipment_for, '');
$get_ex_rate = !empty($get_ex_rate) ? $get_ex_rate : array();
$curr_con_rate = ( !empty($get_ex_rate) && isset($get_ex_rate['ex_rate']) ) ? $get_ex_rate['ex_rate'] : 0;
}
}
$c_codes = [];
foreach($custom_settings[$create_shipment_for]['products'] as $prod_to_shipo_key => $prod_to_shipo){
$saved_cc = get_post_meta( $prod_to_shipo['product_id'], 'hits_dhl_cc', true);
if(!empty($saved_cc)){
$c_codes[] = $saved_cc;
}
if (!empty($frm_curr) && !empty($to_curr) && ($frm_curr != $to_curr) ) {
if ($curr_con_rate > 0) {
$custom_settings[$create_shipment_for]['products'][$prod_to_shipo_key]['price'] = $prod_to_shipo['price'] * $curr_con_rate;
}
}
}
$data = array();
$data['integrated_key'] = $general_settings['a2z_dhlexpress_integration_key'];
$data['order_id'] = $order_id;
$data['exec_type'] = $execution;
$data['mode'] = $mode;
$data['carrier_type'] = 'dhl';
$data['meta'] = array(
"site_id" => $custom_settings[$create_shipment_for]['a2z_dhlexpress_site_id'],
"password" => $custom_settings[$create_shipment_for]['a2z_dhlexpress_site_pwd'],
"accountnum" => $custom_settings[$create_shipment_for]['a2z_dhlexpress_acc_no'],
"t_company" => $order_shipping_company,
"t_address1" => str_replace('"', '', $order_shipping_address_1),
"t_address2" => str_replace('"', '', $order_shipping_address_2),
"t_city" => $order_shipping_city,
"t_state" => $order_shipping_state,
"t_postal" => $order_shipping_postcode,
"t_country" => $order_shipping_country,
"t_name" => $order_shipping_first_name . ' '. $order_shipping_last_name,
"t_phone" => $order_shipping_phone,
"t_email" => $order_shipping_email,
"dutiable" => $general_settings['a2z_dhlexpress_duty_payment'],
"insurance" => $general_settings['a2z_dhlexpress_insure'],
"pack_this" => "Y",
"products" => $custom_settings[$create_shipment_for]['products'],
"pack_algorithm" => $general_settings['a2z_dhlexpress_packing_type'],
"boxes" => $boxes_to_shipo,
"max_weight" => $general_settings['a2z_dhlexpress_max_weight'],
"plt" => ($general_settings['a2z_dhlexpress_ppt'] == 'yes') ? "Y" : "N",
"airway_bill" => ($general_settings['a2z_dhlexpress_aabill'] == 'yes') ? "Y" : "N",
"sd" => ($general_settings['a2z_dhlexpress_sat'] == 'yes') ? "Y" : "N",
"cod" => ($general_settings['a2z_dhlexpress_cod'] == 'yes') ? "Y" : "N",
"service_code" => $custom_settings[$create_shipment_for]['service_code'],
"email_alert" => ( isset($general_settings['a2z_dhlexpress_email_alert']) && ($general_settings['a2z_dhlexpress_email_alert'] == 'yes') ) ? "Y" : "N",
"shipment_content" => $ship_content,
"danger_goods_item" => isset($general_settings['a2z_dhlexpress_dgs']) ? $general_settings['a2z_dhlexpress_dgs'] : 'no',
"s_company" => $custom_settings[$create_shipment_for]['a2z_dhlexpress_company'],
"s_address1" => $custom_settings[$create_shipment_for]['a2z_dhlexpress_address1'],
"s_address2" => $custom_settings[$create_shipment_for]['a2z_dhlexpress_address2'],
"s_city" => $custom_settings[$create_shipment_for]['a2z_dhlexpress_city'],
"s_state" => $custom_settings[$create_shipment_for]['a2z_dhlexpress_state'],
"s_postal" => $custom_settings[$create_shipment_for]['a2z_dhlexpress_zip'],
"s_country" => $custom_settings[$create_shipment_for]['a2z_dhlexpress_country'],
"gstin" => $custom_settings[$create_shipment_for]['a2z_dhlexpress_gstin'],
"s_name" => $custom_settings[$create_shipment_for]['a2z_dhlexpress_shipper_name'],
"s_phone" => $custom_settings[$create_shipment_for]['a2z_dhlexpress_mob_num'],
"s_email" => $custom_settings[$create_shipment_for]['a2z_dhlexpress_email'],
"label_size" => $general_settings['a2z_dhlexpress_print_size'],
"sent_email_to" => $custom_settings[$create_shipment_for]['a2z_dhlexpress_label_email'],
"pic_exec_type" => $pickup_mode,
"pic_loc_type" => (isset($general_settings['a2z_dhlexpress_pickup_loc_type']) ? $general_settings['a2z_dhlexpress_pickup_loc_type'] : ''),
"pic_pac_loc" => (isset($general_settings['a2z_dhlexpress_pickup_pac_loc']) ? $general_settings['a2z_dhlexpress_pickup_pac_loc'] : ''),
"pic_contact_per" => (isset($general_settings['a2z_dhlexpress_pickup_per_name']) ? $general_settings['a2z_dhlexpress_pickup_per_name'] : ''),
"pic_contact_no" => (isset($general_settings['a2z_dhlexpress_pickup_per_contact_no']) ? $general_settings['a2z_dhlexpress_pickup_per_contact_no'] : ''),
"pic_door_to" => (isset($general_settings['a2z_dhlexpress_pickup_door_to']) ? $general_settings['a2z_dhlexpress_pickup_door_to'] : ''),
"pic_type" => (isset($general_settings['a2z_dhlexpress_pickup_type']) ? $general_settings['a2z_dhlexpress_pickup_type'] : ''),
"pic_days_after" => (isset($general_settings['a2z_dhlexpress_pickup_date']) ? $general_settings['a2z_dhlexpress_pickup_date'] : ''),
"pic_open_time" => (isset($general_settings['a2z_dhlexpress_pickup_open_time']) ? $general_settings['a2z_dhlexpress_pickup_open_time'] : ''),
"pic_close_time" => (isset($general_settings['a2z_dhlexpress_pickup_close_time']) ? $general_settings['a2z_dhlexpress_pickup_close_time'] : ''),
"pic_mail_date" => date('c'),
"pic_date" => date("Y-m-d"),
"payment_con" => (isset($general_settings['a2z_dhlexpress_pay_con']) ? $general_settings['a2z_dhlexpress_pay_con'] : 'S'),
"cus_payment_con" => (isset($general_settings['a2z_dhlexpress_cus_pay_con']) ? $general_settings['a2z_dhlexpress_cus_pay_con'] : ''),
"translation" => ( (isset($general_settings['a2z_dhlexpress_translation']) && $general_settings['a2z_dhlexpress_translation'] == "yes" ) ? 'Y' : 'N'),
"translation_key" => (isset($general_settings['a2z_dhlexpress_translation_key']) ? $general_settings['a2z_dhlexpress_translation_key'] : ''),
"commodity_code" => $c_codes,
"ship_price" => isset($order_data['shipping_total']) ? $order_data['shipping_total'] : 0,
"order_total" => isset($order_data['total']) ? $order_data['total'] : 0,
"order_total_tax" => isset($order_data['total_tax']) ? $order_data['total_tax'] : 0,
"label" => $create_shipment_for,
"export_reason" => (isset($general_settings['a2z_dhlexpress_export_reason']) ? $general_settings['a2z_dhlexpress_export_reason'] : 'P')
);
//Bulk shipment
$bulk_shipment_url = "https://app.hitshipo.com/label_api/create_shipment.php";
// $bulk_shipment_url = "http://localhost/hitshipo/label_api/create_shipment.php";
$response = wp_remote_post( $bulk_shipment_url , array(
'method' => 'POST',
'timeout' => 45,
'redirection' => 5,
'httpversion' => '1.0',
'blocking' => true,
'headers' => array('Content-Type' => 'application/json; charset=utf-8'),
'body' => json_encode($data),
'sslverify' => FALSE
)
);
$output = json_decode($response['body'],true);
if($output){
if(isset($output['status']) || isset($output['pickup_status'])){
if(isset($output['status']) && $output['status'] != 'success'){
// update_option('hit_dhl_status_'.$order_id, $output['status'][0]);
$failed += 1;
$failed_ids[] = $order_id;
}else if(isset($output['status']) && $output['status'] == 'success'){
$output['user_id'] = $create_shipment_for;
$result_arr = array();
$data = get_option('hit_dhl_values_'.$order_id, array());
if($data){
$result_arr = json_decode($data, true);
}
$result_arr[] = $output;
update_option('hit_dhl_values_'.$order_id, json_encode($result_arr));
$success += 1;
}
if (isset($output['pickup_status']) && $output['pickup_status'] != 'Success') {
$pic_res['status'] = "failed";
update_option('hit_dhl_pickup_values_'.$order_id, json_encode($pic_res));
}elseif (isset($output['pickup_status']) && $output['pickup_status'] == 'Success') {
$pic_res['confirm_no'] = $output['pickup_confirm_no'];
$pic_res['ready_time'] = $output['pickup_ready_time'];
$pic_res['pickup_date'] = $output['pickup_date'];
$pic_res['status'] = "success";
update_option('hit_dhl_pickup_values_'.$order_id, json_encode($pic_res));
}
}else{
$failed += 1;
$failed_ids[] = $order_id;
}
}else{
$failed += 1;
$failed_ids[] = $order_id;
}
}
}else{
$failed += 1;
}
}
return $redirect_to = add_query_arg( array(
'success_lbl' => $success,
'failed_lbl' => $failed,
// 'failed_lbl_ids' => implode( ',', rtrim($failed_ids, ",") ),
), $redirect_to );
}
}
}
function shipo_bulk_label_action_admin_notice() {
if(isset($_GET['success_lbl']) && isset($_GET['failed_lbl'])){
printf( '
Generated labels: '. esc_html($_GET['success_lbl']) .' Failed Label: '. esc_html($_GET['failed_lbl']).'
');
}
}
public function dhl_track($order){
$general_settings = get_option('a2z_dhl_main_settings',array());
$order_id = $order->get_id();
$json_data = get_option('hit_dhl_values_'.$order_id);
if (!empty($json_data) && isset($general_settings['a2z_dhlexpress_trk_status_cus']) && $general_settings['a2z_dhlexpress_trk_status_cus'] == "yes") {
$array_data_to_track = json_decode($json_data, true);
$track_datas = array();
if (isset($array_data_to_track[0])) {
$track_datas = $array_data_to_track;
}else {
$track_datas[] = $array_data_to_track;
}
$trk_count = 1;
$tot_trk_count = count($track_datas);
// echo '';print_r($array_data_to_track);echo '
'; print_r($track_datas);die();
if ($track_datas) {
echo '
DHL Express Tracking';
foreach ($track_datas as $value) {
if (isset($general_settings['a2z_dhlexpress_site_id']) && isset($general_settings['a2z_dhlexpress_site_pwd'])) {
$trk_no = $value['tracking_num'];
$user_id = $value['user_id']; //Test track No : 2192079993 '.$trk_no.'
$xml = '
2002-06-25T11:28:56-08:00
1234567890123456789012345678
'.$general_settings['a2z_dhlexpress_site_id'].'
'.$general_settings['a2z_dhlexpress_site_pwd'].'
en
'.$trk_no.'
ALL_CHECK_POINTS
B
';
$result = wp_remote_post( "https://xmlpi-ea.dhl.com/XMLShippingServlet" , array(
'method' => 'POST',
'timeout' => 45,
'redirection' => 5,
'httpversion' => '1.0',
'blocking' => true,
'body' => $xml,
'sslverify' => FALSE
)
);
if (!empty($result)) {
$xml = simplexml_load_string($result['body']);
$xml = json_decode(json_encode($xml), true);
// echo '';print_r($xml);die();
if(isset($xml['AWBInfo']['ShipmentInfo']['ShipmentEvent']) && $xml['AWBInfo']['ShipmentInfo']['ShipmentEvent']){
$events = $xml['AWBInfo']['ShipmentInfo']['ShipmentEvent'];
$last_event_status = '';
$event_count = count($events);
if (isset($events[$event_count -1])) {
$last_event_status = $events[$event_count -1]['ServiceEvent']['Description'];
}
$to_disp = '
Package Status: '.$last_event_status.'
Package '.$trk_count.' of '.$tot_trk_count.'
Tracking No: '.$trk_no.'
';
foreach ($events as $key => $value) {
$event_status = $value['ServiceEvent']['Description'];
$event_loc = $value['ServiceArea']['Description'];
$event_time = date('h:i - A', strtotime($value['Time']));
$event_date = date('M d Y', strtotime($value['Date']));
// echo '
';echo 'XML
';print_r($value);print_r($events);die();
$to_disp .= '
'.$event_date.'
'.$event_time.'
';
if ($value['ServiceEvent']['EventCode'] == "OK") {
$to_disp .= '
';
}else {
$to_disp .= '
';
}
$to_disp .= '
'.$event_status.'
'.$event_loc.'
';
}
$to_disp .= '';
}else {
$to_disp = 'Sorry! No data found for this package...
';
echo $to_disp;
return;
}
}else {
$to_disp = ' "technical name",
'1' => 'DOMESTIC EXPRESS 12:00',
'2' => 'B2C',
'3' => 'B2C',
'4' => 'JETLINE',
'5' => 'SPRINTLINE',
'7' => 'EXPRESS EASY',
'8' => 'EXPRESS EASY',
'9' => 'EUROPACK',
'B' => 'BREAKBULK EXPRESS',
'C' => 'MEDICAL EXPRESS',
'D' => 'EXPRESS WORLDWIDE',
'E' => 'EXPRESS 9:00',
'F' => 'FREIGHT WORLDWIDE',
'G' => 'DOMESTIC ECONOMY SELECT',
'H' => 'ECONOMY SELECT',
'I' => 'DOMESTIC EXPRESS 9:00',
'J' => 'JUMBO BOX',
'K' => 'EXPRESS 9:00',
'L' => 'EXPRESS 10:30',
'M' => 'EXPRESS 10:30',
'N' => 'DOMESTIC EXPRESS',
'O' => 'DOMESTIC EXPRESS 10:30',
'P' => 'EXPRESS WORLDWIDE',
'Q' => 'MEDICAL EXPRESS',
'R' => 'GLOBALMAIL BUSINESS',
'S' => 'SAME DAY',
'T' => 'EXPRESS 12:00',
'U' => 'EXPRESS WORLDWIDE',
'V' => 'EUROPACK',
'W' => 'ECONOMY SELECT',
'X' => 'EXPRESS ENVELOPE',
'Y' => 'EXPRESS 12:00'
);
echo '
DHL Express - HITShipo
';
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
";print_r($custom_settings);die();
$json_data = get_option('hit_dhl_values_'.$order_id);
$pickup_json_data = get_option('hit_dhl_pickup_values_'.$order_id);
$rate_json_data = get_option('hit_dhl_order_rates_'.$order_id);
// echo $pickup_json_data;
$notice = get_option('hit_dhl_status_'.$order_id, null);
if($notice && $notice != 'success'){
echo "".$notice."
";
delete_option('hit_dhl_status_'.$order_id);
}
if(!empty($json_data)){
$array_data = json_decode( $json_data, true );
// echo '';print_r($array_data);die();
if(isset($array_data[0])){
foreach ($array_data as $key => $value) {
if(isset($value['user_id'])){
unset($custom_settings[$value['user_id']]);
}
if(isset($value['user_id']) && $value['user_id'] == 'default'){
echo '
Default Account
';
}else{
$user = get_user_by( 'id', $value['user_id'] );
echo '
Account: '.$user->display_name.'
';
}
echo ' Shipping Label ';
echo ' Invoice
';
if(isset($value['slip'])){
echo ' Packing Slip
';
}
}
}else{
$custom_settings = array();
echo ' Shipping Label ';
echo ' Invoice ';
if(isset($array_data['slip'])){
echo ' Packing Slip ';
}
}
}
$rate_data = [];
if (!empty($rate_json_data)) {
$rate_data = json_decode( $rate_json_data, true );
delete_option('hit_dhl_order_rates_'.$order_id);
}
$woo_curr = get_option('woocommerce_currency');
global $dhl_core;
foreach ($custom_settings as $ukey => $value) {
$general_settings['a2z_dhlexpress_currency'] = isset($dhl_core[(isset($value['a2z_dhlexpress_country']) ? $value['a2z_dhlexpress_country'] : 'A2Z')]) ? $dhl_core[$value['a2z_dhlexpress_country']]['currency'] : '';
$dhl_packs = $this->hit_get_dhl_packages($value['products'], $general_settings, $general_settings['a2z_dhlexpress_currency']);
// echo "";print_r($dhl_packs);die();
if($ukey == 'default'){
echo '
Default Account';
if (isset($rate_data[$ukey]) && !empty($rate_data[$ukey])) {
foreach ($rate_data[$ukey] as $rate_code => $rate_cost) {
if (isset($general_settings['a2z_dhlexpress_carrier'][$rate_code]) && $general_settings['a2z_dhlexpress_carrier'][$rate_code] == "yes") {
echo '
';
}
}
} else {
echo '
';
echo '
Shipment Content';
echo '
';
echo '
Reason for Export:
';
echo '
Duty Payment Type:
';
echo apply_filters("hitdhl_custom_fields", '', 'default');
echo "
";
_e('');
_e('');
_e('Customize packages
');
_e('
');
_e('');
echo ' Create Pickup along with shipment.
';
echo '';
}else{
$user = get_user_by( 'id', $ukey );
echo '
Account: '.$user->display_name.'';
if (isset($rate_data[$ukey]) && !empty($rate_data[$ukey])) {
foreach ($rate_data[$ukey] as $rate_code => $rate_cost) {
if (isset($general_settings['a2z_dhlexpress_carrier'][$rate_code]) && $general_settings['a2z_dhlexpress_carrier'][$rate_code] == "yes") {
echo '
';
}
}
} else {
echo '
';
echo '
Shipment Content';
echo '
';
echo '
Reason for Export:
';
echo '
Duty Payment Type:
';
echo apply_filters("hitdhl_custom_fields", '', $ukey);
echo "
";
_e('');
_e('');
_e('Customize packages
');
_e('
');
_e('');
echo ' Create Pickup along with shipment.
';
echo '
';
}
}
if (!empty($pickup_json_data) && empty($json_data)) {
$pickup_array_data = json_decode( $pickup_json_data, true );
if (isset($pickup_array_data['status']) && $pickup_array_data['status'] == "failed") {
echo "
Pickup creation failed
";
}else{
echo 'DHL pickup details:
';
echo 'Confirmation No : '.$pickup_array_data['confirm_no'].'
';
echo 'Ready By Time : '.$pickup_array_data['ready_time'].'
';
echo 'Pickup Date : '.$pickup_array_data['pickup_date'].'
';
}
}else {
echo 'Pickup request can only be created with shipment request
';
}
if(!empty($json_data)){
echo '
';
if (!empty($pickup_json_data)) {
$pickup_array_data = json_decode( $pickup_json_data, true );
if (isset($pickup_array_data['status']) && $pickup_array_data['status'] == "failed") {
echo "
(Note: Manual pickup scheduling is currently not available. Recreating the shipment will reduce HITShippo balance.)
";
}else{
echo 'DHL pickup details:
';
echo 'Confirmation No :'.$pickup_array_data['confirm_no'].'
';
echo 'Ready By Time :'.$pickup_array_data['ready_time'].'
';
echo 'Pickup Date :'.$pickup_array_data['pickup_date'].'
';
}
}else {
echo '
Pickup Not Created';
}
}
}
public function create_dhl_return_label_genetation($post){
// print_r('expression');
// die();
if($post->post_type !='shop_order' ){
return;
}
$order = wc_get_order( $post->ID );
$order_id = $order->get_id();
$_dhl_carriers = array(
//"Public carrier name" => "technical name",
'1' => 'DOMESTIC EXPRESS 12:00',
'2' => 'B2C',
'3' => 'B2C',
'4' => 'JETLINE',
'5' => 'SPRINTLINE',
'7' => 'EXPRESS EASY',
'8' => 'EXPRESS EASY',
'9' => 'EUROPACK',
'B' => 'BREAKBULK EXPRESS',
'C' => 'MEDICAL EXPRESS',
'D' => 'EXPRESS WORLDWIDE',
'E' => 'EXPRESS 9:00',
'F' => 'FREIGHT WORLDWIDE',
'G' => 'DOMESTIC ECONOMY SELECT',
'H' => 'ECONOMY SELECT',
'I' => 'DOMESTIC EXPRESS 9:00',
'J' => 'JUMBO BOX',
'K' => 'EXPRESS 9:00',
'L' => 'EXPRESS 10:30',
'M' => 'EXPRESS 10:30',
'N' => 'DOMESTIC EXPRESS',
'O' => 'DOMESTIC EXPRESS 10:30',
'P' => 'EXPRESS WORLDWIDE',
'Q' => 'MEDICAL EXPRESS',
'R' => 'GLOBALMAIL BUSINESS',
'S' => 'SAME DAY',
'T' => 'EXPRESS 12:00',
'U' => 'EXPRESS WORLDWIDE',
'V' => 'EUROPACK',
'W' => 'ECONOMY SELECT',
'X' => 'EXPRESS ENVELOPE',
'Y' => 'EXPRESS 12:00'
);
$general_settings = get_option('a2z_dhl_main_settings',array());
$json_data = get_option('hit_dhl_return_values_'.$order_id);
if(empty($json_data)){
echo 'Choose Service to Return';
echo '
';
echo '
Products to return';
echo '
';
echo '| "; echo " | ". substr($product_data['name'],0,7)." | "; echo ""; echo " |
".$notice."
"; delete_option('hit_dhl_return_status_'.$order_id); } echo ''; } else{ $array_data = json_decode( $json_data, true ); echo ' Return Label '; echo ' Invoice '; echo ''; } } public function hit_wc_checkout_order_processed($order_id){ // die(); $post = get_post($order_id); if($post->post_type !='shop_order' ){ return; } $ship_content = !empty($_POST['hit_dhl_shipment_content']) ? sanitize_text_field($_POST['hit_dhl_shipment_content']) : 'Shipment Content'; $order = wc_get_order( $order_id ); $service_code = $multi_ven = ''; foreach( $order->get_shipping_methods() as $item_id => $item ){ $service_code = $item->get_meta('a2z_dhl_service'); $multi_ven = $item->get_meta('a2z_multi_ven'); } $general_settings = get_option('a2z_dhl_main_settings',array()); $order_data = $order->get_data(); $items = $order->get_items(); if(!isset($general_settings['a2z_dhlexpress_label_automation']) || $general_settings['a2z_dhlexpress_label_automation'] != 'yes'){ return; } $desination_country = (isset($order_data['shipping']['country']) && $order_data['shipping']['country'] != '') ? $order_data['shipping']['country'] : $order_data['billing']['country']; if(empty($service_code)){ if( !isset($general_settings['a2z_dhlexpress_international_service']) && !isset($general_settings['a2z_dhlexpress_Domestic_service'])){ return; } if (isset($general_settings['a2z_dhlexpress_country']) && $general_settings["a2z_dhlexpress_country"] == $desination_country && $general_settings['a2z_dhlexpress_Domestic_service'] != 'null'){ $service_code = $general_settings['a2z_dhlexpress_Domestic_service']; } elseif (isset($general_settings['a2z_dhlexpress_country']) && $general_settings["a2z_dhlexpress_country"] != $desination_country && $general_settings['a2z_dhlexpress_international_service'] != 'null'){ $service_code = $general_settings['a2z_dhlexpress_international_service']; } else { return; } } $custom_settings = array(); $custom_settings['default'] = array( 'a2z_dhlexpress_site_id' => $general_settings['a2z_dhlexpress_site_id'], 'a2z_dhlexpress_site_pwd' => $general_settings['a2z_dhlexpress_site_pwd'], 'a2z_dhlexpress_acc_no' => $general_settings['a2z_dhlexpress_acc_no'], 'a2z_dhlexpress_import_no' => $general_settings['a2z_dhlexpress_import_no'], 'a2z_dhlexpress_shipper_name' => $general_settings['a2z_dhlexpress_shipper_name'], 'a2z_dhlexpress_company' => $general_settings['a2z_dhlexpress_company'], 'a2z_dhlexpress_mob_num' => $general_settings['a2z_dhlexpress_mob_num'], 'a2z_dhlexpress_email' => $general_settings['a2z_dhlexpress_email'], 'a2z_dhlexpress_address1' => $general_settings['a2z_dhlexpress_address1'], 'a2z_dhlexpress_address2' => $general_settings['a2z_dhlexpress_address2'], 'a2z_dhlexpress_city' => $general_settings['a2z_dhlexpress_city'], 'a2z_dhlexpress_state' => $general_settings['a2z_dhlexpress_state'], 'a2z_dhlexpress_zip' => $general_settings['a2z_dhlexpress_zip'], 'a2z_dhlexpress_country' => $general_settings['a2z_dhlexpress_country'], 'a2z_dhlexpress_gstin' => $general_settings['a2z_dhlexpress_gstin'], 'a2z_dhlexpress_con_rate' => $general_settings['a2z_dhlexpress_con_rate'], 'service_code' => $service_code, 'a2z_dhlexpress_label_email' => $general_settings['a2z_dhlexpress_label_email'], ); $vendor_settings = array(); if(!empty($general_settings['a2z_dhlexpress_weight_unit']) && $general_settings['a2z_dhlexpress_weight_unit'] == 'KG_CM') { $dhl_mod_weight_unit = 'kg'; $dhl_mod_dim_unit = 'cm'; }elseif(!empty($general_settings['a2z_dhlexpress_weight_unit']) && $general_settings['a2z_dhlexpress_weight_unit'] == 'LB_IN') { $dhl_mod_weight_unit = 'lbs'; $dhl_mod_dim_unit = 'in'; } else { $dhl_mod_weight_unit = 'kg'; $dhl_mod_dim_unit = 'cm'; } $pack_products = array(); foreach ( $items as $item ) { $product_data = $item->get_data(); $product = array(); $product['product_name'] = str_replace('"', '', $product_data['name']); $product['product_quantity'] = $product_data['quantity']; $product['product_id'] = $product_data['product_id']; $saved_cc = get_post_meta( $product_data['product_id'], 'hits_dhl_cc', true); if(!empty($saved_cc)){ $product['commodity_code'] = $saved_cc; } $saved_desc = get_post_meta( $product_data['product_id'], 'hits_dhl_desc', true); if(!empty($saved_desc)){ $product['invoice_desc'] = $saved_desc; } $dgs_contentid = get_post_meta( $product_data['product_id'], 'hits_dhl_danger_good_content_id', true); if(!empty($dgs_contentid)){ $product['danger_good_contentid'] = $dgs_contentid; } $dgs_label_des = get_post_meta( $product_data['product_id'], 'hits_dhl_danger_good_label_description', true); if(!empty($dgs_label_des)){ $product['danger_good_label_desci'] = $dgs_label_des; } $dgs_uncode = get_post_meta( $product_data['product_id'], 'hits_dhl_danger_good_un_code', true); if(!empty($dgs_uncode)){ $product['danger_good_uncode'] = $dgs_uncode; } $product_variation_id = $item->get_variation_id(); if(empty($product_variation_id) || $product_variation_id == 0){ $getproduct = wc_get_product( $product_data['product_id'] ); }else{ $getproduct = wc_get_product( $product_variation_id ); } $woo_weight_unit = get_option('woocommerce_weight_unit'); $woo_dimension_unit = get_option('woocommerce_dimension_unit'); $dhl_mod_weight_unit = $dhl_mod_dim_unit = ''; $product['sku'] = $getproduct->get_sku(); $product['price'] = (isset($product_data['total']) && isset($product_data['quantity'])) ? number_format(($product_data['total'] / $product_data['quantity']), 2) : 0; $width = $getproduct->get_width(); $height = $getproduct->get_height(); $depth = $getproduct->get_length(); if($width && $height && $depth){ if ($woo_dimension_unit != $dhl_mod_dim_unit) { $prod_width = round($width, 3); $prod_height = round($height, 3); $prod_depth = round($depth, 3); //wc_get_dimension( $dimension, $to_unit, $from_unit ); $product['width'] = round(wc_get_dimension( $prod_width, $dhl_mod_dim_unit, $woo_dimension_unit ), 3); $product['height'] = round(wc_get_dimension( $prod_height, $dhl_mod_dim_unit, $woo_dimension_unit ), 3); $product['depth'] = round(wc_get_dimension( $prod_depth, $dhl_mod_dim_unit, $woo_dimension_unit ), 3); }else { $product['width'] = round($width,3); $product['height'] = round($height,3); $product['depth'] = round($depth,3); } }else{ $product['width'] = ''; $product['height'] = ''; $product['depth'] = ''; } if ($woo_weight_unit != $dhl_mod_weight_unit) { $prod_weight = $getproduct->get_weight(); $product['weight'] = round(wc_get_weight( $prod_weight, $dhl_mod_weight_unit, $woo_weight_unit ), 3); }else{ $product['weight'] = round($getproduct->get_weight(),3); } $pack_products[] = $product; } if(isset($general_settings['a2z_dhlexpress_v_enable']) && $general_settings['a2z_dhlexpress_v_enable'] == 'yes' && isset($general_settings['a2z_dhlexpress_v_labels']) && $general_settings['a2z_dhlexpress_v_labels'] == 'yes'){ // Multi Vendor Enabled foreach ($pack_products as $key => $value) { $product_id = $value['product_id']; $dhl_account = get_post_meta($product_id,'dhl_express_address', true); if(empty($dhl_account) || $dhl_account == 'default'){ $dhl_account = 'default'; if (!isset($vendor_settings[$dhl_account])) { $vendor_settings[$dhl_account] = $custom_settings['default']; } $vendor_settings[$dhl_account]['products'][] = $value; } if($dhl_account != 'default'){ $user_account = get_post_meta($dhl_account,'a2z_dhl_vendor_settings', true); $user_account = empty($user_account) ? array() : $user_account; if(!empty($user_account)){ if(!isset($vendor_settings[$dhl_account])){ $vendor_settings[$dhl_account] = $custom_settings['default']; if($user_account['a2z_dhlexpress_site_id'] != '' && $user_account['a2z_dhlexpress_site_pwd'] != '' && $user_account['a2z_dhlexpress_acc_no'] != ''){ $vendor_settings[$dhl_account]['a2z_dhlexpress_site_id'] = $user_account['a2z_dhlexpress_site_id']; if($user_account['a2z_dhlexpress_site_pwd'] != ''){ $vendor_settings[$dhl_account]['a2z_dhlexpress_site_pwd'] = $user_account['a2z_dhlexpress_site_pwd']; } if($user_account['a2z_dhlexpress_acc_no'] != ''){ $vendor_settings[$dhl_account]['a2z_dhlexpress_acc_no'] = $user_account['a2z_dhlexpress_acc_no']; } $vendor_settings[$dhl_account]['a2z_dhlexpress_import_no'] = !empty($user_account['a2z_dhlexpress_import_no']) ? $user_account['a2z_dhlexpress_import_no'] : ''; } if ($user_account['a2z_dhlexpress_address1'] != '' && $user_account['a2z_dhlexpress_city'] != '' && $user_account['a2z_dhlexpress_state'] != '' && $user_account['a2z_dhlexpress_zip'] != '' && $user_account['a2z_dhlexpress_country'] != '' && $user_account['a2z_dhlexpress_shipper_name'] != '') { if($user_account['a2z_dhlexpress_shipper_name'] != ''){ $vendor_settings[$dhl_account]['a2z_dhlexpress_shipper_name'] = $user_account['a2z_dhlexpress_shipper_name']; } if($user_account['a2z_dhlexpress_company'] != ''){ $vendor_settings[$dhl_account]['a2z_dhlexpress_company'] = $user_account['a2z_dhlexpress_company']; } if($user_account['a2z_dhlexpress_mob_num'] != ''){ $vendor_settings[$dhl_account]['a2z_dhlexpress_mob_num'] = $user_account['a2z_dhlexpress_mob_num']; } if($user_account['a2z_dhlexpress_email'] != ''){ $vendor_settings[$dhl_account]['a2z_dhlexpress_email'] = $user_account['a2z_dhlexpress_email']; } if ($user_account['a2z_dhlexpress_address1'] != '') { $vendor_settings[$dhl_account]['a2z_dhlexpress_address1'] = $user_account['a2z_dhlexpress_address1']; } $vendor_settings[$dhl_account]['a2z_dhlexpress_address2'] = $user_account['a2z_dhlexpress_address2']; if($user_account['a2z_dhlexpress_city'] != ''){ $vendor_settings[$dhl_account]['a2z_dhlexpress_city'] = $user_account['a2z_dhlexpress_city']; } if($user_account['a2z_dhlexpress_state'] != ''){ $vendor_settings[$dhl_account]['a2z_dhlexpress_state'] = $user_account['a2z_dhlexpress_state']; } if($user_account['a2z_dhlexpress_zip'] != ''){ $vendor_settings[$dhl_account]['a2z_dhlexpress_zip'] = $user_account['a2z_dhlexpress_zip']; } if($user_account['a2z_dhlexpress_country'] != ''){ $vendor_settings[$dhl_account]['a2z_dhlexpress_country'] = $user_account['a2z_dhlexpress_country']; } $vendor_settings[$dhl_account]['a2z_dhlexpress_gstin'] = $user_account['a2z_dhlexpress_gstin']; $vendor_settings[$dhl_account]['a2z_dhlexpress_con_rate'] = $user_account['a2z_dhlexpress_con_rate']; } if(isset($general_settings['a2z_dhlexpress_v_email']) && $general_settings['a2z_dhlexpress_v_email'] == 'yes'){ $user_dat = get_userdata($dhl_account); $vendor_settings[$dhl_account]['a2z_dhlexpress_label_email'] = $user_dat->data->user_email; } if($multi_ven !=''){ $array_ven = explode('|',$multi_ven); $scode = ''; foreach ($array_ven as $key => $svalue) { $ex_service = explode("_", $svalue); if($ex_service[0] == $dhl_account){ $vendor_settings[$dhl_account]['service_code'] = $ex_service[1]; } } if($scode == ''){ if($order_data['shipping']['country'] != $vendor_settings[$dhl_account]['a2z_dhlexpress_country']){ $vendor_settings[$dhl_account]['service_code'] = $user_account['a2z_dhlexpress_def_inter']; }else{ $vendor_settings[$dhl_account]['service_code'] = $user_account['a2z_dhlexpress_def_dom']; } } }else{ if($order_data['shipping']['country'] != $vendor_settings[$dhl_account]['a2z_dhlexpress_country']){ $vendor_settings[$dhl_account]['service_code'] = $user_account['a2z_dhlexpress_def_inter']; }else{ $vendor_settings[$dhl_account]['service_code'] = $user_account['a2z_dhlexpress_def_dom']; } } } $vendor_settings[$dhl_account]['products'][] = $value; } } } } if(empty($vendor_settings)){ $custom_settings['default']['products'] = $pack_products; }else{ $custom_settings = $vendor_settings; } $order_id = $order_data['id']; $order_currency = $order_data['currency']; $order_shipping_first_name = $order_data['shipping']['first_name']; $order_shipping_last_name = $order_data['shipping']['last_name']; $order_shipping_company = empty($order_data['shipping']['company']) ? $order_data['shipping']['first_name'] : $order_data['shipping']['company']; $order_shipping_address_1 = $order_data['shipping']['address_1']; $order_shipping_address_2 = $order_data['shipping']['address_2']; $order_shipping_city = $order_data['shipping']['city']; $order_shipping_state = $order_data['shipping']['state']; $order_shipping_postcode = $order_data['shipping']['postcode']; $order_shipping_country = $order_data['shipping']['country']; $order_shipping_phone = $order_data['billing']['phone']; $order_shipping_email = $order_data['billing']['email']; if(!empty($general_settings) && isset($general_settings['a2z_dhlexpress_integration_key'])){ $mode = 'live'; if(isset($general_settings['a2z_dhlexpress_test']) && $general_settings['a2z_dhlexpress_test']== 'yes'){ $mode = 'test'; } $execution = 'manual'; if(isset($general_settings['a2z_dhlexpress_label_automation']) && $general_settings['a2z_dhlexpress_label_automation']== 'yes'){ $execution = 'auto'; } $boxes_to_shipo = array(); if (isset($general_settings['a2z_dhlexpress_packing_type']) && $general_settings['a2z_dhlexpress_packing_type'] == "box") { if (isset($general_settings['a2z_dhlexpress_boxes']) && !empty($general_settings['a2z_dhlexpress_boxes'])) { foreach ($general_settings['a2z_dhlexpress_boxes'] as $box) { if ($box['enabled'] != 1) { continue; }else { $boxes_to_shipo[] = $box; } } } } foreach ($custom_settings as $key => $cvalue) { global $dhl_core; $frm_curr = get_option('woocommerce_currency'); $to_curr = isset($dhl_core[$cvalue['a2z_dhlexpress_country']]) ? $dhl_core[$cvalue['a2z_dhlexpress_country']]['currency'] : ''; $curr_con_rate = ( isset($cvalue['a2z_dhlexpress_con_rate']) && !empty($cvalue['a2z_dhlexpress_con_rate']) ) ? $cvalue['a2z_dhlexpress_con_rate'] : 0; if (!empty($frm_curr) && !empty($to_curr) && ($frm_curr != $to_curr) ) { if (isset($general_settings['a2z_dhlexpress_auto_con_rate']) && $general_settings['a2z_dhlexpress_auto_con_rate'] == "yes") { $current_date = date('m-d-Y', time()); $ex_rate_data = get_option('a2z_dhl_ex_rate'.$key); $ex_rate_data = !empty($ex_rate_data) ? $ex_rate_data : array(); if (empty($ex_rate_data) || (isset($ex_rate_data['date']) && $ex_rate_data['date'] != $current_date) ) { if (isset($cvalue['a2z_dhlexpress_country']) && !empty($cvalue['a2z_dhlexpress_country']) && isset($general_settings['a2z_dhlexpress_integration_key']) && !empty($general_settings['a2z_dhlexpress_integration_key'])) { $ex_rate_Request = json_encode(array('integrated_key' => $general_settings['a2z_dhlexpress_integration_key'], 'from_curr' => $frm_curr, 'to_curr' => $to_curr)); $ex_rate_url = "https://app.hitshipo.com/get_exchange_rate.php"; // $ex_rate_url = "http://localhost/hitshipo/get_exchange_rate.php"; $ex_rate_response = wp_remote_post( $ex_rate_url , array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => true, 'headers' => array('Content-Type' => 'application/json; charset=utf-8'), 'body' => $ex_rate_Request, 'sslverify' => FALSE ) ); $ex_rate_result = ( is_array($ex_rate_response) && isset($ex_rate_response['body'])) ? json_decode($ex_rate_response['body'], true) : array(); if ( !empty($ex_rate_result) && isset($ex_rate_result['ex_rate']) && $ex_rate_result['ex_rate'] != "Not Found" ) { $ex_rate_result['date'] = $current_date; update_option('a2z_dhl_ex_rate'.$key, $ex_rate_result); }else { if (!empty($ex_rate_data)) { $ex_rate_data['date'] = $current_date; update_option('a2z_dhl_ex_rate'.$key, $ex_rate_data); } } } } $get_ex_rate = get_option('a2z_dhl_ex_rate'.$key, ''); $get_ex_rate = !empty($get_ex_rate) ? $get_ex_rate : array(); $curr_con_rate = ( !empty($get_ex_rate) && isset($get_ex_rate['ex_rate']) ) ? $get_ex_rate['ex_rate'] : 0; } } $c_codes = []; foreach($cvalue['products'] as $prod_to_shipo_key => $prod_to_shipo){ $saved_cc = get_post_meta( $prod_to_shipo['product_id'], 'hits_dhl_cc', true); if(!empty($saved_cc)){ $c_codes[] = $saved_cc; } if (!empty($frm_curr) && !empty($to_curr) && ($frm_curr != $to_curr) ) { if ($curr_con_rate > 0) { $cvalue['products'][$prod_to_shipo_key]['price'] = $prod_to_shipo['price'] * $curr_con_rate; } } } //For Automatic Label Generation $data = array(); $data['integrated_key'] = $general_settings['a2z_dhlexpress_integration_key']; $data['order_id'] = $order_id; $data['exec_type'] = $execution; $data['mode'] = $mode; $data['carrier_type'] = 'dhl'; $data['meta'] = array( "site_id" => $cvalue['a2z_dhlexpress_site_id'], "password" => $cvalue['a2z_dhlexpress_site_pwd'], "accountnum" => $cvalue['a2z_dhlexpress_acc_no'], "t_company" => $order_shipping_company, "t_address1" => str_replace('"', '', $order_shipping_address_1), "t_address2" => str_replace('"', '', $order_shipping_address_2), "t_city" => $order_shipping_city, "t_state" => $order_shipping_state, "t_postal" => $order_shipping_postcode, "t_country" => $order_shipping_country, "t_name" => $order_shipping_first_name . ' '. $order_shipping_last_name, "t_phone" => $order_shipping_phone, "t_email" => $order_shipping_email, "dutiable" => $general_settings['a2z_dhlexpress_duty_payment'], "insurance" => $general_settings['a2z_dhlexpress_insure'], "pack_this" => "Y", "products" => $cvalue['products'], "pack_algorithm" => $general_settings['a2z_dhlexpress_packing_type'], "boxes" => $boxes_to_shipo, "max_weight" => $general_settings['a2z_dhlexpress_max_weight'], "plt" => ($general_settings['a2z_dhlexpress_ppt'] == 'yes') ? "Y" : "N", "airway_bill" => ($general_settings['a2z_dhlexpress_aabill'] == 'yes') ? "Y" : "N", "sd" => ($general_settings['a2z_dhlexpress_sat'] == 'yes') ? "Y" : "N", "cod" => ($general_settings['a2z_dhlexpress_cod'] == 'yes') ? "Y" : "N", "service_code" => $service_code, "danger_goods_item" => isset($general_settings['a2z_dhlexpress_dgs']) ? $general_settings['a2z_dhlexpress_dgs'] : 'no', "shipment_content" => $ship_content, "email_alert" => ( isset($general_settings['a2z_dhlexpress_email_alert']) && ($general_settings['a2z_dhlexpress_email_alert'] == 'yes') ) ? "Y" : "N", "s_company" => $cvalue['a2z_dhlexpress_company'], "s_address1" => $cvalue['a2z_dhlexpress_address1'], "s_address2" => $cvalue['a2z_dhlexpress_address2'], "s_city" => $cvalue['a2z_dhlexpress_city'], "s_state" => $cvalue['a2z_dhlexpress_state'], "s_postal" => $cvalue['a2z_dhlexpress_zip'], "s_country" => $cvalue['a2z_dhlexpress_country'], "gstin" => $cvalue['a2z_dhlexpress_gstin'], "s_name" => $cvalue['a2z_dhlexpress_shipper_name'], "s_phone" => $cvalue['a2z_dhlexpress_mob_num'], "s_email" => $cvalue['a2z_dhlexpress_email'], "label_size" => $general_settings['a2z_dhlexpress_print_size'], "sent_email_to" => $cvalue['a2z_dhlexpress_label_email'], "pic_exec_type" => (isset($general_settings['a2z_dhlexpress_pickup_automation']) && $general_settings['a2z_dhlexpress_pickup_automation'] == 'yes') ? "auto" : "manual", "pic_loc_type" => (isset($general_settings['a2z_dhlexpress_pickup_loc_type']) ? $general_settings['a2z_dhlexpress_pickup_loc_type'] : ''), "pic_pac_loc" => (isset($general_settings['a2z_dhlexpress_pickup_pac_loc']) ? $general_settings['a2z_dhlexpress_pickup_pac_loc'] : ''), "pic_contact_per" => (isset($general_settings['a2z_dhlexpress_pickup_per_name']) ? $general_settings['a2z_dhlexpress_pickup_per_name'] : ''), "pic_contact_no" => (isset($general_settings['a2z_dhlexpress_pickup_per_contact_no']) ? $general_settings['a2z_dhlexpress_pickup_per_contact_no'] : ''), "pic_door_to" => (isset($general_settings['a2z_dhlexpress_pickup_door_to']) ? $general_settings['a2z_dhlexpress_pickup_door_to'] : ''), "pic_type" => (isset($general_settings['a2z_dhlexpress_pickup_type']) ? $general_settings['a2z_dhlexpress_pickup_type'] : ''), "pic_days_after" => (isset($general_settings['a2z_dhlexpress_pickup_date']) ? $general_settings['a2z_dhlexpress_pickup_date'] : ''), "pic_open_time" => (isset($general_settings['a2z_dhlexpress_pickup_open_time']) ? $general_settings['a2z_dhlexpress_pickup_open_time'] : ''), "pic_close_time" => (isset($general_settings['a2z_dhlexpress_pickup_close_time']) ? $general_settings['a2z_dhlexpress_pickup_close_time'] : ''), "pic_mail_date" => date('c'), "pic_date" => date("Y-m-d"), "label" => $key, "payment_con" => (isset($general_settings['a2z_dhlexpress_pay_con']) ? $general_settings['a2z_dhlexpress_pay_con'] : 'S'), "cus_payment_con" => (isset($general_settings['a2z_dhlexpress_cus_pay_con']) ? $general_settings['a2z_dhlexpress_cus_pay_con'] : ''), "translation" => ( (isset($general_settings['a2z_dhlexpress_translation']) && $general_settings['a2z_dhlexpress_translation'] == "yes" ) ? 'Y' : 'N'), "translation_key" => (isset($general_settings['a2z_dhlexpress_translation_key']) ? $general_settings['a2z_dhlexpress_translation_key'] : ''), "commodity_code" => $c_codes, "ship_price" => isset($order_data['shipping_total']) ? $order_data['shipping_total'] : 0, "order_total" => isset($order_data['total']) ? $order_data['total'] : 0, "order_total_tax" => isset($order_data['total_tax']) ? $order_data['total_tax'] : 0, "label" => $key, "export_reason" => (isset($general_settings['a2z_dhlexpress_export_reason']) ? $general_settings['a2z_dhlexpress_export_reason'] : 'P') ); //Auto Shipment $auto_ship_url = "https://app.hitshipo.com/label_api/create_shipment.php"; // $auto_ship_url = "http://localhost/hitshipo/label_api/create_shipment.php"; wp_remote_post( $auto_ship_url , array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => false, 'headers' => array('Content-Type' => 'application/json; charset=utf-8'), 'body' => json_encode($data), 'sslverify' => FALSE ) ); } } } // Save the data of the Meta field public function hit_create_dhl_shipping( $order_id ) { $post = get_post($order_id); if($post->post_type !='shop_order' ){ return; } if ( isset( $_POST[ 'hit_dhl_reset' ] ) ) { delete_option('hit_dhl_values_'.$order_id); } if (isset($_POST['hit_dhl_get_rates'])) { global $dhl_core; $get_rates_for = sanitize_text_field($_POST['hit_dhl_get_rates']); $general_settings = get_option('a2z_dhl_main_settings',array()); $custom_packs = []; if (isset($_POST['hits_dhl_add_cus_pack_'.$get_rates_for])) { if (!isset($_POST['hits_dhl_pack_weight_'.$get_rates_for]) || !isset($_POST['hits_dhl_pack_cost_'.$get_rates_for]) || !isset($_POST['hits_dhl_pack_currency_'.$get_rates_for])) { update_option('hit_dhl_status_'.$order_id, "Need packs for custom packing."); return; } foreach ($_POST['hits_dhl_pack_weight_'.$get_rates_for] as $key => $pack_heights) { $curr_pack = []; $curr_pack['GroupNumber'] = $key+1; $curr_pack['GroupPackageCount'] = $key+1; $curr_pack['Weight'] = [ "Value" => isset($_POST['hits_dhl_pack_weight_'.$get_rates_for][$key]) ? $_POST['hits_dhl_pack_weight_'.$get_rates_for][$key] : 0, "Units" => isset($_POST['hits_dhl_pack_weg_unit_'.$get_rates_for][$key]) ? $_POST['hits_dhl_pack_weg_unit_'.$get_rates_for][$key] : "KG" ]; if (isset($_POST['hits_dhl_pack_height_'.$get_rates_for][$key]) && isset($_POST['hits_dhl_pack_length_'.$get_rates_for][$key]) && isset($_POST['hits_dhl_pack_width_'.$get_rates_for][$key])) { if (!empty($_POST['hits_dhl_pack_height_'.$get_rates_for][$key]) && !empty($_POST['hits_dhl_pack_length_'.$get_rates_for][$key]) && !empty($_POST['hits_dhl_pack_width_'.$get_rates_for][$key])) { $curr_pack['Dimensions'] = [ "Length" => $_POST['hits_dhl_pack_length_'.$get_rates_for][$key], "Width" => $_POST['hits_dhl_pack_width_'.$get_rates_for][$key], "Height" => $_POST['hits_dhl_pack_height_'.$get_rates_for][$key], "Units" =>$_POST['hits_dhl_pack_dim_unit_'.$get_rates_for][$key] ]; } } $curr_pack['InsuredValue'] = [ "Amount" => isset($_POST['hits_dhl_pack_cost_'.$get_rates_for][$key]) ? $_POST['hits_dhl_pack_cost_'.$get_rates_for][$key] : 0, "Currency" => isset($_POST['hits_dhl_pack_currency_'.$get_rates_for][$key]) ? $_POST['hits_dhl_pack_currency_'.$get_rates_for][$key] : "" ]; $curr_pack['packed_products'] = []; $curr_pack['package_id'] = "Custom_Pack_".$key; $curr_pack['packtype'] = "BOX"; $custom_packs[] = $curr_pack; } } $order = wc_get_order( $order_id ); if($order){ $order_data = $order->get_data(); $order_id = $order_data['id']; $order_products = $this->get_products_on_order($general_settings, $order); $custom_settings = $this->get_vendors_on_order($general_settings, $order_products); $mesage_time = date('c'); $message_date = date('Y-m-d'); $weight_unit = $dim_unit = ''; if (!empty($general_settings['a2z_dhlexpress_weight_unit']) && $general_settings['a2z_dhlexpress_weight_unit'] == 'KG_CM') { $weight_unit = 'KG'; $dim_unit = 'CM'; } else { $weight_unit = 'LB'; $dim_unit = 'IN'; } if (!isset($general_settings['a2z_dhlexpress_packing_type'])) { return; } $woo_weight_unit = get_option('woocommerce_weight_unit'); $woo_dimension_unit = get_option('woocommerce_dimension_unit'); $dhl_mod_weight_unit = $dhl_mod_dim_unit = ''; if (!empty($general_settings['a2z_dhlexpress_weight_unit']) && $general_settings['a2z_dhlexpress_weight_unit'] == 'KG_CM') { $dhl_mod_weight_unit = 'kg'; $dhl_mod_dim_unit = 'cm'; } elseif (!empty($general_settings['a2z_dhlexpress_weight_unit']) && $general_settings['a2z_dhlexpress_weight_unit'] == 'LB_IN') { $dhl_mod_weight_unit = 'lbs'; $dhl_mod_dim_unit = 'in'; } else { $dhl_mod_weight_unit = 'kg'; $dhl_mod_dim_unit = 'cm'; } $shipping_rates = array(); $value = isset($custom_settings[$get_rates_for]) ? $custom_settings[$get_rates_for] : []; if (isset($general_settings['a2z_dhlexpress_auto_con_rate']) && $general_settings['a2z_dhlexpress_auto_con_rate'] == "yes") { $current_date = date('m-d-Y', time()); $ex_rate_data = get_option('a2z_dhl_ex_rate'.$key); $ex_rate_data = !empty($ex_rate_data) ? $ex_rate_data : array(); if (empty($ex_rate_data) || (isset($ex_rate_data['date']) && $ex_rate_data['date'] != $current_date) ) { if (isset($general_settings['a2z_dhlexpress_country']) && !empty($general_settings['a2z_dhlexpress_country']) && isset($general_settings['a2z_dhlexpress_integration_key']) && !empty($general_settings['a2z_dhlexpress_integration_key'])) { $frm_curr = get_option('woocommerce_currency'); $to_curr = isset($dhl_core[$general_settings['a2z_dhlexpress_country']]) ? $dhl_core[$general_settings['a2z_dhlexpress_country']]['currency'] : ''; $ex_rate_Request = json_encode(array('integrated_key' => $general_settings['a2z_dhlexpress_integration_key'], 'from_curr' => $frm_curr, 'to_curr' => $to_curr)); $ex_rate_url = "https://app.hitshipo.com/get_exchange_rate.php"; // $ex_rate_url = "http://localhost/Hitshipo/get_exchange_rate.php"; $ex_rate_response = wp_remote_post( $ex_rate_url , array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => true, 'headers' => array('Content-Type' => 'application/json; charset=utf-8'), 'body' => $ex_rate_Request, 'sslverify' => FALSE ) ); $ex_rate_result = ( is_array($ex_rate_response) && isset($ex_rate_response['body'])) ? json_decode($ex_rate_response['body'], true) : array(); if ( !empty($ex_rate_result) && isset($ex_rate_result['ex_rate']) && $ex_rate_result['ex_rate'] != "Not Found" ) { $ex_rate_result['date'] = $current_date; update_option('a2z_dhl_ex_rate'.$key, $ex_rate_result); }else { if (!empty($ex_rate_data)) { $ex_rate_data['date'] = $current_date; update_option('a2z_dhl_ex_rate'.$key, $ex_rate_data); } } } } } $to_city = $order_data['shipping']['city']; if (isset($general_settings['a2z_dhlexpress_translation']) && $general_settings['a2z_dhlexpress_translation'] == "yes" ) { if (isset($general_settings['a2z_dhlexpress_translation_key']) && !empty($general_settings['a2z_dhlexpress_translation_key'])) { include_once('classes/gtrans/vendor/autoload.php'); if (!empty($to_city)) { if (!preg_match('%^[ -~]+$%', $to_city)) //Cheks english or not /[^A-Za-z0-9]+/ { $response = array(); try{ $translate = new TranslateClient(['key' => $general_settings['a2z_dhlexpress_translation_key']]); // Tranlate text $response = $translate->translate($to_city, [ 'target' => 'en', ]); }catch(exception $e){ // echo "\n Exception Caught" . $e->getMessage(); //Error handling } if (!empty($response) && isset($response['text']) && !empty($response['text'])) { $to_city = $response['text']; } } } } } $shipping_rates[$get_rates_for] = array(); $orgin_postalcode_or_city = $this->a2z_get_zipcode_or_city($value['a2z_dhlexpress_country'], $value['a2z_dhlexpress_city'], $value['a2z_dhlexpress_zip']); $destination_postcode_city = $this->a2z_get_zipcode_or_city($order_data['shipping']['country'], $to_city, $order_data['shipping']['postcode']); $general_settings['a2z_dhlexpress_currency'] = isset($dhl_core[(isset($value['a2z_dhlexpress_country']) ? $value['a2z_dhlexpress_country'] : 'A2Z')]) ? $dhl_core[$value['a2z_dhlexpress_country']]['currency'] : ''; $value['products'] = apply_filters('a2z_dhlexpress_rate_based_product', $value['products'],'true'); $dhl_packs = !empty($custom_packs) ? $custom_packs : $this->hit_get_dhl_packages($value['products'], $general_settings, $general_settings['a2z_dhlexpress_currency']); $pieces = ""; $cart_total = 0; $index = 0; if ($dhl_packs) { foreach ($dhl_packs as $parcel) { $index = $index + 1; $pieces .= '';
// print_r($package);
// die();
if (!class_exists('WeightPack')) {
include_once 'controllors/classes/weight_pack/class-hit-weight-packing.php';
}
$max_weight = isset($general_settings['a2z_dhlexpress_max_weight']) && $general_settings['a2z_dhlexpress_max_weight'] != '' ? $general_settings['a2z_dhlexpress_max_weight'] : 10;
$weight_pack = new WeightPack('pack_ascending');
$weight_pack->set_max_weight($max_weight);
$package_total_weight = 0;
$insured_value = 0;
$ctr = 0;
foreach ($package as $item_id => $product_data) {
$ctr++;
$chk_qty = $product_data['product_quantity'];
$weight_pack->add_item($product_data['weight'], $product_data, $chk_qty);
}
$pack = $weight_pack->pack_items();
$errors = $pack->get_errors();
if (!empty($errors)) {
//do nothing
return;
} else {
$boxes = $pack->get_packed_boxes();
$unpacked_items = $pack->get_unpacked_items();
$insured_value = 0;
$packages = array_merge($boxes, $unpacked_items); // merge items if unpacked are allowed
$package_count = sizeof($packages);
// get all items to pass if item info in box is not distinguished
$packable_items = $weight_pack->get_packable_items();
$all_items = array();
if (is_array($packable_items)) {
foreach ($packable_items as $packable_item) {
$all_items[] = $packable_item['data'];
}
}
//pre($packable_items);
$order_total = '';
$to_ship = array();
$group_id = 1;
foreach ($packages as $package) {
$packed_products = array();
if (isset($package['items'])) {
foreach ($package['items'] as $key => $value) {
$insured_value += isset($value['price']) ? $value['price'] : 0;
}
}
$packed_products = isset($package['items']) ? $package['items'] : $all_items;
// Creating package request
$package_total_weight = $package['weight'];
$insurance_array = array(
'Amount' => $insured_value,
'Currency' => $orderCurrency
);
$group = array(
'GroupNumber' => $group_id,
'GroupPackageCount' => 1,
'Weight' => array(
'Value' => round($package_total_weight, 3),
'Units' => (isset($general_settings['weg_dim']) && $general_settings['weg_dim'] === 'yes') ? 'KG' : 'LBS'
),
'packed_products' => $packed_products,
);
$group['InsuredValue'] = $insurance_array;
$group['packtype'] = 'BOX';
$to_ship[] = $group;
$group_id++;
}
}
return $to_ship;
}
private function box_shipping($package, $general_settings, $orderCurrency, $chk = false)
{
if (!class_exists('HIT_Boxpack')) {
include_once 'controllors/classes/hit-box-packing.php';
}
$boxpack = new HIT_Boxpack();
$boxes = isset($general_settings['a2z_dhlexpress_boxes']) ? $general_settings['a2z_dhlexpress_boxes'] : array();
if (empty($boxes)) {
return false;
}
// $boxes = unserialize($boxes);
// Define boxes
foreach ($boxes as $key => $box) {
if (!$box['enabled']) {
continue;
}
$box['pack_type'] = !empty($box['pack_type']) ? $box['pack_type'] : 'BOX';
$newbox = $boxpack->add_box($box['length'], $box['width'], $box['height'], $box['box_weight'], $box['pack_type']);
if (isset($box['id'])) {
$newbox->set_id(current(explode(':', $box['id'])));
}
if ($box['max_weight']) {
$newbox->set_max_weight($box['max_weight']);
}
if ($box['pack_type']) {
$newbox->set_packtype($box['pack_type']);
}
}
// Add items
foreach ($package as $item_id => $product_data) {
if (isset($product_data['weight']) && !empty($product_data['weight'])) {
$item_weight = round($product_data['weight'] > 0.001 ? $product_data['weight'] : 0.001, 3);
}
if (isset($product_data['width']) && isset($product_data['height']) && isset($product_data['depth']) && !empty($product_data['width']) && !empty($product_data['height']) && !empty($product_data['depth'])) {
$item_dimension = array(
'Length' => max(1, round($product_data['depth'], 3)),
'Width' => max(1, round($product_data['width'], 3)),
'Height' => max(1, round($product_data['height'], 3))
);
}
if (isset($item_weight) && isset($item_dimension)) {
// $dimensions = array($values['depth'], $values['height'], $values['width']);
$chk_qty = $product_data['product_quantity'];
for ($i = 0; $i < $chk_qty; $i++) {
$boxpack->add_item($item_dimension['Width'], $item_dimension['Height'], $item_dimension['Length'], $item_weight, round($product_data['price']), array(
'data' => $product_data
));
}
} else {
// $this->debug(sprintf(__('Product #%s is missing dimensions. Aborting.', 'wf-shipping-dhl'), $item_id), 'error');
return;
}
}
// Pack it
$boxpack->pack();
$packages = $boxpack->get_packages();
$to_ship = array();
$group_id = 1;
foreach ($packages as $package) {
if ($package->unpacked === true) {
//$this->debug('Unpacked Item');
} else {
//$this->debug('Packed ' . $package->id);
}
$dimensions = array($package->length, $package->width, $package->height);
sort($dimensions);
$insurance_array = array(
'Amount' => round($package->value),
'Currency' => $orderCurrency
);
$group = array(
'GroupNumber' => $group_id,
'GroupPackageCount' => 1,
'Weight' => array(
'Value' => round($package->weight, 3),
'Units' => (isset($general_settings['weg_dim']) && $general_settings['weg_dim'] === 'yes') ? 'KG' : 'LBS'
),
'Dimensions' => array(
'Length' => max(1, round($dimensions[2], 3)),
'Width' => max(1, round($dimensions[1], 3)),
'Height' => max(1, round($dimensions[0], 3)),
'Units' => (isset($general_settings['weg_dim']) && $general_settings['weg_dim'] === 'yes') ? 'CM' : 'IN'
),
'InsuredValue' => $insurance_array,
'packed_products' => array(),
'package_id' => $package->id,
'packtype' => 'BOX'
);
if (!empty($package->packed) && is_array($package->packed)) {
foreach ($package->packed as $packed) {
$group['packed_products'][] = $packed->get_meta('data');
}
}
if (!$package->packed) {
foreach ($package->unpacked as $unpacked) {
$group['packed_products'][] = $unpacked->get_meta('data');
}
}
$to_ship[] = $group;
$group_id++;
}
return $to_ship;
}
private function per_item_shipping($package, $general_settings, $orderCurrency, $chk = false)
{
// echo '';
// print_r($package);
// die();
$to_ship = array();
$group_id = 1;
// Get weight of order
foreach ($package as $item_id => $product_data) {
$group = array();
$insurance_array = array(
'Amount' => round($product_data['price']),
'Currency' => $orderCurrency
);
if (isset($product_data['weight']) && !empty($product_data['weight'])) {
$dhl_per_item_weight = round($product_data['weight'] > 0.001 ? $product_data['weight'] : 0.001, 3);
}
$group = array(
'GroupNumber' => $group_id,
'GroupPackageCount' => 1,
'Weight' => array(
'Value' => $dhl_per_item_weight,
'Units' => (isset($general_settings['a2z_dhlexpress_weight_unit']) && $general_settings['a2z_dhlexpress_weight_unit'] == 'KG_CM') ? 'KG' : 'LBS'
),
'packed_products' => $product_data
);
if (isset($product_data['width']) && isset($product_data['height']) && isset($product_data['depth']) && !empty($product_data['width']) && !empty($product_data['height']) && !empty($product_data['depth'])) {
$group['Dimensions'] = array(
'Length' => max(1, round($product_data['depth'], 3)),
'Width' => max(1, round($product_data['width'], 3)),
'Height' => max(1, round($product_data['height'], 3)),
'Units' => (isset($general_settings['a2z_dhlexpress_weight_unit']) && $general_settings['a2z_dhlexpress_weight_unit'] == 'KG_CM') ? 'CM' : 'IN'
);
}
$group['packtype'] = 'BOX';
$group['InsuredValue'] = $insurance_array;
$chk_qty = $product_data['product_quantity'];
for ($i = 0; $i < $chk_qty; $i++)
$to_ship[] = $group;
$group_id++;
}
return $to_ship;
}
public function a2z_dhl_is_eu_country ($countrycode, $destinationcode) {
$eu_countrycodes = array(
'AT', 'BE', 'BG', 'CY', 'CZ', 'DE', 'DK', 'EE',
'ES', 'FI', 'FR', 'HU', 'IE', 'IT', 'LT', 'LU', 'LV',
'MT', 'NL', 'PL', 'PT', 'RO', 'SE', 'SI', 'SK',
'HR', 'GR'
);
return(in_array($countrycode, $eu_countrycodes) && in_array($destinationcode, $eu_countrycodes));
}
}
$dhl_core = array();
$dhl_core['AD'] = array('region' => 'EU', 'currency' =>'EUR', 'weight' => 'KG_CM');
$dhl_core['AE'] = array('region' => 'AP', 'currency' =>'AED', 'weight' => 'KG_CM');
$dhl_core['AF'] = array('region' => 'AP', 'currency' =>'AFN', 'weight' => 'KG_CM');
$dhl_core['AG'] = array('region' => 'AM', 'currency' =>'XCD', 'weight' => 'LB_IN');
$dhl_core['AI'] = array('region' => 'AM', 'currency' =>'XCD', 'weight' => 'LB_IN');
$dhl_core['AL'] = array('region' => 'AP', 'currency' =>'EUR', 'weight' => 'KG_CM');
$dhl_core['AM'] = array('region' => 'AP', 'currency' =>'AMD', 'weight' => 'KG_CM');
$dhl_core['AN'] = array('region' => 'AM', 'currency' =>'ANG', 'weight' => 'KG_CM');
$dhl_core['AO'] = array('region' => 'AP', 'currency' =>'AOA', 'weight' => 'KG_CM');
$dhl_core['AR'] = array('region' => 'AM', 'currency' =>'ARS', 'weight' => 'KG_CM');
$dhl_core['AS'] = array('region' => 'AM', 'currency' =>'USD', 'weight' => 'LB_IN');
$dhl_core['AT'] = array('region' => 'EU', 'currency' =>'EUR', 'weight' => 'KG_CM');
$dhl_core['AU'] = array('region' => 'AP', 'currency' =>'AUD', 'weight' => 'KG_CM');
$dhl_core['AW'] = array('region' => 'AM', 'currency' =>'AWG', 'weight' => 'LB_IN');
$dhl_core['AZ'] = array('region' => 'AM', 'currency' =>'AZN', 'weight' => 'KG_CM');
$dhl_core['AZ'] = array('region' => 'AM', 'currency' =>'AZN', 'weight' => 'KG_CM');
$dhl_core['GB'] = array('region' => 'EU', 'currency' =>'GBP', 'weight' => 'KG_CM');
$dhl_core['BA'] = array('region' => 'AP', 'currency' =>'BAM', 'weight' => 'KG_CM');
$dhl_core['BB'] = array('region' => 'AM', 'currency' =>'BBD', 'weight' => 'LB_IN');
$dhl_core['BD'] = array('region' => 'AP', 'currency' =>'BDT', 'weight' => 'KG_CM');
$dhl_core['BE'] = array('region' => 'EU', 'currency' =>'EUR', 'weight' => 'KG_CM');
$dhl_core['BF'] = array('region' => 'AP', 'currency' =>'XOF', 'weight' => 'KG_CM');
$dhl_core['BG'] = array('region' => 'EU', 'currency' =>'BGN', 'weight' => 'KG_CM');
$dhl_core['BH'] = array('region' => 'AP', 'currency' =>'BHD', 'weight' => 'KG_CM');
$dhl_core['BI'] = array('region' => 'AP', 'currency' =>'BIF', 'weight' => 'KG_CM');
$dhl_core['BJ'] = array('region' => 'AP', 'currency' =>'XOF', 'weight' => 'KG_CM');
$dhl_core['BM'] = array('region' => 'AM', 'currency' =>'BMD', 'weight' => 'LB_IN');
$dhl_core['BN'] = array('region' => 'AP', 'currency' =>'BND', 'weight' => 'KG_CM');
$dhl_core['BO'] = array('region' => 'AM', 'currency' =>'BOB', 'weight' => 'KG_CM');
$dhl_core['BR'] = array('region' => 'AM', 'currency' =>'BRL', 'weight' => 'KG_CM');
$dhl_core['BS'] = array('region' => 'AM', 'currency' =>'BSD', 'weight' => 'LB_IN');
$dhl_core['BT'] = array('region' => 'AP', 'currency' =>'BTN', 'weight' => 'KG_CM');
$dhl_core['BW'] = array('region' => 'AP', 'currency' =>'BWP', 'weight' => 'KG_CM');
$dhl_core['BY'] = array('region' => 'AP', 'currency' =>'BYR', 'weight' => 'KG_CM');
$dhl_core['BZ'] = array('region' => 'AM', 'currency' =>'BZD', 'weight' => 'KG_CM');
$dhl_core['CA'] = array('region' => 'AM', 'currency' =>'CAD', 'weight' => 'LB_IN');
$dhl_core['CF'] = array('region' => 'AP', 'currency' =>'XAF', 'weight' => 'KG_CM');
$dhl_core['CG'] = array('region' => 'AP', 'currency' =>'XAF', 'weight' => 'KG_CM');
$dhl_core['CH'] = array('region' => 'EU', 'currency' =>'CHF', 'weight' => 'KG_CM');
$dhl_core['CI'] = array('region' => 'AP', 'currency' =>'XOF', 'weight' => 'KG_CM');
$dhl_core['CK'] = array('region' => 'AP', 'currency' =>'NZD', 'weight' => 'KG_CM');
$dhl_core['CL'] = array('region' => 'AM', 'currency' =>'CLP', 'weight' => 'KG_CM');
$dhl_core['CM'] = array('region' => 'AP', 'currency' =>'XAF', 'weight' => 'KG_CM');
$dhl_core['CN'] = array('region' => 'AP', 'currency' =>'CNY', 'weight' => 'KG_CM');
$dhl_core['CO'] = array('region' => 'AM', 'currency' =>'COP', 'weight' => 'KG_CM');
$dhl_core['CR'] = array('region' => 'AM', 'currency' =>'CRC', 'weight' => 'KG_CM');
$dhl_core['CU'] = array('region' => 'AM', 'currency' =>'CUC', 'weight' => 'KG_CM');
$dhl_core['CV'] = array('region' => 'AP', 'currency' =>'CVE', 'weight' => 'KG_CM');
$dhl_core['CY'] = array('region' => 'AP', 'currency' =>'EUR', 'weight' => 'KG_CM');
$dhl_core['CZ'] = array('region' => 'EU', 'currency' =>'CZK', 'weight' => 'KG_CM');
$dhl_core['DE'] = array('region' => 'AP', 'currency' =>'EUR', 'weight' => 'KG_CM');
$dhl_core['DJ'] = array('region' => 'EU', 'currency' =>'DJF', 'weight' => 'KG_CM');
$dhl_core['DK'] = array('region' => 'AM', 'currency' =>'DKK', 'weight' => 'KG_CM');
$dhl_core['DM'] = array('region' => 'AM', 'currency' =>'XCD', 'weight' => 'LB_IN');
$dhl_core['DO'] = array('region' => 'AP', 'currency' =>'DOP', 'weight' => 'LB_IN');
$dhl_core['DZ'] = array('region' => 'AM', 'currency' =>'DZD', 'weight' => 'KG_CM');
$dhl_core['EC'] = array('region' => 'EU', 'currency' =>'USD', 'weight' => 'KG_CM');
$dhl_core['EE'] = array('region' => 'AP', 'currency' =>'EUR', 'weight' => 'KG_CM');
$dhl_core['EG'] = array('region' => 'AP', 'currency' =>'EGP', 'weight' => 'KG_CM');
$dhl_core['ER'] = array('region' => 'EU', 'currency' =>'ERN', 'weight' => 'KG_CM');
$dhl_core['ES'] = array('region' => 'AP', 'currency' =>'EUR', 'weight' => 'KG_CM');
$dhl_core['ET'] = array('region' => 'AU', 'currency' =>'ETB', 'weight' => 'KG_CM');
$dhl_core['FI'] = array('region' => 'AP', 'currency' =>'EUR', 'weight' => 'KG_CM');
$dhl_core['FJ'] = array('region' => 'AP', 'currency' =>'FJD', 'weight' => 'KG_CM');
$dhl_core['FK'] = array('region' => 'AM', 'currency' =>'GBP', 'weight' => 'KG_CM');
$dhl_core['FM'] = array('region' => 'AM', 'currency' =>'USD', 'weight' => 'LB_IN');
$dhl_core['FO'] = array('region' => 'AM', 'currency' =>'DKK', 'weight' => 'KG_CM');
$dhl_core['FR'] = array('region' => 'EU', 'currency' =>'EUR', 'weight' => 'KG_CM');
$dhl_core['GA'] = array('region' => 'AP', 'currency' =>'XAF', 'weight' => 'KG_CM');
$dhl_core['GB'] = array('region' => 'EU', 'currency' =>'GBP', 'weight' => 'KG_CM');
$dhl_core['GD'] = array('region' => 'AM', 'currency' =>'XCD', 'weight' => 'LB_IN');
$dhl_core['GE'] = array('region' => 'AM', 'currency' =>'GEL', 'weight' => 'KG_CM');
$dhl_core['GF'] = array('region' => 'AM', 'currency' =>'EUR', 'weight' => 'KG_CM');
$dhl_core['GG'] = array('region' => 'AM', 'currency' =>'GBP', 'weight' => 'KG_CM');
$dhl_core['GH'] = array('region' => 'AP', 'currency' =>'GHS', 'weight' => 'KG_CM');
$dhl_core['GI'] = array('region' => 'AM', 'currency' =>'GBP', 'weight' => 'KG_CM');
$dhl_core['GL'] = array('region' => 'AM', 'currency' =>'DKK', 'weight' => 'KG_CM');
$dhl_core['GM'] = array('region' => 'AP', 'currency' =>'GMD', 'weight' => 'KG_CM');
$dhl_core['GN'] = array('region' => 'AP', 'currency' =>'GNF', 'weight' => 'KG_CM');
$dhl_core['GP'] = array('region' => 'AM', 'currency' =>'EUR', 'weight' => 'KG_CM');
$dhl_core['GQ'] = array('region' => 'AP', 'currency' =>'XAF', 'weight' => 'KG_CM');
$dhl_core['GR'] = array('region' => 'EU', 'currency' =>'EUR', 'weight' => 'KG_CM');
$dhl_core['GT'] = array('region' => 'AM', 'currency' =>'GTQ', 'weight' => 'KG_CM');
$dhl_core['GU'] = array('region' => 'AM', 'currency' =>'USD', 'weight' => 'LB_IN');
$dhl_core['GW'] = array('region' => 'AP', 'currency' =>'XOF', 'weight' => 'KG_CM');
$dhl_core['GY'] = array('region' => 'AP', 'currency' =>'GYD', 'weight' => 'LB_IN');
$dhl_core['HK'] = array('region' => 'AM', 'currency' =>'HKD', 'weight' => 'KG_CM');
$dhl_core['HN'] = array('region' => 'AM', 'currency' =>'HNL', 'weight' => 'KG_CM');
$dhl_core['HR'] = array('region' => 'AP', 'currency' =>'HRK', 'weight' => 'KG_CM');
$dhl_core['HT'] = array('region' => 'AM', 'currency' =>'HTG', 'weight' => 'LB_IN');
$dhl_core['HU'] = array('region' => 'EU', 'currency' =>'HUF', 'weight' => 'KG_CM');
$dhl_core['IC'] = array('region' => 'EU', 'currency' =>'EUR', 'weight' => 'KG_CM');
$dhl_core['ID'] = array('region' => 'AP', 'currency' =>'IDR', 'weight' => 'KG_CM');
$dhl_core['IE'] = array('region' => 'EU', 'currency' =>'EUR', 'weight' => 'KG_CM');
$dhl_core['IL'] = array('region' => 'AP', 'currency' =>'ILS', 'weight' => 'KG_CM');
$dhl_core['IN'] = array('region' => 'AP', 'currency' =>'INR', 'weight' => 'KG_CM');
$dhl_core['IQ'] = array('region' => 'AP', 'currency' =>'IQD', 'weight' => 'KG_CM');
$dhl_core['IR'] = array('region' => 'AP', 'currency' =>'IRR', 'weight' => 'KG_CM');
$dhl_core['IS'] = array('region' => 'EU', 'currency' =>'ISK', 'weight' => 'KG_CM');
$dhl_core['IT'] = array('region' => 'EU', 'currency' =>'EUR', 'weight' => 'KG_CM');
$dhl_core['JE'] = array('region' => 'AM', 'currency' =>'GBP', 'weight' => 'KG_CM');
$dhl_core['JM'] = array('region' => 'AM', 'currency' =>'JMD', 'weight' => 'KG_CM');
$dhl_core['JO'] = array('region' => 'AP', 'currency' =>'JOD', 'weight' => 'KG_CM');
$dhl_core['JP'] = array('region' => 'AP', 'currency' =>'JPY', 'weight' => 'KG_CM');
$dhl_core['KE'] = array('region' => 'AP', 'currency' =>'KES', 'weight' => 'KG_CM');
$dhl_core['KG'] = array('region' => 'AP', 'currency' =>'KGS', 'weight' => 'KG_CM');
$dhl_core['KH'] = array('region' => 'AP', 'currency' =>'KHR', 'weight' => 'KG_CM');
$dhl_core['KI'] = array('region' => 'AP', 'currency' =>'AUD', 'weight' => 'KG_CM');
$dhl_core['KM'] = array('region' => 'AP', 'currency' =>'KMF', 'weight' => 'KG_CM');
$dhl_core['KN'] = array('region' => 'AM', 'currency' =>'XCD', 'weight' => 'LB_IN');
$dhl_core['KP'] = array('region' => 'AP', 'currency' =>'KPW', 'weight' => 'LB_IN');
$dhl_core['KR'] = array('region' => 'AP', 'currency' =>'KRW', 'weight' => 'KG_CM');
$dhl_core['KV'] = array('region' => 'AM', 'currency' =>'EUR', 'weight' => 'KG_CM');
$dhl_core['KW'] = array('region' => 'AP', 'currency' =>'KWD', 'weight' => 'KG_CM');
$dhl_core['KY'] = array('region' => 'AM', 'currency' =>'KYD', 'weight' => 'KG_CM');
$dhl_core['KZ'] = array('region' => 'AP', 'currency' =>'KZF', 'weight' => 'LB_IN');
$dhl_core['LA'] = array('region' => 'AP', 'currency' =>'LAK', 'weight' => 'KG_CM');
$dhl_core['LB'] = array('region' => 'AP', 'currency' =>'USD', 'weight' => 'KG_CM');
$dhl_core['LC'] = array('region' => 'AM', 'currency' =>'XCD', 'weight' => 'KG_CM');
$dhl_core['LI'] = array('region' => 'AM', 'currency' =>'CHF', 'weight' => 'LB_IN');
$dhl_core['LK'] = array('region' => 'AP', 'currency' =>'LKR', 'weight' => 'KG_CM');
$dhl_core['LR'] = array('region' => 'AP', 'currency' =>'LRD', 'weight' => 'KG_CM');
$dhl_core['LS'] = array('region' => 'AP', 'currency' =>'LSL', 'weight' => 'KG_CM');
$dhl_core['LT'] = array('region' => 'EU', 'currency' =>'EUR', 'weight' => 'KG_CM');
$dhl_core['LU'] = array('region' => 'EU', 'currency' =>'EUR', 'weight' => 'KG_CM');
$dhl_core['LV'] = array('region' => 'EU', 'currency' =>'EUR', 'weight' => 'KG_CM');
$dhl_core['LY'] = array('region' => 'AP', 'currency' =>'LYD', 'weight' => 'KG_CM');
$dhl_core['MA'] = array('region' => 'AP', 'currency' =>'MAD', 'weight' => 'KG_CM');
$dhl_core['MC'] = array('region' => 'AM', 'currency' =>'EUR', 'weight' => 'KG_CM');
$dhl_core['MD'] = array('region' => 'AP', 'currency' =>'MDL', 'weight' => 'KG_CM');
$dhl_core['ME'] = array('region' => 'AM', 'currency' =>'EUR', 'weight' => 'KG_CM');
$dhl_core['MG'] = array('region' => 'AP', 'currency' =>'MGA', 'weight' => 'KG_CM');
$dhl_core['MH'] = array('region' => 'AM', 'currency' =>'USD', 'weight' => 'LB_IN');
$dhl_core['MK'] = array('region' => 'AP', 'currency' =>'MKD', 'weight' => 'KG_CM');
$dhl_core['ML'] = array('region' => 'AP', 'currency' =>'COF', 'weight' => 'KG_CM');
$dhl_core['MM'] = array('region' => 'AP', 'currency' =>'USD', 'weight' => 'KG_CM');
$dhl_core['MN'] = array('region' => 'AP', 'currency' =>'MNT', 'weight' => 'KG_CM');
$dhl_core['MO'] = array('region' => 'AP', 'currency' =>'MOP', 'weight' => 'KG_CM');
$dhl_core['MP'] = array('region' => 'AM', 'currency' =>'USD', 'weight' => 'LB_IN');
$dhl_core['MQ'] = array('region' => 'AM', 'currency' =>'EUR', 'weight' => 'KG_CM');
$dhl_core['MR'] = array('region' => 'AP', 'currency' =>'MRO', 'weight' => 'KG_CM');
$dhl_core['MS'] = array('region' => 'AM', 'currency' =>'XCD', 'weight' => 'LB_IN');
$dhl_core['MT'] = array('region' => 'AP', 'currency' =>'EUR', 'weight' => 'KG_CM');
$dhl_core['MU'] = array('region' => 'AP', 'currency' =>'MUR', 'weight' => 'KG_CM');
$dhl_core['MV'] = array('region' => 'AP', 'currency' =>'MVR', 'weight' => 'KG_CM');
$dhl_core['MW'] = array('region' => 'AP', 'currency' =>'MWK', 'weight' => 'KG_CM');
$dhl_core['MX'] = array('region' => 'AM', 'currency' =>'MXN', 'weight' => 'KG_CM');
$dhl_core['MY'] = array('region' => 'AP', 'currency' =>'MYR', 'weight' => 'KG_CM');
$dhl_core['MZ'] = array('region' => 'AP', 'currency' =>'MZN', 'weight' => 'KG_CM');
$dhl_core['NA'] = array('region' => 'AP', 'currency' =>'NAD', 'weight' => 'KG_CM');
$dhl_core['NC'] = array('region' => 'AP', 'currency' =>'XPF', 'weight' => 'KG_CM');
$dhl_core['NE'] = array('region' => 'AP', 'currency' =>'XOF', 'weight' => 'KG_CM');
$dhl_core['NG'] = array('region' => 'AP', 'currency' =>'NGN', 'weight' => 'KG_CM');
$dhl_core['NI'] = array('region' => 'AM', 'currency' =>'NIO', 'weight' => 'KG_CM');
$dhl_core['NL'] = array('region' => 'EU', 'currency' =>'EUR', 'weight' => 'KG_CM');
$dhl_core['NO'] = array('region' => 'EU', 'currency' =>'NOK', 'weight' => 'KG_CM');
$dhl_core['NP'] = array('region' => 'AP', 'currency' =>'NPR', 'weight' => 'KG_CM');
$dhl_core['NR'] = array('region' => 'AP', 'currency' =>'AUD', 'weight' => 'KG_CM');
$dhl_core['NU'] = array('region' => 'AP', 'currency' =>'NZD', 'weight' => 'KG_CM');
$dhl_core['NZ'] = array('region' => 'AP', 'currency' =>'NZD', 'weight' => 'KG_CM');
$dhl_core['OM'] = array('region' => 'AP', 'currency' =>'OMR', 'weight' => 'KG_CM');
$dhl_core['PA'] = array('region' => 'AM', 'currency' =>'USD', 'weight' => 'KG_CM');
$dhl_core['PE'] = array('region' => 'AM', 'currency' =>'PEN', 'weight' => 'KG_CM');
$dhl_core['PF'] = array('region' => 'AP', 'currency' =>'XPF', 'weight' => 'KG_CM');
$dhl_core['PG'] = array('region' => 'AP', 'currency' =>'PGK', 'weight' => 'KG_CM');
$dhl_core['PH'] = array('region' => 'AP', 'currency' =>'PHP', 'weight' => 'KG_CM');
$dhl_core['PK'] = array('region' => 'AP', 'currency' =>'PKR', 'weight' => 'KG_CM');
$dhl_core['PL'] = array('region' => 'EU', 'currency' =>'PLN', 'weight' => 'KG_CM');
$dhl_core['PR'] = array('region' => 'AM', 'currency' =>'USD', 'weight' => 'LB_IN');
$dhl_core['PT'] = array('region' => 'EU', 'currency' =>'EUR', 'weight' => 'KG_CM');
$dhl_core['PW'] = array('region' => 'AM', 'currency' =>'USD', 'weight' => 'KG_CM');
$dhl_core['PY'] = array('region' => 'AM', 'currency' =>'PYG', 'weight' => 'KG_CM');
$dhl_core['QA'] = array('region' => 'AP', 'currency' =>'QAR', 'weight' => 'KG_CM');
$dhl_core['RE'] = array('region' => 'AP', 'currency' =>'EUR', 'weight' => 'KG_CM');
$dhl_core['RO'] = array('region' => 'EU', 'currency' =>'RON', 'weight' => 'KG_CM');
$dhl_core['RS'] = array('region' => 'AP', 'currency' =>'RSD', 'weight' => 'KG_CM');
$dhl_core['RU'] = array('region' => 'AP', 'currency' =>'RUB', 'weight' => 'KG_CM');
$dhl_core['RW'] = array('region' => 'AP', 'currency' =>'RWF', 'weight' => 'KG_CM');
$dhl_core['SA'] = array('region' => 'AP', 'currency' =>'SAR', 'weight' => 'KG_CM');
$dhl_core['SB'] = array('region' => 'AP', 'currency' =>'SBD', 'weight' => 'KG_CM');
$dhl_core['SC'] = array('region' => 'AP', 'currency' =>'SCR', 'weight' => 'KG_CM');
$dhl_core['SD'] = array('region' => 'AP', 'currency' =>'SDG', 'weight' => 'KG_CM');
$dhl_core['SE'] = array('region' => 'EU', 'currency' =>'SEK', 'weight' => 'KG_CM');
$dhl_core['SG'] = array('region' => 'AP', 'currency' =>'SGD', 'weight' => 'KG_CM');
$dhl_core['SH'] = array('region' => 'AP', 'currency' =>'SHP', 'weight' => 'KG_CM');
$dhl_core['SI'] = array('region' => 'EU', 'currency' =>'EUR', 'weight' => 'KG_CM');
$dhl_core['SK'] = array('region' => 'EU', 'currency' =>'EUR', 'weight' => 'KG_CM');
$dhl_core['SL'] = array('region' => 'AP', 'currency' =>'SLL', 'weight' => 'KG_CM');
$dhl_core['SM'] = array('region' => 'EU', 'currency' =>'EUR', 'weight' => 'KG_CM');
$dhl_core['SN'] = array('region' => 'AP', 'currency' =>'XOF', 'weight' => 'KG_CM');
$dhl_core['SO'] = array('region' => 'AM', 'currency' =>'SOS', 'weight' => 'KG_CM');
$dhl_core['SR'] = array('region' => 'AM', 'currency' =>'SRD', 'weight' => 'KG_CM');
$dhl_core['SS'] = array('region' => 'AP', 'currency' =>'SSP', 'weight' => 'KG_CM');
$dhl_core['ST'] = array('region' => 'AP', 'currency' =>'STD', 'weight' => 'KG_CM');
$dhl_core['SV'] = array('region' => 'AM', 'currency' =>'USD', 'weight' => 'KG_CM');
$dhl_core['SY'] = array('region' => 'AP', 'currency' =>'SYP', 'weight' => 'KG_CM');
$dhl_core['SZ'] = array('region' => 'AP', 'currency' =>'SZL', 'weight' => 'KG_CM');
$dhl_core['TC'] = array('region' => 'AM', 'currency' =>'USD', 'weight' => 'LB_IN');
$dhl_core['TD'] = array('region' => 'AP', 'currency' =>'XAF', 'weight' => 'KG_CM');
$dhl_core['TG'] = array('region' => 'AP', 'currency' =>'XOF', 'weight' => 'KG_CM');
$dhl_core['TH'] = array('region' => 'AP', 'currency' =>'THB', 'weight' => 'KG_CM');
$dhl_core['TJ'] = array('region' => 'AP', 'currency' =>'TJS', 'weight' => 'KG_CM');
$dhl_core['TL'] = array('region' => 'AP', 'currency' =>'USD', 'weight' => 'KG_CM');
$dhl_core['TN'] = array('region' => 'AP', 'currency' =>'TND', 'weight' => 'KG_CM');
$dhl_core['TO'] = array('region' => 'AP', 'currency' =>'TOP', 'weight' => 'KG_CM');
$dhl_core['TR'] = array('region' => 'AP', 'currency' =>'TRY', 'weight' => 'KG_CM');
$dhl_core['TT'] = array('region' => 'AM', 'currency' =>'TTD', 'weight' => 'LB_IN');
$dhl_core['TV'] = array('region' => 'AP', 'currency' =>'AUD', 'weight' => 'KG_CM');
$dhl_core['TW'] = array('region' => 'AP', 'currency' =>'TWD', 'weight' => 'KG_CM');
$dhl_core['TZ'] = array('region' => 'AP', 'currency' =>'TZS', 'weight' => 'KG_CM');
$dhl_core['UA'] = array('region' => 'AP', 'currency' =>'UAH', 'weight' => 'KG_CM');
$dhl_core['UG'] = array('region' => 'AP', 'currency' =>'USD', 'weight' => 'KG_CM');
$dhl_core['US'] = array('region' => 'AM', 'currency' =>'USD', 'weight' => 'LB_IN');
$dhl_core['UY'] = array('region' => 'AM', 'currency' =>'UYU', 'weight' => 'KG_CM');
$dhl_core['UZ'] = array('region' => 'AP', 'currency' =>'UZS', 'weight' => 'KG_CM');
$dhl_core['VC'] = array('region' => 'AM', 'currency' =>'XCD', 'weight' => 'LB_IN');
$dhl_core['VE'] = array('region' => 'AM', 'currency' =>'VEF', 'weight' => 'KG_CM');
$dhl_core['VG'] = array('region' => 'AM', 'currency' =>'USD', 'weight' => 'LB_IN');
$dhl_core['VI'] = array('region' => 'AM', 'currency' =>'USD', 'weight' => 'LB_IN');
$dhl_core['VN'] = array('region' => 'AP', 'currency' =>'VND', 'weight' => 'KG_CM');
$dhl_core['VU'] = array('region' => 'AP', 'currency' =>'VUV', 'weight' => 'KG_CM');
$dhl_core['WS'] = array('region' => 'AP', 'currency' =>'WST', 'weight' => 'KG_CM');
$dhl_core['XB'] = array('region' => 'AM', 'currency' =>'EUR', 'weight' => 'LB_IN');
$dhl_core['XC'] = array('region' => 'AM', 'currency' =>'EUR', 'weight' => 'LB_IN');
$dhl_core['XE'] = array('region' => 'AM', 'currency' =>'ANG', 'weight' => 'LB_IN');
$dhl_core['XM'] = array('region' => 'AM', 'currency' =>'EUR', 'weight' => 'LB_IN');
$dhl_core['XN'] = array('region' => 'AM', 'currency' =>'XCD', 'weight' => 'LB_IN');
$dhl_core['XS'] = array('region' => 'AP', 'currency' =>'SIS', 'weight' => 'KG_CM');
$dhl_core['XY'] = array('region' => 'AM', 'currency' =>'ANG', 'weight' => 'LB_IN');
$dhl_core['YE'] = array('region' => 'AP', 'currency' =>'YER', 'weight' => 'KG_CM');
$dhl_core['YT'] = array('region' => 'AP', 'currency' =>'EUR', 'weight' => 'KG_CM');
$dhl_core['ZA'] = array('region' => 'AP', 'currency' =>'ZAR', 'weight' => 'KG_CM');
$dhl_core['ZM'] = array('region' => 'AP', 'currency' =>'ZMW', 'weight' => 'KG_CM');
$dhl_core['ZW'] = array('region' => 'AP', 'currency' =>'USD', 'weight' => 'KG_CM');
}
$a2z_dhlexpress = new a2z_dhlexpress_parent();
}
?>