Plugin Directory

Changeset 3472393


Ignore:
Timestamp:
03/02/2026 07:11:36 AM (4 weeks ago)
Author:
bitsstech
Message:

updated trunk

Location:
shipment-tracker-for-woocommerce
Files:
4 added
1 deleted
33 edited

Legend:

Unmodified
Added
Removed
  • shipment-tracker-for-woocommerce/trunk/admin/class-bt-sync-shipment-tracking-admin.php

    r3460036 r3472393  
    5656    private $courierkaro;
    5757    private $proship;
     58    private $ithink;
    5859
    5960    /**
     
    6465     * @param      string    $version    The version of this plugin.
    6566     */
    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)
    6768    {
    6869
     
    8283        $this->courierkaro = $courierkaro;
    8384        $this->proship = $proship;
     85        $this->ithink = $ithink;
    8486    }
    8587
     
    158160            $current_screen->id == "shipment-tracking_page_bt-shipment-tracking-timer" ||
    159161            $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"
    161164            )) {
    162165            $script_data = array(
     
    174177                "test_conn_ekart_nonce" => wp_create_nonce('api_call_for_ekart_test_connection'),
    175178                "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'),
    176180                "test_conn_nimbuspost_nonce" => wp_create_nonce('api_check_for_nimbuspost_test_connection'),
    177181                "test_conn_proship_nonce" => wp_create_nonce('api_call_for_proship_test_connection'),
     
    332336                    $order->add_order_note('Added schedule to push this order to delhivery.' . "\n\n- Shipment tracker for woocommerce", false);
    333337                    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));
    334348
    335349                }
     
    638652
    639653            } 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                );
    641669                $order->add_order_note("Response from Delhivery Push api: " . json_encode($push_resp) . "\n\n- Shipment tracker for woocommerce", false);
    642670            }
     
    804832        }
    805833    }
     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    }
    806908
    807909    public function push_order_to_nimbuspost($order_id)
     
    11211223        if (!$bt_shipping_provider || ($bt_shipping_provider == 'manual' && $shipping_mode_is_manual_or_ship24 == "manual")) {
    11221224            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") {
    11241226            $order_id = isset($_GET['post']) ? $_GET['post'] : sanitize_text_field($_GET['id']);
    11251227            include plugin_dir_path(dirname(__FILE__)) . 'admin/partials/bt-shipment-tracking-metabox.php';
     
    13651467        }
    13661468        // $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        }
    13671490        wp_send_json($response);
    13681491        die();
     
    24512574        } else if (isset($_GET['bt_push_to_shipmozo']) && $_GET['bt_push_to_shipmozo'] == 1 && (isset($_GET['post']) || isset($_GET['id']))) {
    24522575            $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            }
    24532583            $this->push_order_to_shipmozo($order_id);
    24542584            unset($_GET['bt_push_to_shipmozo']);
     
    24982628            $current_page = admin_url(sprintf($pagenow . '?%s', http_build_query($_GET)));
    24992629            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);
    25002637        } else if (is_admin() && isset($_GET['page']) && $_GET['page'] === 'crb_carbon_fields_container_shipment_tracker.php') {
    25012638            wp_safe_redirect(admin_url('admin.php?page=bt-shipment-tracking'));
     
    33723509                $resp = false;
    33733510            }
     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            }
    33743516        }
    33753517        // else if($shipping_provider == 'nimbuspost'){
     
    36213763        add_submenu_page(
    36223764            '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',
    36233773            'Premium Activation - Shipment Tracker for Woocommerce',           // Page title
    36243774            'Activate Premium',       // Menu title
     
    36273777            [$this, 'bt_shipment_tracking_premium_callback'], // Correct way to call class method
    36283778        );
     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        // );
    36293788
    36303789        add_submenu_page(
     
    36653824        include plugin_dir_path(dirname(__FILE__)) . 'admin/partials/new_settings/bt-shipment-new-settings.php';
    36663825        // 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';
    36673842    }
    36683843
     
    39064081        $obj = new Bt_Sync_Shipment_Tracking_Proship();
    39074082        $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);
    39084086    }
    39094087
  • shipment-tracker-for-woocommerce/trunk/admin/js/bt-sync-shipment-tracking-admin.js

    r3460036 r3472393  
    250250            api_test_connection_ship24();
    251251        });
     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        });
    252258
    253259        $(document).on('click', '#btn-bt-sync-now-shyplite', function (e) {
     
    349355        $(document).on('click', '#api_tc_m_close_btn_delh', function (e) {
    350356            $('#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');
    351361        });
    352362        $(document).on('click', '#api_tc_m_close_btn_ship24', function (e) {
     
    10181028        )
    10191029    }
     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    }
    10201044    function bt_st_show_info(info_text) {
    10211045        jQuery('#bt_notify_popup_content_title').text(info_text);
  • shipment-tracker-for-woocommerce/trunk/admin/partials/bt-shipment-tracking-manual-metabox.php

    r3292239 r3472393  
    214214</p>
    215215<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>
    219219</p>
    220220<p class="form-field ">
  • shipment-tracker-for-woocommerce/trunk/admin/partials/bt-shipment-tracking-metabox.php

    r3460036 r3472393  
    9494        </div>
    9595    <?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 } ?>
    96133    <a id="bt_notify_popup" style="display:none;"
    97134        href="#TB_inline?&width=200&height=150&inlineId=bt_notify_popup_content" class="thickbox"></a>
     
    116153        <?php } else { ?>
    117154            <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') { ?>
    119156                <button type="button" style="margin:5px 0" ; id="dawnload_able_pdf" class="button dawnload_able_document"
    120157                    href='#'>Download Label</button>
     
    339376        }
    340377
     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
    341407    </script>
    342408</div>
  • shipment-tracker-for-woocommerce/trunk/admin/partials/order_admin_after_shipping.php

    r3460036 r3472393  
    5959?>
    6060    <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>
    6166     <?php endif ?>
    6267
  • shipment-tracker-for-woocommerce/trunk/admin/partials/order_shipment_details.php

    r3460036 r3472393  
    4848            $edit =  "<br><a class='bt_sync_order_tracking' data-order-id='$order_id' href='#'>Sync Now</a>";
    4949        }
     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        }
    5053   // }
    5154}
  • shipment-tracker-for-woocommerce/trunk/bt-sync-shipment-tracking.php

    r3460036 r3472393  
    1717 * Plugin URI:        https://shipment-tracker-for-woocommerce.bitss.tech/
    1818 * 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.2
     19 * Version:           1.5.3.3
    2020 * Author:            Bitss Techniques
    2121 * Author URI:        https://shipment-tracker-for-woocommerce.bitss.tech
     
    5959
    6060define( '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' );
     61define( 'BT_SYNC_SHIPMENT_TRACKING_VERSION', '1.5.3.3' );
    6262define( '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') );
    6363define( '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') );
     
    149149} );
    150150run_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  
    204204        {
    205205            "name": "doctrine/deprecations",
    206             "version": "1.1.6",
     206            "version": "1.1.5",
    207207            "source": {
    208208                "type": "git",
    209209                "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",
    216216                "shasum": ""
    217217            },
     
    220220            },
    221221            "conflict": {
    222                 "phpunit/phpunit": "<=7.5 || >=14"
     222                "phpunit/phpunit": "<=7.5 || >=13"
    223223            },
    224224            "require-dev": {
    225                 "doctrine/coding-standard": "^9 || ^12 || ^14",
    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",
    227227                "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",
    229229                "psr/log": "^1 || ^2 || ^3"
    230230            },
     
    246246            "support": {
    247247                "issues": "https://github.com/doctrine/deprecations/issues",
    248                 "source": "https://github.com/doctrine/deprecations/tree/1.1.6"
    249             },
    250             "time": "2026-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"
    251251        },
    252252        {
     
    993993        {
    994994            "name": "symfony/finder",
    995             "version": "v6.4.33",
     995            "version": "v6.4.32",
    996996            "source": {
    997997                "type": "git",
    998998                "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",
    10051005                "shasum": ""
    10061006            },
     
    10371037            "homepage": "https://symfony.com",
    10381038            "support": {
    1039                 "source": "https://github.com/symfony/finder/tree/v6.4.33"
     1039                "source": "https://github.com/symfony/finder/tree/v6.4.32"
    10401040            },
    10411041            "funding": [
     
    10571057                }
    10581058            ],
    1059             "time": "2026-01-26T13:03:48+00:00"
     1059            "time": "2026-01-10T14:09:00+00:00"
    10601060        },
    10611061        {
  • shipment-tracker-for-woocommerce/trunk/includes/class-bt-sync-shipment-setting-update-core.php

    r3348657 r3472393  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) exit;
    24
    35class Class_bt_sync_shipment_setting_update_core
  • shipment-tracker-for-woocommerce/trunk/includes/class-bt-sync-shipment-tracking-activator.php

    r3348657 r3472393  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) exit;
    24
    35/**
  • shipment-tracker-for-woocommerce/trunk/includes/class-bt-sync-shipment-tracking-admin-ajax-functions.php

    r3348657 r3472393  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) exit;
    24
    35
     
    1719        $this->manual = $manual;
    1820        $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();
    1958    }
    2059
     
    115154
    116155        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
    117170            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.
    118171            Bt_Sync_Shipment_Tracking::bt_sst_update_order_meta($order_id, '_bt_shipping_awb', sanitize_text_field($awb_number ));
     
    173226
    174227    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
    175249        $resp = array(
    176250            "status" => false,
     
    179253
    180254        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);
    182256            $resp["status"] = true;
    183257        }
  • shipment-tracker-for-woocommerce/trunk/includes/class-bt-sync-shipment-tracking-crons.php

    r3460036 r3472393  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) exit;
    24
    35class Bt_Sync_Shipment_Tracking_Crons {
     
    1921    private $courierkaro;
    2022    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) {
    2326        $this->shiprocket = $shiprocket;
    2427        $this->shipmozo = $shipmozo;
     
    2932        $this->fship = $fship;
    3033        $this->courierkaro = $courierkaro;
    31         $this->proship = $proship;
     34        $this->ithink = $ithink;
    3235    }
    3336   
     
    6871                $objs = $this->shiprocket->update_order_shipment_status($o);
    6972                //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());
    7082            }
    7183        }
     
    240252            }
    241253        }
     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        }
    242261        if(is_array($enabled_shipping_providers) && in_array('delhivery',$enabled_shipping_providers)){
    243262            $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  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) exit;
    24
    35/**
  • shipment-tracker-for-woocommerce/trunk/includes/class-bt-sync-shipment-tracking-i18n.php

    r2469257 r3472393  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) exit;
    24
    35/**
  • shipment-tracker-for-woocommerce/trunk/includes/class-bt-sync-shipment-tracking-loader.php

    r3348657 r3472393  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) exit;
    24
    35/**
  • shipment-tracker-for-woocommerce/trunk/includes/class-bt-sync-shipment-tracking-rest-functions.php

    r3460036 r3472393  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) exit;
    24
    35
  • shipment-tracker-for-woocommerce/trunk/includes/class-bt-sync-shipment-tracking-rest.php

    r3460036 r3472393  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) exit;
    24
    35
  • shipment-tracker-for-woocommerce/trunk/includes/class-bt-sync-shipment-tracking.php

    r3460036 r3472393  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) exit;
    24
    35use Carbon_Fields\Container;
     
    7880    private $ekart;
    7981    private $proship;
     82    private $courierkaro;
     83    private $ithink;
    8084
    8185    /**
     
    208212        ];
    209213    }
    210 
    211214    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)
    216215        $meta_length = Bt_Sync_Shipment_Tracking::bt_sst_get_order_meta($order_id, '_bt_package_length');
    217216        $meta_width = Bt_Sync_Shipment_Tracking::bt_sst_get_order_meta($order_id, '_bt_package_width');
     
    219218        $meta_weight = Bt_Sync_Shipment_Tracking::bt_sst_get_order_meta($order_id, '_bt_package_weight');
    220219
    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'];
    232226        }
    233227
    234         // Convert to standard units: cm for dimensions, g for weight
    235         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 100g
    261         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 
    265228        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,
    270233        ];
    271234    }
     
    343306        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/shipping_providers/courier_karo.php';
    344307        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';
    345309
    346310        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-bt-sync-shipment-tracking-rest.php';
     
    366330        $this->courierkaro = new Bt_Sync_Shipment_Tracking_CourierKaro();
    367331        $this->proship = new Bt_Sync_Shipment_Tracking_Proship();
     332        $this->ithink = new Bt_Sync_Shipment_Tracking_Ithink();
    368333        ( new Bt_Sync_Shipment_Tracking_Review() )->hooks();
    369334    }
     
    377342    private function define_cron_events() {
    378343
    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);
    380345
    381346        $this->loader->add_action( Bt_Sync_Shipment_Tracking_Crons::BT_MINUTELY_JOB, $this->crons, 'minutely_job');
     
    463428    private function define_admin_hooks() {
    464429
    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);
    466431        $this->loader->add_action( 'dokan_order_detail_after_order_general_details',$plugin_admin, 'custom_dokan_order_details', 10, 1 );
    467432        $this->loader->add_action('carbon_fields_save_post',$plugin_admin, 'update_woocommerce_data_on_carbon_fields_save', 10, 3);
     
    503468        $this->loader->add_action( 'bt_push_order_to_courierkaro', $plugin_admin, 'push_order_to_courierkaro',10,3);
    504469        $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);
    505471        $this->loader->add_action( 'bt_push_order_to_nimbuspost', $plugin_admin, 'push_order_to_nimbuspost',10,3);
    506472
     
    531497        $this->loader->add_action( 'wp_ajax_api_call_for_ekart_test_connection', $plugin_admin, 'api_call_for_ekart_test_connection' );
    532498        $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' );
    533500        $this->loader->add_action( 'wp_ajax_get_sms_trial', $plugin_admin, 'get_sms_trial' );
    534501        $this->loader->add_action( 'wp_ajax_get_bt_sst_email_trial', $plugin_admin, 'get_bt_sst_email_trial' );
     
    18221789                    ->set_html(
    18231790                        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>
    18251792                                <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>
    18261793                                <p>Last Webhook Called On: '.$shipmozo_webhook_time.'</p>
     
    23582325                    'ekart' => 'Ekart',
    23592326                    'proship' => 'Proship',
     2327                    'ithink' => 'iThink logistic',
    23602328                ) )
    23612329                ->set_help_text('
     
    26122580                    'ekart' => 'Ekart',
    26132581                    'proship' => 'Proship',
     2582                    'ithink' => 'iThink Logistic',
    26142583                   
    26152584                   
     
    27922761                        'field' => 'bt_sst_courier_rate_provider',
    27932762                        'compare' => 'IN',
    2794                         'value' => array('shiprocket','shipmozo','delhivery','proship'),
     2763                        'value' => array('shiprocket','shipmozo','delhivery','proship','ithink'),
    27952764                    )
    27962765                ) ),
     
    29792948    private function define_public_hooks() {
    29802949
    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);
    29822951
    29832952        // $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  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) exit;
    24
    35class Bt_Sync_Shipment_Tracking_Shipment_Model{
  • shipment-tracker-for-woocommerce/trunk/includes/shipping_providers/delhivery.php

    r3446887 r3472393  
    22use PhpUnitsOfMeasure\PhysicalQuantity\Mass;
    33use PhpUnitsOfMeasure\PhysicalQuantity\Length;
     4if ( ! defined( 'ABSPATH' ) ) exit;
    45class Bt_Sync_Shipment_Tracking_Delhivery {
    56
  • shipment-tracker-for-woocommerce/trunk/includes/shipping_providers/ekart.php

    r3460036 r3472393  
    217217                $product = $a->get_product();
    218218               
    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                // }
    232232                if(empty($product_description )){
    233233                    $product_description = $product->get_name();
     
    236236            }
    237237        }
     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'];
    238244
    239245        $weight_unit = get_option('woocommerce_weight_unit');
  • shipment-tracker-for-woocommerce/trunk/includes/shipping_providers/fship.php

    r3368473 r3472393  
    22use PhpUnitsOfMeasure\PhysicalQuantity\Mass;
    33use PhpUnitsOfMeasure\PhysicalQuantity\Length;
     4if ( ! defined( 'ABSPATH' ) ) exit;
    45class Bt_Sync_Shipment_Tracking_Fship
    56{
  • shipment-tracker-for-woocommerce/trunk/includes/shipping_providers/manual.php

    r3348657 r3472393  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) exit;
    24
    35/**
  • shipment-tracker-for-woocommerce/trunk/includes/shipping_providers/nimbuspost.php

    r3348657 r3472393  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) exit;
    24
    35/**
  • shipment-tracker-for-woocommerce/trunk/includes/shipping_providers/nimbuspost_new.php

    r3284690 r3472393  
    22use PhpUnitsOfMeasure\PhysicalQuantity\Mass;
    33use PhpUnitsOfMeasure\PhysicalQuantity\Length;
     4if ( ! defined( 'ABSPATH' ) ) exit;
    45
    56/**
  • shipment-tracker-for-woocommerce/trunk/includes/shipping_providers/proship.php

    r3460036 r3472393  
    11<?php
     2if ( ! defined( 'ABSPATH' ) ) exit;
    23use PhpUnitsOfMeasure\PhysicalQuantity\Mass;
    34use PhpUnitsOfMeasure\PhysicalQuantity\Length;
  • shipment-tracker-for-woocommerce/trunk/includes/shipping_providers/ship24.php

    r3348657 r3472393  
    11<?php
     2if ( ! defined( 'ABSPATH' ) ) exit;
    23class Bt_Sync_Shipment_Tracking_Ship24 {
    34
  • shipment-tracker-for-woocommerce/trunk/includes/shipping_providers/shipmozo.php

    r3348657 r3472393  
    22use PhpUnitsOfMeasure\PhysicalQuantity\Mass;
    33use PhpUnitsOfMeasure\PhysicalQuantity\Length;
     4if ( ! defined( 'ABSPATH' ) ) exit;
    45class Bt_Sync_Shipment_Tracking_Shipmozo {
    56
     
    5051
    5152    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             NULL
    70             ["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 
    14953        update_option( "shipmozo_webhook_called", time() );
    15054        $enabled_shipping_providers = carbon_get_theme_option( 'bt_sst_enabled_shipping_providers' );
     
    17680                                Bt_Sync_Shipment_Tracking::bt_sst_update_order_meta($order_id, '_bt_shipmozo_order_id', $shipmozo_order_id);
    17781                            }
    178                          
    179                             // $bt_sst_order_statuses_to_sync = carbon_get_theme_option( 'bt_sst_order_statuses_to_sync' );
    18082                            $bt_sst_sync_orders_date = carbon_get_theme_option( 'bt_sst_sync_orders_date' );
    181        
    18283                            $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        
    18684                                $date_created_dt = $order->get_date_created(); // Get order date created WC_DateTime Object
    18785                                $timezone        = $date_created_dt->getTimezone(); // Get the timezone
    18886                                $date_created_ts = $date_created_dt->getTimestamp(); // Get the timestamp in seconds
    189        
    19087                                $now_dt = new WC_DateTime(); // Get current WC_DateTime object instance
    19188                                $now_dt->setTimezone( $timezone ); // Set the same time zone
    19289                                $now_ts = $now_dt->getTimestamp(); // Get the current timestamp in seconds
    193        
    19490                                $allowed_seconds = $bt_sst_sync_orders_date * 24 * 60 * 60; // bt_sst_sync_orders_date in seconds
    195        
    19691                                $diff_in_seconds = $now_ts - $date_created_ts; // Get the difference (in seconds)
    197        
    19892                                if ( $diff_in_seconds <= $allowed_seconds ) {
    19993                                    $shipment_obj = $this->init_model($request, $order_id);
     
    20397                                    return "Thanks Shipmozo! Order too old.";
    20498                                }
    205                             // }else{
    206                             //     return "Thanks Shipmozo! Order status out of scope.";
    207                             // }
    20899                        }
    209100                    }
    210101                }                   
    211102            }
    212 
    213         // ob_start();
    214         // var_dump($request);
    215         // $result = ob_get_clean();
    216 
    217         // error_log($result);
    218 
    219103        return "Thanks Shipmozo, but nothing got updated.";
    220104        }
     
    561445                    } else {
    562446                        $order = wc_get_order( $order_id );
    563                         $order->add_order_note('AWB missing in Shipmozo order');                   
    564447                    }
    565448                } else {
  • shipment-tracker-for-woocommerce/trunk/includes/shipping_providers/shiprocket.php

    r3338305 r3472393  
    11<?php
     2if ( ! defined( 'ABSPATH' ) ) exit;
    23use PhpUnitsOfMeasure\PhysicalQuantity\Mass;
    34use PhpUnitsOfMeasure\PhysicalQuantity\Length;
  • shipment-tracker-for-woocommerce/trunk/includes/shipping_providers/shyplite.php

    r3348657 r3472393  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) exit;
    24
    35/**
  • shipment-tracker-for-woocommerce/trunk/includes/shipping_providers/xpressbees.php

    r3348657 r3472393  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) exit;
    24
    35/**
  • shipment-tracker-for-woocommerce/trunk/public/class-bt-sync-shipment-tracking-public.php

    r3460036 r3472393  
    5959     * @param      string    $version    The version of this plugin.
    6060     */
    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)
    6262    {
    6363
     
    7272        $this->ekart = $ekart;
    7373        $this->proship = $proship;
     74        $this->ithink = $ithink;
    7475    }
    7576
     
    13221323                //  $city = $city_data['city'];
    13231324                // }
     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                // }
    13241436            }
    13251437
     
    14701582    }
    14711583
    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;
    14831620        $processing_days = 0;
    1484         // Check for product page or cart page
    14851621        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
    14891626        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
    14921631        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) {
    14941633                $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
    14971638                $processing_days = max($processing_days, $product_processing_days);
    14981639            }
    14991640        }
    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;
    15021660    }
    15031661
     
    30383196                }
    30393197            }
     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       
    30403340
    30413341        }
  • shipment-tracker-for-woocommerce/trunk/public/partials/bt-sync-shipment-tracking-public-display.php

    r3348657 r3472393  
    11<?php
     2
     3if ( ! defined( 'ABSPATH' ) ) exit;
    24
    35/**
Note: See TracChangeset for help on using the changeset viewer.