Skip to content

Commit

Permalink
search issue fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hmbashar authored Jul 25, 2024
1 parent 542b359 commit 7165edd
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 150 deletions.
7 changes: 3 additions & 4 deletions cbwct.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Plugin URI: https://wordpress.org/plugins/wc-order-tracker/
Description: Your customer can track his/her order on your WooCommerce website easily, woocommerce order tracking system with ajax
Author: Md Abul Bashar
Version: 1.2.2
Version: 1.2.3
Author URI: https://facebook.com/hmbashar
Text Domain: cbwct
Expand All @@ -30,9 +30,8 @@ function cbwct_basic_scripts(){
wp_localize_script( 'cbwct-tracker-ajax', 'cbwct_tracker', array( 'ajaxurl' => admin_url('admin-ajax.php')) );
}
add_action('wp_enqueue_scripts','cbwct_basic_scripts');


//Include additional file
require_once( CBWCT_TRACKER_PATH . '/inc/custom.php' );
require_once( CBWCT_TRACKER_PATH . '/inc/shortcode.php' );
require_once( CBWCT_TRACKER_PATH . '/inc/hooks.php' );
require_once( CBWCT_TRACKER_PATH . '/inc/hooks.php' );

17 changes: 6 additions & 11 deletions inc/custom.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,12 @@ public static function selected_gateway_name($selected) {
}

// check if order number exists
public static function order_number_exists($order_number)
{
if(get_post_type($order_number) == "shop_order")
{
return true;
}
else
{
return false;
}
}

public static function order_number_exists($order_number) {
$order = wc_get_order($order_number);
return ($order && $order->get_id() != null);
}



}
Expand Down
81 changes: 33 additions & 48 deletions inc/process.php
Original file line number Diff line number Diff line change
@@ -1,56 +1,41 @@
<?php
// Don't call the file directly
if ( !defined( 'ABSPATH' ) ) exit;
// Don't call the file directly
if (!defined('ABSPATH')) exit;

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

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


if(empty($get_order_number) || empty($get_phone_number)) { // search field empty check
apply_filters( 'cbwct_order_number_phone_number_required', esc_html__('Order Number & Phone 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';
}

if($get_phone_number === $user_phone || $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 );
}
}
}
if (empty($get_order_number) || empty($get_phone_number)) { // Check if search fields are empty
echo apply_filters('cbwct_order_number_phone_number_required', esc_html__('Order Number & Phone field is required', 'cbwct'));
} else {


if (!CBWCT_ORDER_TRACKER::order_number_exists($get_order_number)) {
echo apply_filters('cbwct_order_is_not_found', esc_html__("Oops! Sorry! {$get_order_number} order is not found! Please check the order or phone number.", 'cbwct'), $get_order_number);
} else {
$order = wc_get_order($get_order_number); // Retrieve the order
$order_data = $order->get_data(); // Get the order data

// Get user phone numbers from billing and shipping forms
$user_billing_phone_number = isset($order_data['billing']['phone']) ? $order_data['billing']['phone'] : '';
$user_shipping_phone_number = isset($order_data['shipping']['phone']) ? $order_data['shipping']['phone'] : '';

// Determine which phone number to use
$user_phone = !empty($user_billing_phone_number) ? $user_billing_phone_number : (!empty($user_shipping_phone_number) ? $user_shipping_phone_number : 'Unknown phone number');

// Compare the provided phone number with the one from the order
if ($get_phone_number === $user_phone) {
// If phone numbers match, include the progress bar and result templates
require_once(CBWCT_TRACKER_PATH . '/inc/templates/progressbar.php');
require_once(CBWCT_TRACKER_PATH . '/inc/templates/result.php');
} else {
echo apply_filters('cbwct_phone_mismatch', esc_html__('The provided phone number does not match our records.', 'cbwct'), $get_order_number);
}
}
}
?>
177 changes: 90 additions & 87 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,88 +1,91 @@
=== Order Tracker for WooCommerce ===
Contributors: hmbashar
Tags: woocommerce order tracker, order tracker,shipping, delivery tracker
Requires at least: 4.7
Tested up to: 6.5
Stable tag: 1.2.2
Requires PHP: 7.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

An easy-to-use WooCommerce order tracker with Ajax. Use as a page template or via [cbwct-order-tracker] shortcode for instant updates anywhere.

== Description ==


Hi, Are you using WooCommerce? you can use the plugin for your customers can track his/her order status on your website, it's a woocommerce order tracking system with ajax, you can use it very easy way, like make a page template or using the [cbwct-order-tracker] shortcode, anytime anywhere, and it's also working with ajax.

Welcome for contribution on <a href="https://github.com/hmbashar/wc-order-tracker">github</a>

