hmbashar / wc-order-tracker

Woocommerce order tracker
1 stars 0 forks source link

To use only the order number. #1

Closed iqbalmbadhan closed 3 weeks ago

iqbalmbadhan commented 1 month ago

Replace process.php file to use the order number for tracking.

`<?php // Don't call the file directly if (!defined('ABSPATH')) exit;

if (!class_exists('CBWCT_ORDER_TRACKER')) { return; }

// set variable for getting value from input field $get_order_number = sanitize_text_field($_POST['order_number']); $get_phone_number = sanitize_text_field($_POST['phone_number']);

if (empty($get_order_number)) { // search field empty check apply_filters('cbwct_order_number_phone_number_required', esc_html('Order Number field is required', 'cbwct')); } else { if (!isset($get_order_number)) { // order number empty $order = NULL; } else { if (CBWCT_ORDER_TRACKER::order_number_exists($get_order_number) == false) { echo apply_filters('cbwct_order_is_not_found', esc_html('order is not found!', 'cbwct'), $get_order_number); } else { $order = wc_get_order($get_order_number); // set order number $order_data = $order->get_data(); // The Order data

        // get user phone number from shipping form
        $user_shipping_phone_number = isset($order_data['shipping']['phone']) ? $order_data['shipping']['phone'] : '';

        // get user phone number from billing form
        $user_billing_phone_number = isset($order_data['billing']['phone']) ? $order_data['billing']['phone'] : '';

        // set phone number value
        if (!empty($user_billing_phone_number)) {
            $user_phone = $user_billing_phone_number;
        } elseif ($user_billing_phone_number) {
            $user_phone = $user_billing_phone_number;
        } else {
            $user_phone = '4654654';
        }

        // Check if phone number is provided or not
        if (empty($get_phone_number) || $get_phone_number === $user_phone) {
            if (!empty($order)) {
                $order_data = $order->get_data(); // The Order data

                require_once(CBWCT_TRACKER_PATH . '/inc/templates/progressbar.php');
                require_once(CBWCT_TRACKER_PATH . '/inc/templates/result.php');
            }
        } else {
            echo apply_filters('cbwct_order_is_not_found', esc_html__('order is not found!', 'cbwct'), $get_order_number);
        }
    }
}

} ?>`

hmbashar commented 1 month ago

@iqbalmbadhan Hi, since we already have the feature to search order status by order number, why do I need to use the code again?

iqbalmbadhan commented 1 month ago

@hmbashar thanks bhai for your plugin. In our organisation we are using this and happy with it. Suddenly our manager ask me to set tracking with order number only instead mobile and order number. That’s why I make a little change and post it as a comment. Keep up the good work best of luck.

hmbashar commented 1 month ago

@hmbashar thanks bhai for your plugin. In our organisation we are using this and happy with it. Suddenly our manager ask me to set tracking with order number only instead mobile and order number. That’s why I make a little change and post it as a comment. Keep up the good work best of luck.

"Thank you for your response, but the code format in your comment is not displaying properly. Please edit your comment and use a code format like this is a code format here https://prnt.sc/AdiaSgDhBQHt so that others can easily copy and use the code if needed."