Changeset 3472393
- Timestamp:
- 03/02/2026 07:11:36 AM (4 weeks ago)
- Location:
- shipment-tracker-for-woocommerce
- Files:
-
- 4 added
- 1 deleted
- 33 edited
-
tags/1.5.3.3/.vscode (deleted)
-
trunk/admin/class-bt-sync-shipment-tracking-admin.php (modified) (17 diffs)
-
trunk/admin/js/bt-sync-shipment-tracking-admin.js (modified) (3 diffs)
-
trunk/admin/partials/bt-shipment-tracking-manual-metabox.php (modified) (1 diff)
-
trunk/admin/partials/bt-shipment-tracking-metabox.php (modified) (3 diffs)
-
trunk/admin/partials/new_settings/bt-shipment-dokan-multi-vendor.php (added)
-
trunk/admin/partials/order_admin_after_shipping.php (modified) (1 diff)
-
trunk/admin/partials/order_shipment_details.php (modified) (1 diff)
-
trunk/admin/partials/shipping_provider_pages (added)
-
trunk/admin/partials/shipping_provider_pages/bt-shipment-ithink-logistic.php (added)
-
trunk/bt-sync-shipment-tracking.php (modified) (3 diffs)
-
trunk/composer.lock (modified) (6 diffs)
-
trunk/includes/class-bt-sync-shipment-setting-update-core.php (modified) (1 diff)
-
trunk/includes/class-bt-sync-shipment-tracking-activator.php (modified) (1 diff)
-
trunk/includes/class-bt-sync-shipment-tracking-admin-ajax-functions.php (modified) (5 diffs)
-
trunk/includes/class-bt-sync-shipment-tracking-crons.php (modified) (5 diffs)
-
trunk/includes/class-bt-sync-shipment-tracking-deactivator.php (modified) (1 diff)
-
trunk/includes/class-bt-sync-shipment-tracking-i18n.php (modified) (1 diff)
-
trunk/includes/class-bt-sync-shipment-tracking-loader.php (modified) (1 diff)
-
trunk/includes/class-bt-sync-shipment-tracking-rest-functions.php (modified) (1 diff)
-
trunk/includes/class-bt-sync-shipment-tracking-rest.php (modified) (1 diff)
-
trunk/includes/class-bt-sync-shipment-tracking.php (modified) (15 diffs)
-
trunk/includes/models/class-bt-sync-shipment-tracking-shipment-model.php (modified) (1 diff)
-
trunk/includes/shipping_providers/delhivery.php (modified) (1 diff)
-
trunk/includes/shipping_providers/ekart.php (modified) (2 diffs)
-
trunk/includes/shipping_providers/fship.php (modified) (1 diff)
-
trunk/includes/shipping_providers/ithink.php (added)
-
trunk/includes/shipping_providers/manual.php (modified) (1 diff)
-
trunk/includes/shipping_providers/nimbuspost.php (modified) (1 diff)
-
trunk/includes/shipping_providers/nimbuspost_new.php (modified) (1 diff)
-
trunk/includes/shipping_providers/proship.php (modified) (1 diff)
-
trunk/includes/shipping_providers/ship24.php (modified) (1 diff)
-
trunk/includes/shipping_providers/shipmozo.php (modified) (5 diffs)
-
trunk/includes/shipping_providers/shiprocket.php (modified) (1 diff)
-
trunk/includes/shipping_providers/shyplite.php (modified) (1 diff)
-
trunk/includes/shipping_providers/xpressbees.php (modified) (1 diff)
-
trunk/public/class-bt-sync-shipment-tracking-public.php (modified) (5 diffs)
-
trunk/public/partials/bt-sync-shipment-tracking-public-display.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
shipment-tracker-for-woocommerce/trunk/admin/class-bt-sync-shipment-tracking-admin.php
r3460036 r3472393 56 56 private $courierkaro; 57 57 private $proship; 58 private $ithink; 58 59 59 60 /** … … 64 65 * @param string $version The version of this plugin. 65 66 */ 66 public function __construct($plugin_name, $version, $shiprocket, $shyplite, $nimbuspost, $manual, $licenser, $shipmozo, $nimbuspost_new, $delhivery, $ship24, $fship, $ekart, $courierkaro, $proship )67 public function __construct($plugin_name, $version, $shiprocket, $shyplite, $nimbuspost, $manual, $licenser, $shipmozo, $nimbuspost_new, $delhivery, $ship24, $fship, $ekart, $courierkaro, $proship, $ithink) 67 68 { 68 69 … … 82 83 $this->courierkaro = $courierkaro; 83 84 $this->proship = $proship; 85 $this->ithink = $ithink; 84 86 } 85 87 … … 158 160 $current_screen->id == "shipment-tracking_page_bt-shipment-tracking-timer" || 159 161 $current_screen->id == "toplevel_page_bt-shipment-tracking"|| 160 $current_screen->id == "shipment-tracking_page_bt-shipment-tracking-help-support" 162 $current_screen->id == "shipment-tracking_page_bt-shipment-tracking-help-support"|| 163 $current_screen->id == "shipment-tracking_page_bt-shipment-tracking-ithink-logistics" 161 164 )) { 162 165 $script_data = array( … … 174 177 "test_conn_ekart_nonce" => wp_create_nonce('api_call_for_ekart_test_connection'), 175 178 "test_conn_ship24_nonce" => wp_create_nonce('api_call_for_ship24_test_connection'), 179 "test_conn_ithink_nonce" => wp_create_nonce('api_call_for_ithink_test_connection'), 176 180 "test_conn_nimbuspost_nonce" => wp_create_nonce('api_check_for_nimbuspost_test_connection'), 177 181 "test_conn_proship_nonce" => wp_create_nonce('api_call_for_proship_test_connection'), … … 332 336 $order->add_order_note('Added schedule to push this order to delhivery.' . "\n\n- Shipment tracker for woocommerce", false); 333 337 wp_schedule_single_event(time() + 1, 'bt_push_order_to_proship', array($order_id)); 338 339 } 340 }else if ($bt_shipping_provider == "ithink") { 341 $settings = get_option('ithink_logistics_settings'); 342 $bt_sst_ithink_push_order_method_is_automatic = isset($settings['auto_push']) ? $settings['auto_push'] : '0'; 343 $is_premium = $this->licenser->is_license_active(); 344 if ($bt_sst_ithink_push_order_method_is_automatic == 1 && $is_premium) { 345 $order = wc_get_order($order_id); 346 $order->add_order_note('Added schedule to push this order to delhivery.' . "\n\n- Shipment tracker for woocommerce", false); 347 wp_schedule_single_event(time() + 1, 'bt_push_order_to_ithink', array($order_id)); 334 348 335 349 } … … 638 652 639 653 } else { 640 $order->add_order_note("Failed to push order to Delhivery, please verify api credentials." . "\n\n- Shipment tracker for woocommerce", false); 654 $remarks = 'Unknown error'; 655 if (isset($push_resp['packages']) && is_array($push_resp['packages']) && !empty($push_resp['packages'])) { 656 if (isset($push_resp['packages'][0]['remarks'])) { 657 $remarks = $push_resp['packages'][0]['remarks']; 658 } 659 660 } elseif (isset($push_resp['rmk'])) { 661 $remarks = $push_resp['rmk']; 662 } 663 $order->add_order_note( 664 "Failed to push order to Delhivery, got error response from delhivery: '" 665 . json_encode($remarks) . "'" 666 . "\n\n- Shipment tracker for woocommerce", 667 false 668 ); 641 669 $order->add_order_note("Response from Delhivery Push api: " . json_encode($push_resp) . "\n\n- Shipment tracker for woocommerce", false); 642 670 } … … 804 832 } 805 833 } 834 public function push_order_to_ithink($order_id) 835 { 836 try { 837 $order = wc_get_order($order_id); 838 839 $existing_awb = Bt_Sync_Shipment_Tracking::bt_sst_get_order_meta( 840 $order_id, 841 '_bt_ithink_waybill_no', 842 true 843 ); 844 845 if (!empty($existing_awb)) { 846 $order->add_order_note( 847 'Delivery already assigned. Waybill No: ' . $existing_awb . "\n\n- Shipment tracker for WooCommerce", 848 false 849 ); 850 return; 851 } 852 853 $order->add_order_note( 854 'Pushing order to iThink: ' . $order_id . "\n\n- Shipment tracker for WooCommerce", 855 false 856 ); 857 858 $push_resp = $this->ithink->create_forward_order($order_id); 859 860 if (empty($push_resp) || !isset($push_resp['waybill'] )) { 861 $order->add_order_note( 862 'Failed to push order to iThink. Empty or invalid response.' . "\n\n- Shipment tracker for WooCommerce", 863 false 864 ); 865 return; 866 } 867 868 if ($push_resp['status']==="error") { 869 $error_msg = $push_resp['remark']; 870 871 $order->add_order_note( 872 "Failed to push order to iThink: {$error_msg}\n\n- Shipment tracker for WooCommerce", 873 false 874 ); 875 return; 876 } 877 878 if (!empty($push_resp['waybill'])) { 879 $awb = $push_resp['waybill']; 880 // Bt_Sync_Shipment_Tracking::bt_sst_update_order_meta($order_id, '_proship_new_label_url', $push_resp['result']['label_url']); 881 882 Bt_Sync_Shipment_Tracking::bt_sst_update_order_meta( 883 $order_id, 884 '_bt_ithink_waybill_no', 885 $awb 886 ); 887 Bt_Sync_Shipment_Tracking::bt_sst_update_order_meta($order_id, '_bt_shipping_awb', $awb); 888 889 $order->add_order_note( 890 "Order pushed to iThink successfully. Waybill No: {$awb}\n\n- Shipment tracker for WooCommerce", 891 false 892 ); 893 894 bt_force_sync_order_tracking($order_id); 895 } else { 896 $order->add_order_note( 897 'Order created but AWB number not received from iThink.' . "\n\n- Shipment tracker for WooCommerce", 898 false 899 ); 900 } 901 902 } catch (Exception $e) { 903 error_log( 904 'iThink push error for order ' . $order_id . ': ' . $e->getMessage() 905 ); 906 } 907 } 806 908 807 909 public function push_order_to_nimbuspost($order_id) … … 1121 1223 if (!$bt_shipping_provider || ($bt_shipping_provider == 'manual' && $shipping_mode_is_manual_or_ship24 == "manual")) { 1122 1224 include plugin_dir_path(dirname(__FILE__)) . 'admin/partials/bt-shipment-tracking-manual-metabox.php'; 1123 } else if ($bt_shipping_provider == 'shiprocket' || $bt_shipping_provider == 'shyplite' || $bt_shipping_provider == 'nimbuspost' || $bt_shipping_provider == 'xpressbees' || $bt_shipping_provider == 'shipmozo' || $bt_shipping_provider == 'nimbuspost_new' || $bt_shipping_provider == 'delhivery' || $shipping_mode_is_manual_or_ship24 == "ship24" || $bt_shipping_provider == "fship" || $bt_shipping_provider == "ekart" || $bt_shipping_provider == "courierkaro" || $bt_shipping_provider == "proship" ) {1225 } else if ($bt_shipping_provider == 'shiprocket' || $bt_shipping_provider == 'shyplite' || $bt_shipping_provider == 'nimbuspost' || $bt_shipping_provider == 'xpressbees' || $bt_shipping_provider == 'shipmozo' || $bt_shipping_provider == 'nimbuspost_new' || $bt_shipping_provider == 'delhivery' || $shipping_mode_is_manual_or_ship24 == "ship24" || $bt_shipping_provider == "fship" || $bt_shipping_provider == "ekart" || $bt_shipping_provider == "courierkaro" || $bt_shipping_provider == "proship"|| $bt_shipping_provider == "ithink") { 1124 1226 $order_id = isset($_GET['post']) ? $_GET['post'] : sanitize_text_field($_GET['id']); 1125 1227 include plugin_dir_path(dirname(__FILE__)) . 'admin/partials/bt-shipment-tracking-metabox.php'; … … 1365 1467 } 1366 1468 // $response = "idfugdf"; 1469 wp_send_json($response); 1470 die(); 1471 } 1472 public function api_call_for_ithink_test_connection() 1473 { 1474 $nonce = sanitize_text_field($_GET["value"]); 1475 if (!wp_verify_nonce($nonce, 'api_call_for_ithink_test_connection')) { 1476 } 1477 $response = array( 1478 "status" => false, 1479 "data" => null, 1480 "message" => "Test Connection Failed. Please verify api credentials and try again." 1481 ); 1482 $api_call = $this->ithink->ithink_test_connection(); 1483 if ($api_call === true) { 1484 $response = array( 1485 "status" => true, 1486 "data" => null, 1487 "message" => "Test Connection Successful. Great work!!" 1488 ); 1489 } 1367 1490 wp_send_json($response); 1368 1491 die(); … … 2451 2574 } else if (isset($_GET['bt_push_to_shipmozo']) && $_GET['bt_push_to_shipmozo'] == 1 && (isset($_GET['post']) || isset($_GET['id']))) { 2452 2575 $order_id = isset($_GET['post']) ? $_GET['post'] : $_GET['id']; 2576 $order = wc_get_order($order_id); 2577 if ($order) { 2578 $order->add_order_note( 2579 'Manual push to Shipmozo triggered by admin.' . "\n\n- Shipment tracker for woocommerce", 2580 false 2581 ); 2582 } 2453 2583 $this->push_order_to_shipmozo($order_id); 2454 2584 unset($_GET['bt_push_to_shipmozo']); … … 2498 2628 $current_page = admin_url(sprintf($pagenow . '?%s', http_build_query($_GET))); 2499 2629 wp_safe_redirect($current_page); 2630 }else if (isset($_GET['bt_push_to_ithink']) && $_GET['bt_push_to_ithink'] == 1 && (isset($_GET['post']) || isset($_GET['id']))) { 2631 $order_id = isset($_GET['post']) ? $_GET['post'] : $_GET['id']; 2632 $getresponce = $this->push_order_to_ithink($order_id); 2633 unset($_GET['bt_push_to_ithink']); 2634 global $pagenow; 2635 $current_page = admin_url(sprintf($pagenow . '?%s', http_build_query($_GET))); 2636 wp_safe_redirect($current_page); 2500 2637 } else if (is_admin() && isset($_GET['page']) && $_GET['page'] === 'crb_carbon_fields_container_shipment_tracker.php') { 2501 2638 wp_safe_redirect(admin_url('admin.php?page=bt-shipment-tracking')); … … 3372 3509 $resp = false; 3373 3510 } 3511 } else if ($shipping_provider == 'ithink') { 3512 if (isset($_POST['awbs'])) { 3513 $awbs = array_map('sanitize_text_field', $_POST['awbs']); 3514 $resp = $this->ithink->generate_shipping_label($awbs); 3515 } 3374 3516 } 3375 3517 // else if($shipping_provider == 'nimbuspost'){ … … 3621 3763 add_submenu_page( 3622 3764 'bt-shipment-tracking', 3765 'iThink Logistics - Shipment Tracker for Woocommerce', // Page title 3766 'iThink Logistics', // Menu title 3767 'manage_options', // Capability 3768 'bt-shipment-tracking-ithink-logistics', // Menu slug 3769 [$this, 'bt_shipment_tracking_ithink_logistics_callback'], // Correct way to call class method 3770 ); 3771 add_submenu_page( 3772 'bt-shipment-tracking', 3623 3773 'Premium Activation - Shipment Tracker for Woocommerce', // Page title 3624 3774 'Activate Premium', // Menu title … … 3627 3777 [$this, 'bt_shipment_tracking_premium_callback'], // Correct way to call class method 3628 3778 ); 3779 3780 // add_submenu_page( 3781 // 'bt-shipment-tracking', 3782 // 'Dokan Multi Vendor - Shipment Tracker for Woocommerce', // Page title 3783 // 'Dokan Multi Vendor', // Menu title 3784 // 'manage_options', // Capability 3785 // 'bt-shipment-tracking-multi-vendor', // Menu slug 3786 // [$this, 'bt_shipment_tracking_multi_vendor_callback'], // Correct way to call class method 3787 // ); 3629 3788 3630 3789 add_submenu_page( … … 3665 3824 include plugin_dir_path(dirname(__FILE__)) . 'admin/partials/new_settings/bt-shipment-new-settings.php'; 3666 3825 // include plugin_dir_path(dirname(__FILE__)) . 'admin/partials/new_settings/bt-shipment-help.php'; 3826 } 3827 public function bt_shipment_tracking_ithink_logistics_callback() 3828 { 3829 // wp_enqueue_script('bt-shipment-new-settings-js'); 3830 wp_enqueue_script($this->plugin_name); 3831 // $active_tab = "help_tab"; 3832 wp_enqueue_style('bulma-css'); 3833 include plugin_dir_path(dirname(__FILE__)) . 'admin/partials/shipping_provider_pages/bt-shipment-ithink-logistic.php'; 3834 } 3835 public function bt_shipment_tracking_multi_vendor_callback() 3836 { 3837 // wp_enqueue_script('bt-shipment-new-settings-js'); 3838 wp_enqueue_script($this->plugin_name); 3839 // $active_tab = "help_tab"; 3840 wp_enqueue_style('bulma-css'); 3841 include plugin_dir_path(dirname(__FILE__)) . 'admin/partials/new_settings/bt-shipment-dokan-multi-vendor.php'; 3667 3842 } 3668 3843 … … 3906 4081 $obj = new Bt_Sync_Shipment_Tracking_Proship(); 3907 4082 $response = $obj->update_order_shipment_status($order_id); 4083 }else if ($bt_shipping_provider == 'ithink') { 4084 $obj = new Bt_Sync_Shipment_Tracking_Ithink(); 4085 $response = $obj->update_order_shipment_status($order_id); 3908 4086 } 3909 4087 -
shipment-tracker-for-woocommerce/trunk/admin/js/bt-sync-shipment-tracking-admin.js
r3460036 r3472393 250 250 api_test_connection_ship24(); 251 251 }); 252 $(document).on('click', '#api_test_connection_btn_ithink', function (e) { 253 e.preventDefault(); 254 // alert("Please save the settings first, then test the connection."); 255 $(this).addClass('is-loading'); 256 api_test_connection_ithink(); 257 }); 252 258 253 259 $(document).on('click', '#btn-bt-sync-now-shyplite', function (e) { … … 349 355 $(document).on('click', '#api_tc_m_close_btn_delh', function (e) { 350 356 $('#api_test_connection_modal_delh').removeClass('is-active'); 357 }); 358 $(document).on('click', '#api_tc_m_close_btn_ithink', function (e) { 359 $('#api_test_connection_modal_ithink').removeClass('is-active'); 360 $('#api_test_connection_modal_ithink').css('display', 'none'); 351 361 }); 352 362 $(document).on('click', '#api_tc_m_close_btn_ship24', function (e) { … … 1018 1028 ) 1019 1029 } 1030 function api_test_connection_ithink() { 1031 var nonce = bt_sync_shipment_track_data.test_conn_nonce; 1032 $.get( 1033 bt_sync_shipment_track_data.ajax_url, 1034 { action: 'api_call_for_ithink_test_connection', value: nonce }, 1035 function (res) { 1036 $('#api_tc-m-content_ithink').html(res.message); 1037 $('#api_test_connection_modal_ithink').addClass('is-active'); 1038 $('#api_test_connection_modal_ithink').css('display', 'flex'); 1039 $('#api_test_connection_btn_ithink').removeClass('is-loading'); 1040 1041 } 1042 ) 1043 } 1020 1044 function bt_st_show_info(info_text) { 1021 1045 jQuery('#bt_notify_popup_content_title').text(info_text); -
shipment-tracker-for-woocommerce/trunk/admin/partials/bt-shipment-tracking-manual-metabox.php
r3292239 r3472393 214 214 </p> 215 215 <p class="form-field bt_sst_current_saved_data"> 216 <span><?php echo $bt_shipment_tracking['current_address']?></span>217 <span><?php echo " ". $bt_shipment_tracking['current_country']." "; ?></span>218 <span><?php echo $bt_shipment_tracking['current_pincode']?></span>216 <span><?php echo esc_html($bt_shipment_tracking['current_address']); ?></span> 217 <span><?php echo " ".esc_html($bt_shipment_tracking['current_country'])." "; ?></span> 218 <span><?php echo esc_html($bt_shipment_tracking['current_pincode']); ?></span> 219 219 </p> 220 220 <p class="form-field "> -
shipment-tracker-for-woocommerce/trunk/admin/partials/bt-shipment-tracking-metabox.php
r3460036 r3472393 94 94 </div> 95 95 <?php } ?> 96 <?php 97 98 if($bt_shipping_provider == "ekart" || $bt_shipping_provider == "ithink" ){ 99 $dimension_unit = get_option('woocommerce_dimension_unit'); 100 $weight_unit = get_option('woocommerce_weight_unit'); 101 102 $computed = Bt_Sync_Shipment_Tracking::bt_sst_get_package_dimensions($order_id); 103 $meta_length = $computed['length']; 104 $meta_width = $computed['width']; 105 $meta_height = $computed['height']; 106 $meta_weight = $computed['weight']; 107 108 ?> 109 <br> 110 <div style="padding: 10px; background: #f9f9f9; border: 1px solid #ddd; border-radius: 4px;"> 111 <strong>Package Dimensions</strong> 112 <div style="margin-top: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px;"> 113 <div> 114 <label style="display: block; font-size: 12px; margin-bottom: 4px;">Length (<?php echo esc_html($dimension_unit); ?>)</label> 115 <input type="number" step="any" id="bt_package_length_metabox" name="bt_package_length_metabox" value="<?php echo esc_attr($meta_length); ?>" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 3px;" /> 116 </div> 117 <div> 118 <label style="display: block; font-size: 12px; margin-bottom: 4px;">Width (<?php echo esc_html($dimension_unit); ?>)</label> 119 <input type="number" step="any" id="bt_package_width_metabox" name="bt_package_width_metabox" value="<?php echo esc_attr($meta_width); ?>" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 3px;" /> 120 </div> 121 <div> 122 <label style="display: block; font-size: 12px; margin-bottom: 4px;">Height (<?php echo esc_html($dimension_unit); ?>)</label> 123 <input type="number" step="any" id="bt_package_height_metabox" name="bt_package_height_metabox" value="<?php echo esc_attr($meta_height); ?>" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 3px;" /> 124 </div> 125 <div> 126 <label style="display: block; font-size: 12px; margin-bottom: 4px;">Weight (<?php echo esc_html($weight_unit); ?>)</label> 127 <input type="number" step="any" id="bt_package_weight_metabox" name="bt_package_weight_metabox" value="<?php echo esc_attr($meta_weight); ?>" style="width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 3px;" /> 128 </div> 129 </div> 130 <button type="button" id="save_package_dims" class="button button-primary" style="margin-top: 10px;">Save Package Dimensions</button> 131 </div> 132 <?php } ?> 96 133 <a id="bt_notify_popup" style="display:none;" 97 134 href="#TB_inline?&width=200&height=150&inlineId=bt_notify_popup_content" class="thickbox"></a> … … 116 153 <?php } else { ?> 117 154 <button type="button" id="sync_manual" class="button save_order" href='#'>Sync Tracking Now</button> 118 <?php if ($get_awb_no && $bt_shipping_provider == 'shiprocket' || $bt_shipping_provider == 'delhivery' || $bt_shipping_provider == 'shipmozo' || $bt_shipping_provider == 'nimbuspost_new' || $bt_shipping_provider == 'nimbuspost'|| $bt_shipping_provider == 'proship' ) { ?>155 <?php if ($get_awb_no && $bt_shipping_provider == 'shiprocket' || $bt_shipping_provider == 'delhivery' || $bt_shipping_provider == 'shipmozo' || $bt_shipping_provider == 'nimbuspost_new' || $bt_shipping_provider == 'nimbuspost'|| $bt_shipping_provider == 'proship'|| $bt_shipping_provider == 'ithink') { ?> 119 156 <button type="button" style="margin:5px 0" ; id="dawnload_able_pdf" class="button dawnload_able_document" 120 157 href='#'>Download Label</button> … … 339 376 } 340 377 378 jQuery('#save_package_dims').click(function () { 379 jQuery('#save_package_dims').text('Saving...').prop('disabled', true); 380 381 jQuery.ajax({ 382 method: "POST", 383 url: '<?php echo esc_url(admin_url('admin-ajax.php')); ?>', 384 dataType: "json", 385 data: { 386 'order_id': '<?php echo esc_js($order_id); ?>', 387 'package_length': jQuery('#bt_package_length_metabox').val(), 388 'package_width': jQuery('#bt_package_width_metabox').val(), 389 'package_height': jQuery('#bt_package_height_metabox').val(), 390 'package_weight': jQuery('#bt_package_weight_metabox').val(), 391 'action': 'save_package_dimensions' 392 }, success: function (response) { 393 jQuery('#save_package_dims').text('Save Package Dimensions').prop('disabled', false); 394 if (response && response.status) { 395 bt_st_show_info("Package dimensions saved successfully."); 396 } else { 397 alert('Failed to save package dimensions: ' + (response?.message || 'Unknown error')); 398 } 399 }, error: function (jqXHR, textStatus, errorThrown) { 400 jQuery('#save_package_dims').text('Save Package Dimensions').prop('disabled', false); 401 alert('Error saving package dimensions: ' + errorThrown); 402 } 403 }); 404 }); 405 406 341 407 </script> 342 408 </div> -
shipment-tracker-for-woocommerce/trunk/admin/partials/order_admin_after_shipping.php
r3460036 r3472393 59 59 ?> 60 60 <a href="<?php echo esc_url($current_page) ?>">Push Now</a> 61 <?php elseif($bt_shipping_provider == "ithink" && wc_get_order($order_id)->has_status('processing')): 62 global $pagenow; 63 $current_page = admin_url(sprintf($pagenow . '?%s', http_build_query(array_merge($_GET, array("bt_push_to_ithink" => true))))); 64 ?> 65 <a href="<?php echo esc_url($current_page) ?>">Push Now</a> 61 66 <?php endif ?> 62 67 -
shipment-tracker-for-woocommerce/trunk/admin/partials/order_shipment_details.php
r3460036 r3472393 48 48 $edit = "<br><a class='bt_sync_order_tracking' data-order-id='$order_id' href='#'>Sync Now</a>"; 49 49 } 50 else if ($bt_shipping_provider == "ithink"){ 51 $edit = "<br><a class='bt_sync_order_tracking' data-order-id='$order_id' href='#'>Sync Now</a>"; 52 } 50 53 // } 51 54 } -
shipment-tracker-for-woocommerce/trunk/bt-sync-shipment-tracking.php
r3460036 r3472393 17 17 * Plugin URI: https://shipment-tracker-for-woocommerce.bitss.tech/ 18 18 * Description: Most comprehensive shipment tracking plugin that extends your woocommerce store with shipment related features. Keeps you & your customers informed about shipment movement. 19 * Version: 1.5.3. 219 * Version: 1.5.3.3 20 20 * Author: Bitss Techniques 21 21 * Author URI: https://shipment-tracker-for-woocommerce.bitss.tech … … 59 59 60 60 define( 'Carbon_Fields\URL', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'vendor/htmlburger/carbon-fields/' );//fix for Bitnami installations. 61 define( 'BT_SYNC_SHIPMENT_TRACKING_VERSION', '1.5.3. 2' );61 define( 'BT_SYNC_SHIPMENT_TRACKING_VERSION', '1.5.3.3' ); 62 62 define( 'BT_SHIPPING_PROVIDERS', array('delhivery' =>'Delhivery','nimbuspost' => 'Nimbuspost (Deprecated)','nimbuspost_new' => 'Nimbuspost','shipmozo'=>'Shipmozo','shiprocket' => 'Shiprocket', 'xpressbees' => 'Xpressbees', 'manual' =>'Custom Shipping', 'fship' => 'Fship','ekart' => 'Ekart','courierkaro' => 'Courier Karo','proship' => 'Proship') ); 63 63 define( 'BT_SHIPPING_PROVIDERS_WITH_NONE', array('none' =>'none','delhivery' =>'Delhivery', 'nimbuspost' => 'Nimbuspost (OLD)','nimbuspost_new' => 'Nimbuspost(NEW)','shipmozo'=>'Shipmozo','shiprocket' => 'Shiprocket', 'xpressbees' => 'Xpressbees','manual' =>'Custom Shipping' , 'fship' => 'Fship','ekart' => 'Ekart','courierkaro' => 'Courier Karo','proship' => 'Proship') ); … … 149 149 } ); 150 150 run_bt_sync_shipment_tracking(); 151 // Enable error reporting for debugging (development only)152 if (defined('WP_DEBUG') && WP_DEBUG) {153 error_reporting(E_ALL);154 ini_set('display_errors', '1');155 ini_set('display_startup_errors', '1');156 } -
shipment-tracker-for-woocommerce/trunk/composer.lock
r3460036 r3472393 204 204 { 205 205 "name": "doctrine/deprecations", 206 "version": "1.1. 6",206 "version": "1.1.5", 207 207 "source": { 208 208 "type": "git", 209 209 "url": "https://github.com/doctrine/deprecations.git", 210 "reference": " d4fe3e6fd9bb9e72557a19674f44d8ac7db4c6ca"211 }, 212 "dist": { 213 "type": "zip", 214 "url": "https://api.github.com/repos/doctrine/deprecations/zipball/ d4fe3e6fd9bb9e72557a19674f44d8ac7db4c6ca",215 "reference": " d4fe3e6fd9bb9e72557a19674f44d8ac7db4c6ca",210 "reference": "459c2f5dd3d6a4633d3b5f46ee2b1c40f57d3f38" 211 }, 212 "dist": { 213 "type": "zip", 214 "url": "https://api.github.com/repos/doctrine/deprecations/zipball/459c2f5dd3d6a4633d3b5f46ee2b1c40f57d3f38", 215 "reference": "459c2f5dd3d6a4633d3b5f46ee2b1c40f57d3f38", 216 216 "shasum": "" 217 217 }, … … 220 220 }, 221 221 "conflict": { 222 "phpunit/phpunit": "<=7.5 || >=1 4"222 "phpunit/phpunit": "<=7.5 || >=13" 223 223 }, 224 224 "require-dev": { 225 "doctrine/coding-standard": "^9 || ^12 || ^1 4",226 "phpstan/phpstan": "1.4.10 || 2.1. 30",225 "doctrine/coding-standard": "^9 || ^12 || ^13", 226 "phpstan/phpstan": "1.4.10 || 2.1.11", 227 227 "phpstan/phpstan-phpunit": "^1.0 || ^2", 228 "phpunit/phpunit": "^7.5 || ^8.5 || ^9.6 || ^10.5 || ^11.5 || ^12 .4 || ^13.0",228 "phpunit/phpunit": "^7.5 || ^8.5 || ^9.6 || ^10.5 || ^11.5 || ^12", 229 229 "psr/log": "^1 || ^2 || ^3" 230 230 }, … … 246 246 "support": { 247 247 "issues": "https://github.com/doctrine/deprecations/issues", 248 "source": "https://github.com/doctrine/deprecations/tree/1.1. 6"249 }, 250 "time": "202 6-02-07T07:09:04+00:00"248 "source": "https://github.com/doctrine/deprecations/tree/1.1.5" 249 }, 250 "time": "2025-04-07T20:06:18+00:00" 251 251 }, 252 252 { … … 993 993 { 994 994 "name": "symfony/finder", 995 "version": "v6.4.3 3",995 "version": "v6.4.32", 996 996 "source": { 997 997 "type": "git", 998 998 "url": "https://github.com/symfony/finder.git", 999 "reference": " 24965ca011dac87431729640feef8bcf7b5523e0"1000 }, 1001 "dist": { 1002 "type": "zip", 1003 "url": "https://api.github.com/repos/symfony/finder/zipball/ 24965ca011dac87431729640feef8bcf7b5523e0",1004 "reference": " 24965ca011dac87431729640feef8bcf7b5523e0",999 "reference": "3ec24885c1d9ababbb9c8f63bb42fea3c8c9b6de" 1000 }, 1001 "dist": { 1002 "type": "zip", 1003 "url": "https://api.github.com/repos/symfony/finder/zipball/3ec24885c1d9ababbb9c8f63bb42fea3c8c9b6de", 1004 "reference": "3ec24885c1d9ababbb9c8f63bb42fea3c8c9b6de", 1005 1005 "shasum": "" 1006 1006 }, … … 1037 1037 "homepage": "https://symfony.com", 1038 1038 "support": { 1039 "source": "https://github.com/symfony/finder/tree/v6.4.3 3"1039 "source": "https://github.com/symfony/finder/tree/v6.4.32" 1040 1040 }, 1041 1041 "funding": [ … … 1057 1057 } 1058 1058 ], 1059 "time": "2026-01- 26T13:03:48+00:00"1059 "time": "2026-01-10T14:09:00+00:00" 1060 1060 }, 1061 1061 { -
shipment-tracker-for-woocommerce/trunk/includes/class-bt-sync-shipment-setting-update-core.php
r3348657 r3472393 1 1 <?php 2 3 if ( ! defined( 'ABSPATH' ) ) exit; 2 4 3 5 class Class_bt_sync_shipment_setting_update_core -
shipment-tracker-for-woocommerce/trunk/includes/class-bt-sync-shipment-tracking-activator.php
r3348657 r3472393 1 1 <?php 2 3 if ( ! defined( 'ABSPATH' ) ) exit; 2 4 3 5 /** -
shipment-tracker-for-woocommerce/trunk/includes/class-bt-sync-shipment-tracking-admin-ajax-functions.php
r3348657 r3472393 1 1 <?php 2 3 if ( ! defined( 'ABSPATH' ) ) exit; 2 4 3 5 … … 17 19 $this->manual = $manual; 18 20 $this->fship = $fship; 21 } 22 23 public function save_package_dimensions(){ 24 $resp = array( 25 "status" => false, 26 "message" => '' 27 ); 28 29 if(empty($order_id = sanitize_text_field($_POST['order_id']))){ 30 $resp['message'] = 'Invalid order id.'; 31 wp_send_json($resp); 32 wp_die(); 33 } 34 35 try { 36 if (isset($_POST['package_length'])) { 37 Bt_Sync_Shipment_Tracking::bt_sst_update_order_meta($order_id, '_bt_package_length', sanitize_text_field($_POST['package_length'])); 38 } 39 if (isset($_POST['package_width'])) { 40 Bt_Sync_Shipment_Tracking::bt_sst_update_order_meta($order_id, '_bt_package_width', sanitize_text_field($_POST['package_width'])); 41 } 42 if (isset($_POST['package_height'])) { 43 Bt_Sync_Shipment_Tracking::bt_sst_update_order_meta($order_id, '_bt_package_height', sanitize_text_field($_POST['package_height'])); 44 } 45 if (isset($_POST['package_weight'])) { 46 Bt_Sync_Shipment_Tracking::bt_sst_update_order_meta($order_id, '_bt_package_weight', sanitize_text_field($_POST['package_weight'])); 47 } 48 $resp['status'] = true; 49 $resp['message'] = 'Package dimensions saved.'; 50 } 51 catch(Exception $e) { 52 $resp["message"] = $e->getMessage(); 53 $resp["status"] = false; 54 } 55 56 wp_send_json($resp); 57 wp_die(); 19 58 } 20 59 … … 115 154 116 155 try { 156 // Save optional package dimensions/weight if provided (stored in store units) 157 if (isset($_POST['package_length'])) { 158 Bt_Sync_Shipment_Tracking::bt_sst_update_order_meta($order_id, '_bt_package_length', sanitize_text_field($_POST['package_length'])); 159 } 160 if (isset($_POST['package_width'])) { 161 Bt_Sync_Shipment_Tracking::bt_sst_update_order_meta($order_id, '_bt_package_width', sanitize_text_field($_POST['package_width'])); 162 } 163 if (isset($_POST['package_height'])) { 164 Bt_Sync_Shipment_Tracking::bt_sst_update_order_meta($order_id, '_bt_package_height', sanitize_text_field($_POST['package_height'])); 165 } 166 if (isset($_POST['package_weight'])) { 167 Bt_Sync_Shipment_Tracking::bt_sst_update_order_meta($order_id, '_bt_package_weight', sanitize_text_field($_POST['package_weight'])); 168 } 169 117 170 Bt_Sync_Shipment_Tracking::bt_sst_delete_order_meta($order_id, '_bt_shipment_tracking' );//fix to delete old shipment data so that new awb number can take effect. 118 171 Bt_Sync_Shipment_Tracking::bt_sst_update_order_meta($order_id, '_bt_shipping_awb', sanitize_text_field($awb_number )); … … 173 226 174 227 public function bt_tracking_manual(){ 228 if ( ! current_user_can( 'manage_woocommerce' ) ) { 229 wp_send_json( array( 'status' => false, 'response' => 'Permission denied.' ) ); 230 wp_die(); 231 } 232 233 $order_id = isset($_POST['order_id']) ? sanitize_text_field($_POST['order_id']) : ''; 234 $fields = array( 235 'awb_number', 236 'courier_name', 237 'etd', 238 'shipping_status', 239 'current_pincode', 240 'current_address', 241 'current_country', 242 'tracking_link', 243 ); 244 $sanitized = array(); 245 foreach ($fields as $field) { 246 $sanitized[$field] = isset($_POST[$field]) ? sanitize_text_field($_POST[$field]) : ''; 247 } 248 175 249 $resp = array( 176 250 "status" => false, … … 179 253 180 254 try { 181 $resp["response"] = $this->manual->update_data( sanitize_text_field($_POST['order_id']), $_POST);255 $resp["response"] = $this->manual->update_data($order_id, $sanitized); 182 256 $resp["status"] = true; 183 257 } -
shipment-tracker-for-woocommerce/trunk/includes/class-bt-sync-shipment-tracking-crons.php
r3460036 r3472393 1 1 <?php 2 3 if ( ! defined( 'ABSPATH' ) ) exit; 2 4 3 5 class Bt_Sync_Shipment_Tracking_Crons { … … 19 21 private $courierkaro; 20 22 private $proship; 21 22 public function __construct($shiprocket,$shyplite,$nimbuspost_new,$shipmozo,$licenser,$delhivery, $fship, $courierkaro, $proship) { 23 private $ithink; 24 25 public function __construct($shiprocket,$shyplite,$nimbuspost_new,$shipmozo,$licenser,$delhivery, $fship, $courierkaro, $proship, $ithink) { 23 26 $this->shiprocket = $shiprocket; 24 27 $this->shipmozo = $shipmozo; … … 29 32 $this->fship = $fship; 30 33 $this->courierkaro = $courierkaro; 31 $this-> proship = $proship;34 $this->ithink = $ithink; 32 35 } 33 36 … … 68 71 $objs = $this->shiprocket->update_order_shipment_status($o); 69 72 //error_log("synced shiprocket: " . json_encode($objs)); 73 } 74 } 75 } 76 private function sync_ithink_shipments(){ 77 $orderids = $this->get_orders('ithink'); 78 foreach($orderids as $o){ 79 $bt_shipment_tracking = Bt_Sync_Shipment_Tracking_Shipment_Model::get_tracking_by_order_id($o); 80 if(empty($bt_shipment_tracking) || empty($bt_shipment_tracking->current_status) || stripos($bt_shipment_tracking->current_status, "delivered") === false){ 81 $objs = $this->ithink->update_order_shipment_status($o->get_id()); 70 82 } 71 83 } … … 240 252 } 241 253 } 254 if(is_array($enabled_shipping_providers) && in_array('ithink',$enabled_shipping_providers)){ 255 $settings = get_option('ithink_logistics_settings'); 256 $cron_schedule = isset($settings['cron_schedule']) ? $settings['cron_schedule'] : ''; 257 if( $cron_schedule==$cron_freq){ 258 $this->sync_ithink_shipments(); 259 } 260 } 242 261 if(is_array($enabled_shipping_providers) && in_array('delhivery',$enabled_shipping_providers)){ 243 262 $bt_sst_delhivery_cron_schedule=carbon_get_theme_option( 'bt_sst_delhivery_cron_schedule' ); -
shipment-tracker-for-woocommerce/trunk/includes/class-bt-sync-shipment-tracking-deactivator.php
r2469257 r3472393 1 1 <?php 2 3 if ( ! defined( 'ABSPATH' ) ) exit; 2 4 3 5 /** -
shipment-tracker-for-woocommerce/trunk/includes/class-bt-sync-shipment-tracking-i18n.php
r2469257 r3472393 1 1 <?php 2 3 if ( ! defined( 'ABSPATH' ) ) exit; 2 4 3 5 /** -
shipment-tracker-for-woocommerce/trunk/includes/class-bt-sync-shipment-tracking-loader.php
r3348657 r3472393 1 1 <?php 2 3 if ( ! defined( 'ABSPATH' ) ) exit; 2 4 3 5 /** -
shipment-tracker-for-woocommerce/trunk/includes/class-bt-sync-shipment-tracking-rest-functions.php
r3460036 r3472393 1 1 <?php 2 3 if ( ! defined( 'ABSPATH' ) ) exit; 2 4 3 5 -
shipment-tracker-for-woocommerce/trunk/includes/class-bt-sync-shipment-tracking-rest.php
r3460036 r3472393 1 1 <?php 2 3 if ( ! defined( 'ABSPATH' ) ) exit; 2 4 3 5 -
shipment-tracker-for-woocommerce/trunk/includes/class-bt-sync-shipment-tracking.php
r3460036 r3472393 1 1 <?php 2 3 if ( ! defined( 'ABSPATH' ) ) exit; 2 4 3 5 use Carbon_Fields\Container; … … 78 80 private $ekart; 79 81 private $proship; 82 private $courierkaro; 83 private $ithink; 80 84 81 85 /** … … 208 212 ]; 209 213 } 210 211 214 public static function bt_sst_get_package_dimensions($order_id) { 212 $dimension_unit = get_option('woocommerce_dimension_unit');213 $weight_unit = get_option('woocommerce_weight_unit');214 215 // Check order meta overrides (stored in store units)216 215 $meta_length = Bt_Sync_Shipment_Tracking::bt_sst_get_order_meta($order_id, '_bt_package_length'); 217 216 $meta_width = Bt_Sync_Shipment_Tracking::bt_sst_get_order_meta($order_id, '_bt_package_width'); … … 219 218 $meta_weight = Bt_Sync_Shipment_Tracking::bt_sst_get_order_meta($order_id, '_bt_package_weight'); 220 219 221 if (!empty($meta_length) || !empty($meta_width) || !empty($meta_height) || !empty($meta_weight)) { 222 $length_val = !empty($meta_length) ? (float) $meta_length : 0; 223 $width_val = !empty($meta_width) ? (float) $meta_width : 0; 224 $height_val = !empty($meta_height) ? (float) $meta_height : 0; 225 $weight_val = !empty($meta_weight) ? (float) $meta_weight : 0; 226 } else { 227 $computed = Bt_Sync_Shipment_Tracking::bt_sst_compute_package_dimensions($order_id); 228 $length_val = $computed['length']; 229 $width_val = $computed['width']; 230 $height_val = $computed['height']; 231 $weight_val = $computed['weight']; 220 if (empty($meta_length) && empty($meta_width) && empty($meta_height) && empty($meta_weight)) { 221 $computed = self::bt_sst_compute_package_dimensions($order_id); 222 $meta_length = $computed['length']; 223 $meta_width = $computed['width']; 224 $meta_height = $computed['height']; 225 $meta_weight = $computed['weight']; 232 226 } 233 227 234 // Convert to standard units: cm for dimensions, g for weight235 try {236 $length = new Length($length_val, $dimension_unit);237 $length_cm = (float) $length->toUnit('cm');238 } catch (Exception $e) {239 $length_cm = (float) $length_val;240 }241 try {242 $width = new Length($width_val, $dimension_unit);243 $width_cm = (float) $width->toUnit('cm');244 } catch (Exception $e) {245 $width_cm = (float) $width_val;246 }247 try {248 $height = new Length($height_val, $dimension_unit);249 $height_cm = (float) $height->toUnit('cm');250 } catch (Exception $e) {251 $height_cm = (float) $height_val;252 }253 try {254 $mass = new Mass($weight_val, $weight_unit);255 $weight_g = (float) $mass->toUnit('g');256 } catch (Exception $e) {257 $weight_g = (float) $weight_val;258 }259 260 if ($weight_g < 100) $weight_g = 100; // minimum 100g261 if ($length_cm <= 0) $length_cm = 0.5;262 if ($width_cm <= 0) $width_cm = 0.5;263 if ($height_cm <= 0) $height_cm = 0.5;264 265 228 return [ 266 'length _cm' => $length_cm,267 'width _cm' => $width_cm,268 'height _cm' => $height_cm,269 'weight _g' => $weight_g,229 'length' => (float) $meta_length, 230 'width' => (float) $meta_width, 231 'height' => (float) $meta_height, 232 'weight' => (float) $meta_weight, 270 233 ]; 271 234 } … … 343 306 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/shipping_providers/courier_karo.php'; 344 307 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/shipping_providers/proship.php'; 308 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/shipping_providers/ithink.php'; 345 309 346 310 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-bt-sync-shipment-tracking-rest.php'; … … 366 330 $this->courierkaro = new Bt_Sync_Shipment_Tracking_CourierKaro(); 367 331 $this->proship = new Bt_Sync_Shipment_Tracking_Proship(); 332 $this->ithink = new Bt_Sync_Shipment_Tracking_Ithink(); 368 333 ( new Bt_Sync_Shipment_Tracking_Review() )->hooks(); 369 334 } … … 377 342 private function define_cron_events() { 378 343 379 $this->crons = new Bt_Sync_Shipment_Tracking_Crons($this->shiprocket,$this->shyplite,$this->nimbuspost_new,$this->shipmozo, $this->licenser, $this->delhivery, $this->fship, $this->courierkaro, $this->proship );344 $this->crons = new Bt_Sync_Shipment_Tracking_Crons($this->shiprocket,$this->shyplite,$this->nimbuspost_new,$this->shipmozo, $this->licenser, $this->delhivery, $this->fship, $this->courierkaro, $this->proship, $this->ithink); 380 345 381 346 $this->loader->add_action( Bt_Sync_Shipment_Tracking_Crons::BT_MINUTELY_JOB, $this->crons, 'minutely_job'); … … 463 428 private function define_admin_hooks() { 464 429 465 $plugin_admin = new Bt_Sync_Shipment_Tracking_Admin( $this->get_plugin_name(), $this->get_version(),$this->shiprocket,$this->shyplite, $this->nimbuspost, $this->manual, $this->licenser, $this->shipmozo, $this->nimbuspost_new, $this->delhivery, $this->ship24, $this->fship, $this->ekart, $this->courierkaro, $this->proship );430 $plugin_admin = new Bt_Sync_Shipment_Tracking_Admin( $this->get_plugin_name(), $this->get_version(),$this->shiprocket,$this->shyplite, $this->nimbuspost, $this->manual, $this->licenser, $this->shipmozo, $this->nimbuspost_new, $this->delhivery, $this->ship24, $this->fship, $this->ekart, $this->courierkaro, $this->proship, $this->ithink); 466 431 $this->loader->add_action( 'dokan_order_detail_after_order_general_details',$plugin_admin, 'custom_dokan_order_details', 10, 1 ); 467 432 $this->loader->add_action('carbon_fields_save_post',$plugin_admin, 'update_woocommerce_data_on_carbon_fields_save', 10, 3); … … 503 468 $this->loader->add_action( 'bt_push_order_to_courierkaro', $plugin_admin, 'push_order_to_courierkaro',10,3); 504 469 $this->loader->add_action( 'bt_push_order_to_proship', $plugin_admin, 'push_order_to_proship',10,3); 470 $this->loader->add_action( 'bt_push_order_to_ithink', $plugin_admin, 'push_order_to_ithink',10,3); 505 471 $this->loader->add_action( 'bt_push_order_to_nimbuspost', $plugin_admin, 'push_order_to_nimbuspost',10,3); 506 472 … … 531 497 $this->loader->add_action( 'wp_ajax_api_call_for_ekart_test_connection', $plugin_admin, 'api_call_for_ekart_test_connection' ); 532 498 $this->loader->add_action( 'wp_ajax_api_call_for_ship24_test_connection', $plugin_admin, 'api_call_for_ship24_test_connection' ); 499 $this->loader->add_action( 'wp_ajax_api_call_for_ithink_test_connection', $plugin_admin, 'api_call_for_ithink_test_connection' ); 533 500 $this->loader->add_action( 'wp_ajax_get_sms_trial', $plugin_admin, 'get_sms_trial' ); 534 501 $this->loader->add_action( 'wp_ajax_get_bt_sst_email_trial', $plugin_admin, 'get_bt_sst_email_trial' ); … … 1822 1789 ->set_html( 1823 1790 sprintf( ' 1824 <b>Shipmozo Webhook URL: [<a target="_blank" href="https:// app.shipmozo.com/user/shipping-notification">Configure Webhook Here</a>] </b>1791 <b>Shipmozo Webhook URL: [<a target="_blank" href="https://panel.shipmozo.com/settings/shipping-notification">Configure Webhook Here</a>] </b> 1825 1792 <p>'.get_site_url(null, '/wp-json/bt-sync-shipment-tracking-shipmozo/v1.0.0/webhook_receiver').'<a href="#" class="bt_sst_copy_link" > Copy Link</a> </p> 1826 1793 <p>Last Webhook Called On: '.$shipmozo_webhook_time.'</p> … … 2358 2325 'ekart' => 'Ekart', 2359 2326 'proship' => 'Proship', 2327 'ithink' => 'iThink logistic', 2360 2328 ) ) 2361 2329 ->set_help_text(' … … 2612 2580 'ekart' => 'Ekart', 2613 2581 'proship' => 'Proship', 2582 'ithink' => 'iThink Logistic', 2614 2583 2615 2584 … … 2792 2761 'field' => 'bt_sst_courier_rate_provider', 2793 2762 'compare' => 'IN', 2794 'value' => array('shiprocket','shipmozo','delhivery','proship' ),2763 'value' => array('shiprocket','shipmozo','delhivery','proship','ithink'), 2795 2764 ) 2796 2765 ) ), … … 2979 2948 private function define_public_hooks() { 2980 2949 2981 $plugin_public = new Bt_Sync_Shipment_Tracking_Public( $this->get_plugin_name(), $this->get_version() ,$this->shiprocket, $this->shipmozo, $this->nimbuspost_new, $this->licenser, $this->delhivery, $this->fship, $this->ekart, $this->proship );2950 $plugin_public = new Bt_Sync_Shipment_Tracking_Public( $this->get_plugin_name(), $this->get_version() ,$this->shiprocket, $this->shipmozo, $this->nimbuspost_new, $this->licenser, $this->delhivery, $this->fship, $this->ekart, $this->proship, $this->ithink); 2982 2951 2983 2952 // $pincode_checker_location_hook = carbon_get_theme_option( 'bt_sst_pincode_checker_location' ); -
shipment-tracker-for-woocommerce/trunk/includes/models/class-bt-sync-shipment-tracking-shipment-model.php
r3460036 r3472393 1 1 <?php 2 3 if ( ! defined( 'ABSPATH' ) ) exit; 2 4 3 5 class Bt_Sync_Shipment_Tracking_Shipment_Model{ -
shipment-tracker-for-woocommerce/trunk/includes/shipping_providers/delhivery.php
r3446887 r3472393 2 2 use PhpUnitsOfMeasure\PhysicalQuantity\Mass; 3 3 use PhpUnitsOfMeasure\PhysicalQuantity\Length; 4 if ( ! defined( 'ABSPATH' ) ) exit; 4 5 class Bt_Sync_Shipment_Tracking_Delhivery { 5 6 -
shipment-tracker-for-woocommerce/trunk/includes/shipping_providers/ekart.php
r3460036 r3472393 217 217 $product = $a->get_product(); 218 218 219 if(!empty($product->get_weight()) && $product->get_weight()>0){220 $total_weight = $total_weight + ($product->get_weight() * $a->get_quantity());221 }222 223 if(!empty($product->get_width()) && $product->get_width()>0){224 $total_width = $total_width + ($product->get_width() * $a->get_quantity());225 if($product->get_height()>$total_height){226 $total_height =$product->get_height();227 }228 if($product->get_length()>$total_length){229 $total_length =$product->get_length();230 }231 }219 // if(!empty($product->get_weight()) && $product->get_weight()>0){ 220 // $total_weight = $total_weight + ($product->get_weight() * $a->get_quantity()); 221 // } 222 223 // if(!empty($product->get_width()) && $product->get_width()>0){ 224 // $total_width = $total_width + ($product->get_width() * $a->get_quantity()); 225 // if($product->get_height()>$total_height){ 226 // $total_height =$product->get_height(); 227 // } 228 // if($product->get_length()>$total_length){ 229 // $total_length =$product->get_length(); 230 // } 231 // } 232 232 if(empty($product_description )){ 233 233 $product_description = $product->get_name(); … … 236 236 } 237 237 } 238 239 $computed = Bt_Sync_Shipment_Tracking::bt_sst_get_package_dimensions($order_id); 240 $meta_length = $computed['length']; 241 $meta_width = $computed['width']; 242 $meta_height = $computed['height']; 243 $meta_weight = $computed['weight']; 238 244 239 245 $weight_unit = get_option('woocommerce_weight_unit'); -
shipment-tracker-for-woocommerce/trunk/includes/shipping_providers/fship.php
r3368473 r3472393 2 2 use PhpUnitsOfMeasure\PhysicalQuantity\Mass; 3 3 use PhpUnitsOfMeasure\PhysicalQuantity\Length; 4 if ( ! defined( 'ABSPATH' ) ) exit; 4 5 class Bt_Sync_Shipment_Tracking_Fship 5 6 { -
shipment-tracker-for-woocommerce/trunk/includes/shipping_providers/manual.php
r3348657 r3472393 1 1 <?php 2 3 if ( ! defined( 'ABSPATH' ) ) exit; 2 4 3 5 /** -
shipment-tracker-for-woocommerce/trunk/includes/shipping_providers/nimbuspost.php
r3348657 r3472393 1 1 <?php 2 3 if ( ! defined( 'ABSPATH' ) ) exit; 2 4 3 5 /** -
shipment-tracker-for-woocommerce/trunk/includes/shipping_providers/nimbuspost_new.php
r3284690 r3472393 2 2 use PhpUnitsOfMeasure\PhysicalQuantity\Mass; 3 3 use PhpUnitsOfMeasure\PhysicalQuantity\Length; 4 if ( ! defined( 'ABSPATH' ) ) exit; 4 5 5 6 /** -
shipment-tracker-for-woocommerce/trunk/includes/shipping_providers/proship.php
r3460036 r3472393 1 1 <?php 2 if ( ! defined( 'ABSPATH' ) ) exit; 2 3 use PhpUnitsOfMeasure\PhysicalQuantity\Mass; 3 4 use PhpUnitsOfMeasure\PhysicalQuantity\Length; -
shipment-tracker-for-woocommerce/trunk/includes/shipping_providers/ship24.php
r3348657 r3472393 1 1 <?php 2 if ( ! defined( 'ABSPATH' ) ) exit; 2 3 class Bt_Sync_Shipment_Tracking_Ship24 { 3 4 -
shipment-tracker-for-woocommerce/trunk/includes/shipping_providers/shipmozo.php
r3348657 r3472393 2 2 use PhpUnitsOfMeasure\PhysicalQuantity\Mass; 3 3 use PhpUnitsOfMeasure\PhysicalQuantity\Length; 4 if ( ! defined( 'ABSPATH' ) ) exit; 4 5 class Bt_Sync_Shipment_Tracking_Shipmozo { 5 6 … … 50 51 51 52 public function shipmozo_webhook_receiver($request){ 52 53 /*54 Sample Webhook data:55 array(11) {56 ["order_id"]=>57 string(10) "4681GY4954"58 ["refrence_id"]=>59 string(4) "4954"60 ["awb_number"]=>61 string(14) "SPOP1000018714"62 ["carrier"]=>63 string(11) "Ekart 0.5KG"64 ["delhivery_name"]=>65 string(11) "Nidhi Watts"66 ["delhivery_phone"]=>67 string(10) "8432157417"68 ["expected_delivery_date"]=>69 NULL70 ["shipment_type"]=>71 string(7) "Forward"72 ["current_status"]=>73 string(16) "Pickup Completed"74 ["status_time"]=>75 string(19) "2024-03-28 09:30:32"76 ["status_feed"]=>77 array(1) {78 ["scan"]=>79 array(7) {80 [0]=>81 array(3) {82 ["date"]=>83 string(19) "2024-03-28 09:30:32"84 ["status"]=>85 string(24) "shipment pickup complete"86 ["location"]=>87 string(6) "Dwarka"88 }89 [1]=>90 array(3) {91 ["date"]=>92 string(19) "2024-03-28 06:21:52"93 ["status"]=>94 string(23) "shipment out for pickup"95 ["location"]=>96 string(6) "Dwarka"97 }98 [2]=>99 array(3) {100 ["date"]=>101 string(19) "2024-03-27 14:38:56"102 ["status"]=>103 string(7) "NON EKL"104 ["location"]=>105 string(6) "Dwarka"106 }107 [3]=>108 array(3) {109 ["date"]=>110 string(19) "2024-03-27 06:52:27"111 ["status"]=>112 string(21) "Dispatched to JAI/BTS"113 ["location"]=>114 string(6) "Jaipur"115 }116 [4]=>117 array(3) {118 ["date"]=>119 string(19) "2024-03-27 06:44:56"120 ["status"]=>121 string(23) "shipment out for pickup"122 ["location"]=>123 string(6) "Dwarka"124 }125 [5]=>126 array(3) {127 ["date"]=>128 string(19) "2024-03-27 06:39:00"129 ["status"]=>130 string(34) "Dispached by SPO : Priyanka Mittal"131 ["location"]=>132 string(6) "Dwarka"133 }134 [6]=>135 array(3) {136 ["date"]=>137 string(19) "2024-03-27 06:39:00"138 ["status"]=>139 string(25) "Expected at EKL Bamnoli1 "140 ["location"]=>141 string(6) "Dwarka"142 }143 }144 }145 }146 147 */148 149 53 update_option( "shipmozo_webhook_called", time() ); 150 54 $enabled_shipping_providers = carbon_get_theme_option( 'bt_sst_enabled_shipping_providers' ); … … 176 80 Bt_Sync_Shipment_Tracking::bt_sst_update_order_meta($order_id, '_bt_shipmozo_order_id', $shipmozo_order_id); 177 81 } 178 179 // $bt_sst_order_statuses_to_sync = carbon_get_theme_option( 'bt_sst_order_statuses_to_sync' );180 82 $bt_sst_sync_orders_date = carbon_get_theme_option( 'bt_sst_sync_orders_date' ); 181 182 83 $order_status = 'wc-' . $order->get_status(); 183 184 // if(in_array($order_status,$bt_sst_order_statuses_to_sync) || in_array('any',$bt_sst_order_statuses_to_sync)){185 186 84 $date_created_dt = $order->get_date_created(); // Get order date created WC_DateTime Object 187 85 $timezone = $date_created_dt->getTimezone(); // Get the timezone 188 86 $date_created_ts = $date_created_dt->getTimestamp(); // Get the timestamp in seconds 189 190 87 $now_dt = new WC_DateTime(); // Get current WC_DateTime object instance 191 88 $now_dt->setTimezone( $timezone ); // Set the same time zone 192 89 $now_ts = $now_dt->getTimestamp(); // Get the current timestamp in seconds 193 194 90 $allowed_seconds = $bt_sst_sync_orders_date * 24 * 60 * 60; // bt_sst_sync_orders_date in seconds 195 196 91 $diff_in_seconds = $now_ts - $date_created_ts; // Get the difference (in seconds) 197 198 92 if ( $diff_in_seconds <= $allowed_seconds ) { 199 93 $shipment_obj = $this->init_model($request, $order_id); … … 203 97 return "Thanks Shipmozo! Order too old."; 204 98 } 205 // }else{206 // return "Thanks Shipmozo! Order status out of scope.";207 // }208 99 } 209 100 } 210 101 } 211 102 } 212 213 // ob_start();214 // var_dump($request);215 // $result = ob_get_clean();216 217 // error_log($result);218 219 103 return "Thanks Shipmozo, but nothing got updated."; 220 104 } … … 561 445 } else { 562 446 $order = wc_get_order( $order_id ); 563 $order->add_order_note('AWB missing in Shipmozo order');564 447 } 565 448 } else { -
shipment-tracker-for-woocommerce/trunk/includes/shipping_providers/shiprocket.php
r3338305 r3472393 1 1 <?php 2 if ( ! defined( 'ABSPATH' ) ) exit; 2 3 use PhpUnitsOfMeasure\PhysicalQuantity\Mass; 3 4 use PhpUnitsOfMeasure\PhysicalQuantity\Length; -
shipment-tracker-for-woocommerce/trunk/includes/shipping_providers/shyplite.php
r3348657 r3472393 1 1 <?php 2 3 if ( ! defined( 'ABSPATH' ) ) exit; 2 4 3 5 /** -
shipment-tracker-for-woocommerce/trunk/includes/shipping_providers/xpressbees.php
r3348657 r3472393 1 1 <?php 2 3 if ( ! defined( 'ABSPATH' ) ) exit; 2 4 3 5 /** -
shipment-tracker-for-woocommerce/trunk/public/class-bt-sync-shipment-tracking-public.php
r3460036 r3472393 59 59 * @param string $version The version of this plugin. 60 60 */ 61 public function __construct($plugin_name, $version, $shiprocket, $shipmozo, $nimbuspost_new, $licenser, $delhivery, $fship, $ekart, $proship )61 public function __construct($plugin_name, $version, $shiprocket, $shipmozo, $nimbuspost_new, $licenser, $delhivery, $fship, $ekart, $proship, $ithink) 62 62 { 63 63 … … 72 72 $this->ekart = $ekart; 73 73 $this->proship = $proship; 74 $this->ithink = $ithink; 74 75 } 75 76 … … 1322 1323 // $city = $city_data['city']; 1323 1324 // } 1325 }else if ($pickup_data_provider == 'ithink') { 1326 $express_tat = null; 1327 if (false === ($bt_sst_cached_delivery_estimates_ithink = get_transient('bt_sst_cached_delivery_estimates_ithink'))) { 1328 $bt_sst_cached_delivery_estimates_ithink = array(); 1329 } 1330 1331 if ($delivery_country == "IN") { 1332 $settings = get_option('ithink_logistics_settings'); 1333 $pickup_pincode = isset($settings['pickup_pincode']) ? $settings['pickup_pincode'] : ''; 1334 1335 $length = 10; 1336 $breadth = 10; 1337 $height = 10; 1338 $weight = '1'; 1339 $cod_amount = 100; 1340 if ($pickup_pincode) { 1341 $cached_pincode_key = $pickup_pincode . "_" . $delivery_pincode . "_3"; 1342 if (isset($bt_sst_cached_delivery_estimates_ithink[$cached_pincode_key])) { 1343 $push_resp = $bt_sst_cached_delivery_estimates_ithink[$cached_pincode_key][0]; 1344 $express_tat = $bt_sst_cached_delivery_estimates_ithink[$cached_pincode_key][1]; 1345 $response["message"] = "Data fetched from cache."; 1346 } else { 1347 $push_resp = $this->ithink->check_shipping_rate( 1348 $pickup_pincode, 1349 $delivery_pincode, 1350 $length, 1351 $breadth, 1352 $height, 1353 $weight, 1354 $cod_amount, 1355 "forward", 1356 "COD" 1357 ); 1358 if (!isset($push_resp["error"]) && $push_resp != null && !empty($push_resp) && sizeof($push_resp) > 0) { 1359 $bt_sst_cached_delivery_estimates_ithink[$cached_pincode_key] = [$push_resp, $express_tat]; 1360 set_transient('bt_sst_cached_delivery_estimates_ithink', $bt_sst_cached_delivery_estimates_ithink, 1 * HOUR_IN_SECONDS); 1361 $response["message"] = "Data fetched from Delhivery."; 1362 } else { 1363 $push_resp = []; 1364 } 1365 } 1366 } 1367 1368 } 1369 1370 $filtered_arr = $push_resp['data']; 1371 $minMinTat = min(array_column($filtered_arr, 'delivery_tat')); 1372 $fastest = array_filter($filtered_arr, function ($item) use ($minMinTat) { 1373 return $item['delivery_tat'] == $minMinTat; 1374 }); 1375 $minMaxTat = min(array_column($fastest, 'delivery_tat')); 1376 $fastest = array_filter($fastest, function ($item) use ($minMaxTat) { 1377 return $item['delivery_tat'] == $minMaxTat; 1378 }); 1379 1380 usort($fastest, function ($a, $b) { 1381 return $a['rate'] <=> $b['rate']; 1382 }); 1383 1384 $filtered_arr = $fastest[0]; 1385 1386 if (is_array($filtered_arr) && sizeof($filtered_arr) > 0) { 1387 $check_error_for_hide_show_ponbox["data"] = true; 1388 $max_date_charges = $filtered_arr['rate']; 1389 $min_date_charges = $filtered_arr['rate']; 1390 1391 $max_courier_name = 'ithink'; 1392 $min_courier_name = 'ithink'; 1393 1394 $min_days = 2; 1395 $max_days = 5; 1396 $express_tat = $filtered_arr['delivery_tat']; 1397 if ($express_tat != null) { 1398 $min_days = $express_tat; 1399 $max_days = $express_tat; 1400 } 1401 1402 if (!$min_days) { 1403 $min_days = 1; 1404 } 1405 if (!$max_days) { 1406 $max_days = 1; 1407 } 1408 $current_date = new DateTime(); 1409 $min_date = $current_date->add(new DateInterval("P{$min_days}D"))->format("l, d M, Y"); 1410 $max_date = $current_date->add(new DateInterval("P{$max_days}D"))->format("l, d M, Y"); 1411 1412 $processing_days = $this->bt_get_processing_days($product_id, $variation_id); 1413 if (!$processing_days) { 1414 $processing_days = carbon_get_theme_option("bt_sst_shiprocket_processing_days"); 1415 } 1416 1417 if (!$is_premium) { 1418 $processing_days = 0; //if not premium, then no processing days. 1419 } 1420 if ($processing_days && $processing_days > 0) { 1421 $min_date = $this->addDayswithdate($min_date, $processing_days); 1422 $max_date = $this->addDayswithdate($max_date, $processing_days); 1423 } else { 1424 $min_date = $this->addDayswithdate($min_date, 0); 1425 $max_date = $this->addDayswithdate($max_date, 0); 1426 } 1427 $check_error_for_hide_show_ponbox["data"] = true; 1428 } else { 1429 $bt_sst_message_text_template = "Delivery not available. Try a different pincode or contact support."; 1430 } 1431 $city = $delivery_pincode; 1432 // $city_data = $this->delhivery->get_locality($delivery_pincode); 1433 // if (isset($city_data['city'])) { 1434 // $city = $city_data['city']; 1435 // } 1324 1436 } 1325 1437 … … 1470 1582 } 1471 1583 1472 function bt_get_processing_days($product_id = false, $variation_id = false) 1473 { 1474 // This function will populate the days it will take to process an order. 1475 // Processing days for a particular product is stored in '_bt_sst_product_processing_days_field' meta data. 1476 // At product category level, it is stored in '_bt_sst_product_category_processing_days_field' meta data of product category. 1477 // Processing days is equal to the '_bt_sst_product_processing_days_field' value at product level whicle at cart level, processing days is equal to the max value of '_bt_sst_product_processing_days_field' meta value across all products in the cart. 1478 //1. check if current page is cart page or product page. 1479 //2. if product page, get value of '_bt_sst_product_processing_days_field' meta data and return as 1480 //3. if cart page, loop through all products and 1481 1482 global $product, $woocommerce; 1584 // function bt_get_processing_days($product_id = false, $variation_id = false) 1585 // { 1586 // // This function will populate the days it will take to process an order. 1587 // // Processing days for a particular product is stored in '_bt_sst_product_processing_days_field' meta data. 1588 // // At product category level, it is stored in '_bt_sst_product_category_processing_days_field' meta data of product category. 1589 // // Processing days is equal to the '_bt_sst_product_processing_days_field' value at product level whicle at cart level, processing days is equal to the max value of '_bt_sst_product_processing_days_field' meta value across all products in the cart. 1590 // //1. check if current page is cart page or product page. 1591 // //2. if product page, get value of '_bt_sst_product_processing_days_field' meta data and return as 1592 // //3. if cart page, loop through all products and 1593 1594 // global $product, $woocommerce; 1595 // $processing_days = 0; 1596 // // Check for product page or cart page 1597 // if ($variation_id) { 1598 // $processing_days = $this->get_processing_days_for_product($variation_id); 1599 1600 // } 1601 // if ($product_id && $processing_days == 0) { 1602 // $processing_days = $this->get_processing_days_for_product($product_id); 1603 // } 1604 // if (is_cart() || is_checkout()) { 1605 // foreach ($woocommerce->cart->get_cart() as $cart_item_key => $cart_item) { 1606 // $product = $cart_item['data']; 1607 // $product_id = $product->get_id(); 1608 // $product_processing_days = $this->get_processing_days_for_product($product_id); 1609 // $processing_days = max($processing_days, $product_processing_days); 1610 // } 1611 // } 1612 1613 // return $processing_days; 1614 // } 1615 1616 1617 public function bt_get_processing_days($product_id = false, $variation_id = false) 1618 { 1619 global $woocommerce; 1483 1620 $processing_days = 0; 1484 // Check for product page or cart page1485 1621 if ($variation_id) { 1486 $processing_days = $this->get_processing_days_for_product($variation_id); 1487 1488 } 1622 $raw_value = $this->get_processing_days_for_product($variation_id); 1623 $processing_days = $this->normalize_processing_days($raw_value); 1624 } 1625 1489 1626 if ($product_id && $processing_days == 0) { 1490 $processing_days = $this->get_processing_days_for_product($product_id); 1491 } 1627 $raw_value = $this->get_processing_days_for_product($product_id); 1628 $processing_days = $this->normalize_processing_days($raw_value); 1629 } 1630 1492 1631 if (is_cart() || is_checkout()) { 1493 foreach ($woocommerce->cart->get_cart() as $cart_item _key => $cart_item) {1632 foreach ($woocommerce->cart->get_cart() as $cart_item) { 1494 1633 $product = $cart_item['data']; 1495 $product_id = $product->get_id(); 1496 $product_processing_days = $this->get_processing_days_for_product($product_id); 1634 $cart_product_id = $product->get_id(); 1635 $raw_value = $this->get_processing_days_for_product($cart_product_id); 1636 $product_processing_days = $this->normalize_processing_days($raw_value); 1637 1497 1638 $processing_days = max($processing_days, $product_processing_days); 1498 1639 } 1499 1640 } 1500 1501 return $processing_days; 1641 return (int) $processing_days; 1642 } 1643 1644 private function normalize_processing_days($value) 1645 { 1646 if (empty($value)) { 1647 return 0; 1648 } 1649 $value = strtolower(trim($value)); 1650 preg_match('/\d+/', $value, $matches); 1651 $number = isset($matches[0]) ? (int) $matches[0] : 0; 1652 1653 if ($number <= 0) { 1654 return 0; 1655 } 1656 if (strpos($value, 'hour') !== false || strpos($value, 'hr') !== false) { 1657 return (int) ceil($number / 24); 1658 } 1659 return (int) $number; 1502 1660 } 1503 1661 … … 3038 3196 } 3039 3197 } 3198 3199 }else if ($bt_sst_courier_rate_provider == 'ithink') { 3200 3201 $cart_totals = $this->get_cart_weight_and_dimentions(); 3202 3203 $weight_in_kg = $cart_totals['total_weight_kg']; 3204 $length_in_cms = $cart_totals['total_length_cm']; 3205 $breadth_in_cms = $cart_totals['total_width_cm']; 3206 $height_in_cms = $cart_totals['total_height_cm']; 3207 $declared_value = $cart_totals['declared_value']; 3208 3209 if ($weight_in_kg < 0.1) { 3210 $weight_in_kg = 0.1; 3211 } 3212 if ($length_in_cms < 1) { 3213 $length_in_cms = 10; 3214 } 3215 if ($breadth_in_cms < 1) { 3216 $breadth_in_cms = 10; 3217 } 3218 if ($height_in_cms < 1) { 3219 $height_in_cms = 10; 3220 } 3221 3222 if ($weight_in_kg > 0) { 3223 3224 $settings = get_option('ithink_logistics_settings'); 3225 if (false === ($bt_sst_cached_delivery_estimates_ithink = get_transient('bt_sst_cached_delivery_estimates_ithink'))) { 3226 $bt_sst_cached_delivery_estimates_ithink = array(); 3227 } 3228 if ($delivery_country == "IN") { 3229 $pickup_pincode = isset($settings['pickup_pincode']) ? $settings['pickup_pincode'] : ''; 3230 3231 if (!empty($pickup_pincode)) { 3232 $pm = $cod == 1 ? "COD" : "PREPAID"; 3233 $cached_pincode_key = $pickup_pincode . "_" . $delivery_pincode . "_" . $weight_in_kg . '_' . $pm; 3234 if (isset($bt_sst_cached_delivery_estimates_ithink[$cached_pincode_key])) { 3235 $push_resp = $bt_sst_cached_delivery_estimates_ithink[$cached_pincode_key]; 3236 } else { 3237 $cod_amount = $cod == 1 ? $declared_value : 0; 3238 $push_resp = $this->ithink->check_shipping_rate( 3239 $pickup_pincode, 3240 $delivery_pincode, 3241 $length_in_cms, 3242 $breadth_in_cms, 3243 $height_in_cms, 3244 $weight_in_kg, 3245 $declared_value, 3246 "forward", 3247 "COD",); 3248 if ($push_resp != null && !empty($push_resp)) { 3249 $bt_sst_cached_delivery_estimates_ithink[$cached_pincode_key] = $push_resp; 3250 set_transient('bt_sst_cached_delivery_estimates_ithink', $bt_sst_cached_delivery_estimates_ithink, 1 * HOUR_IN_SECONDS); 3251 } else { 3252 $push_resp = []; 3253 } 3254 } 3255 $filtered_arr = $push_resp["data"]; 3256 } 3257 3258 3259 } 3260 } 3261 3262 $free_shipping_rates = []; 3263 foreach ($rates as $key => $r) { 3264 if (strpos($key, 'free_shipping') !== false) { 3265 $free_shipping_rates[$key] = $r; 3266 } 3267 } 3268 $rates = $free_shipping_rates; 3269 3270 if ($delivery_country == "IN") { 3271 usort($filtered_arr, function ($a, $b) { 3272 return ($a['rate'] - ($b['rate'])); 3273 }); 3274 $i = 0; 3275 foreach ($filtered_arr as $rb) { 3276 $lable = ucfirst($rb['logistic_name']); 3277 $bt_sst_shipping_duration_days = null; 3278 $bt_sst_shipping_edd = null; 3279 if (isset($rb['delivery_tat']) && $rb['delivery_tat'] != null) { 3280 $bt_sst_shipping_duration_days = $rb['delivery_tat']; 3281 $bt_sst_shipping_edd = new DateTime("+" . $bt_sst_shipping_duration_days . " days"); 3282 } 3283 $id = 'flat_rate:ithink:' . $rb['logistic_name']; 3284 $method_id = 'flat_rate'; 3285 $markup_cost = carbon_get_theme_option( 3286 "bt_sst_markup_charges" 3287 ); 3288 if (!$markup_cost) { 3289 $markup_cost = 0; 3290 } 3291 if (($rb['rate'] + $markup_cost) < 0) { 3292 $markup_cost = 0; 3293 } 3294 3295 $delivery_charge = 0; 3296 if ($cod == 1) { 3297 $two_percent = $rb['rate'] * (2 / 100); 3298 if ($two_percent > 40) { 3299 $delivery_charge = $two_percent; 3300 } else { 3301 $delivery_charge = 40; 3302 } 3303 } 3304 $cost = round($rb['rate'] + $markup_cost + $delivery_charge, 2); 3305 3306 3307 $texes = []; 3308 $delivery_date = ''; 3309 $processing_days = $this->bt_get_processing_days(); 3310 if (!$processing_days) { 3311 $processing_days = carbon_get_theme_option("bt_sst_shipment_processing_days"); 3312 } 3313 if (!$processing_days || $processing_days < 0) { 3314 $processing_days = 0; 3315 } 3316 $delivery_date = $this->addDayswithdate($bt_sst_shipping_edd->format('Y-m-d H:i:s'), $processing_days); 3317 3318 $show_delivery_date = carbon_get_theme_option("bt_sst_show_ithink_date"); 3319 if ($show_delivery_date == 1) { 3320 $lable .= " (Edd: " . $delivery_date . ")"; 3321 } 3322 3323 $WC_Shipping_Rate = new WC_Shipping_Rate(); 3324 3325 $WC_Shipping_Rate->add_meta_data("edd", $delivery_date); 3326 $WC_Shipping_Rate->set_id($id); 3327 $WC_Shipping_Rate->set_label($lable); 3328 $WC_Shipping_Rate->set_method_id($method_id); 3329 $WC_Shipping_Rate->set_cost($cost); 3330 $WC_Shipping_Rate->set_instance_id($id); 3331 $WC_Shipping_Rate->set_taxes($texes); 3332 $WC_Shipping_Rate->add_meta_data('bt_sst_courier_company_name', $lable); 3333 $WC_Shipping_Rate->add_meta_data('bt_sst_shipment_provider', 'delhivery'); 3334 $WC_Shipping_Rate->add_meta_data('bt_sst_shipping_duration_days', $bt_sst_shipping_duration_days); 3335 $WC_Shipping_Rate->add_meta_data('bt_sst_processing_days', $processing_days); 3336 $rates[$id] = $WC_Shipping_Rate; 3337 } 3338 } 3339 3040 3340 3041 3341 } -
shipment-tracker-for-woocommerce/trunk/public/partials/bt-sync-shipment-tracking-public-display.php
r3348657 r3472393 1 1 <?php 2 3 if ( ! defined( 'ABSPATH' ) ) exit; 2 4 3 5 /**
Note: See TracChangeset
for help on using the changeset viewer.