https://www.youtube.com/watch?v=FfE7GuqwlbA

https://www.youtube.com/watch?v=PojzV-wmLpw

= Filter Hook =

* cbwct_pending_prograss_percent
* cbwct_on_hold_prograss_percent
* cbwct_processing_prograss_percent
* cbwct_shipped_prograss_percent
* cbwct_completed_prograss_percent

== Frequently Asked Questions ==

= How can i use the plugin? =

You can use the plugin by template or shortcode, you need to make a page then select "Order Tracker for WooCommerce" template from your page attribute option.

= Do you have shortcode for using the plugin anywhere? =

Yes, You've shortcode for the plugin, you can use the shortcode [cbwct-order-tracker] for showing the search form with search result anywhere.

= Do you support hook? =
Yes, You've some of hooks for developer

* cbwct_pending_prograss_percent
* cbwct_on_hold_prograss_percent
* cbwct_processing_prograss_percent
* cbwct_shipped_prograss_percent
* cbwct_completed_prograss_percent

= Order and mobile number correct but still showing doesn't found? =
make sure your customer has used the exact same number for the tracking which that number input when placing the order. like If your customer inputs his/her phone number with country code when placing an order then his/her needs the exact same number with the country code.

If your customer input this format +88 (country code) 123456789 (mobile number) full number like +88123456789 then his/her need to exact same like +88123456789 for the tracking.

or if he/she inputs without country code and only mobile number like this 123456789 then his/her need to input without country code like this 123456789 number for tracking.


== Screenshots ==

1. Cancelled ordered
2. Order Shipped
2. Order Processing
2. Order On-Hold

== Changelog ==
= 1.2.2 =
* text doamin added and security updated


= 1.1 =
* fix search form broken issue

= 1.1 =
* Add Shipped in status
* shortcode error fix
* Few changes.


= 1.0 =
* Release new version.



== Upgrade Notice ==

= 1.0 =
=== Order Tracker for WooCommerce ===
Contributors: hmbashar
Tags: woocommerce order tracker, order tracker,shipping, delivery tracker
Requires at least: 4.7
Tested up to: 6.6
Stable tag: 1.2.3
Requires PHP: 8.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

An easy-to-use WooCommerce order tracker with Ajax. Use as a page template or via [cbwct-order-tracker] shortcode for instant updates anywhere.

== Description ==


Hi, Are you using WooCommerce? you can use the plugin for your customers can track his/her order status on your website, it's a woocommerce order tracking system with ajax, you can use it very easy way, like make a page template or using the [cbwct-order-tracker] shortcode, anytime anywhere, and it's also working with ajax.

Welcome for contribution on <a href="https://github.com/hmbashar/wc-order-tracker">github</a>

https://www.youtube.com/watch?v=FfE7GuqwlbA

https://www.youtube.com/watch?v=PojzV-wmLpw

= Filter Hook =

* cbwct_pending_prograss_percent
* cbwct_on_hold_prograss_percent
* cbwct_processing_prograss_percent
* cbwct_shipped_prograss_percent
* cbwct_completed_prograss_percent

== Frequently Asked Questions ==

= How can i use the plugin? =

You can use the plugin by template or shortcode, you need to make a page then select "Order Tracker for WooCommerce" template from your page attribute option.

= Do you have shortcode for using the plugin anywhere? =

Yes, You've shortcode for the plugin, you can use the shortcode [cbwct-order-tracker] for showing the search form with search result anywhere.

= Do you support hook? =
Yes, You've some of hooks for developer

* cbwct_pending_prograss_percent
* cbwct_on_hold_prograss_percent
* cbwct_processing_prograss_percent
* cbwct_shipped_prograss_percent
* cbwct_completed_prograss_percent

= Order and mobile number correct but still showing doesn't found? =
make sure your customer has used the exact same number for the tracking which that number input when placing the order. like If your customer inputs his/her phone number with country code when placing an order then his/her needs the exact same number with the country code.

If your customer input this format +88 (country code) 123456789 (mobile number) full number like +88123456789 then his/her need to exact same like +88123456789 for the tracking.

or if he/she inputs without country code and only mobile number like this 123456789 then his/her need to input without country code like this 123456789 number for tracking.


== Screenshots ==

1. Cancelled ordered
2. Order Shipped
2. Order Processing
2. Order On-Hold

== Changelog ==
= 1.2.3 =
* order number searching issue fix

= 1.2.2 =
* text doamin added and security updated


= 1.1 =
* fix search form broken issue

= 1.1 =
* Add Shipped in status
* shortcode error fix
* Few changes.


= 1.0 =
* Release new version.



== Upgrade Notice ==

= 1.0 =
Upgrade notices describe the reason a user should upgrade.

0 comments on commit 7165edd

Please sign in to comment.