From 21d0d34edac70eb25d31ebde4ca901fa40521150 Mon Sep 17 00:00:00 2001 From: pronob1010 Date: Mon, 29 Jan 2024 16:05:47 +0600 Subject: [PATCH 1/9] feat: Add tracking info to customer orders and custom OrderId support in TD-WooCommerce widget. --- src/Plugins/WooCommerce.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/Plugins/WooCommerce.php b/src/Plugins/WooCommerce.php index 87282c7..165f625 100755 --- a/src/Plugins/WooCommerce.php +++ b/src/Plugins/WooCommerce.php @@ -2,6 +2,7 @@ namespace ThriveDesk\Plugins; +use AfterShip_Actions; use ThriveDesk\Plugin; use WC_Order_Query; use WC_Subscriptions_Product; @@ -22,6 +23,11 @@ final class WooCommerce extends Plugin { */ public $orders = []; + /** + * To store tracking details. + */ + public $tracking = []; + /** * To track the get_orders method is already called or not. */ @@ -153,6 +159,14 @@ public function get_formated_amount( float $amount ): string { return get_woocommerce_currency_symbol() . $amount; } + public function get_tracking_info($order_id){ + if ( in_array( 'aftership-woocommerce-tracking/aftership-woocommerce-tracking.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) ) { + $afterShip = new AfterShip_Actions(); + array_push($this->tracking, $afterShip->get_tracking_items($order_id)); + } + return $this->tracking; + } + /** * Get the customer orders * @@ -168,7 +182,7 @@ public function get_orders(): array { foreach ( $customer_orders as $order ) { array_push( $this->orders, [ - 'order_id' => $order->get_id(), + 'order_id' => $order->get_order_number(), 'amount' => (float) $order->get_total(), 'amount_formated' => $this->get_formated_amount( $order->get_total() ), 'date' => date( 'd M Y', strtotime( $order->get_date_created() ) ), @@ -178,7 +192,7 @@ public function get_orders(): array { 'order_url' => method_exists( $order, 'get_edit_order_url' ) ? $order->get_edit_order_url() : '#', 'coupon' => $order->get_coupon_codes() ?? null, - + 'tracking_info' => $this->get_tracking_info($order->get_id()), ] ); } } @@ -208,7 +222,7 @@ public function order_status( $order_id ): array { } return [ - 'order_id' => $order->get_id(), + 'order_id' => $order->get_order_number(), 'amount' => $order->get_total(), 'amount_formatted' => $this->get_formated_amount( $order->get_total() ), 'date' => date( 'd M Y', strtotime( $order->get_date_created() ) ), From 50cc237aee01d08163f537314b3292df43662b45 Mon Sep 17 00:00:00 2001 From: pronob1010 Date: Mon, 29 Jan 2024 17:13:08 +0600 Subject: [PATCH 2/9] fix: formate update --- src/Plugins/WooCommerce.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Plugins/WooCommerce.php b/src/Plugins/WooCommerce.php index 165f625..8f66019 100755 --- a/src/Plugins/WooCommerce.php +++ b/src/Plugins/WooCommerce.php @@ -162,7 +162,7 @@ public function get_formated_amount( float $amount ): string { public function get_tracking_info($order_id){ if ( in_array( 'aftership-woocommerce-tracking/aftership-woocommerce-tracking.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) ) { $afterShip = new AfterShip_Actions(); - array_push($this->tracking, $afterShip->get_tracking_items($order_id)); + $this->tracking = array_merge($this->tracking, array('aftership' => $afterShip->get_tracking_items($order_id))); } return $this->tracking; } From 4cc58ec1ca4b9e616b043503d1b0d99d51101500 Mon Sep 17 00:00:00 2001 From: Rijoanul-Shanto Date: Tue, 30 Jan 2024 13:36:59 +0600 Subject: [PATCH 3/9] chore: reformat --- src/Plugins/WooCommerce.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Plugins/WooCommerce.php b/src/Plugins/WooCommerce.php index 8f66019..d4fa963 100755 --- a/src/Plugins/WooCommerce.php +++ b/src/Plugins/WooCommerce.php @@ -159,11 +159,14 @@ public function get_formated_amount( float $amount ): string { return get_woocommerce_currency_symbol() . $amount; } - public function get_tracking_info($order_id){ - if ( in_array( 'aftership-woocommerce-tracking/aftership-woocommerce-tracking.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) ) { - $afterShip = new AfterShip_Actions(); - $this->tracking = array_merge($this->tracking, array('aftership' => $afterShip->get_tracking_items($order_id))); + public function get_tracking_info( $order_id ) { + if ( in_array( 'aftership-woocommerce-tracking/aftership-woocommerce-tracking.php', + apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) ) { + $afterShip = new AfterShip_Actions(); + $this->tracking = array_merge( $this->tracking, + array( 'aftership' => $afterShip->get_tracking_items( $order_id ) ) ); } + return $this->tracking; } @@ -190,9 +193,9 @@ public function get_orders(): array { 'shipping' => $this->shipping_param ? $this->get_shipping_details( $order ) : [], 'downloads' => $this->get_order_items( $order ), 'order_url' => method_exists( $order, - 'get_edit_order_url' ) ? $order->get_edit_order_url() : '#', + 'get_edit_order_url' ) ? $order->get_edit_order_url() : '#', 'coupon' => $order->get_coupon_codes() ?? null, - 'tracking_info' => $this->get_tracking_info($order->get_id()), + 'tracking_info' => $this->get_tracking_info( $order->get_id() ), ] ); } } From 1ea9d0d708f770b27e00dc8428cfef38719c3785 Mon Sep 17 00:00:00 2001 From: pronob1010 Date: Tue, 30 Jan 2024 14:17:18 +0600 Subject: [PATCH 4/9] fix: auto tracking key added --- src/Plugins/WooCommerce.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Plugins/WooCommerce.php b/src/Plugins/WooCommerce.php index 8f66019..14105a7 100755 --- a/src/Plugins/WooCommerce.php +++ b/src/Plugins/WooCommerce.php @@ -162,7 +162,9 @@ public function get_formated_amount( float $amount ): string { public function get_tracking_info($order_id){ if ( in_array( 'aftership-woocommerce-tracking/aftership-woocommerce-tracking.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) ) { $afterShip = new AfterShip_Actions(); - $this->tracking = array_merge($this->tracking, array('aftership' => $afterShip->get_tracking_items($order_id))); + if($afterShip->get_tracking_items($order_id)){ + $this->tracking = array_merge($this->tracking, array('aftership' => $afterShip->get_tracking_items($order_id))); + } } return $this->tracking; } From ca1919d3f175007ab8a8f85cc195785319262b7c Mon Sep 17 00:00:00 2001 From: pronob1010 Date: Tue, 30 Jan 2024 14:41:23 +0600 Subject: [PATCH 5/9] fix: clear after tracking info added --- src/Plugins/WooCommerce.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Plugins/WooCommerce.php b/src/Plugins/WooCommerce.php index de9d0ba..dea1bab 100755 --- a/src/Plugins/WooCommerce.php +++ b/src/Plugins/WooCommerce.php @@ -200,6 +200,7 @@ public function get_orders(): array { } } + $this->tracking = []; return $this->orders; } From 5241f7171aee59cd56073d9e21025c581a93936a Mon Sep 17 00:00:00 2001 From: pronob1010 Date: Tue, 30 Jan 2024 14:43:57 +0600 Subject: [PATCH 6/9] fix: clear after tracking info added --- src/Plugins/WooCommerce.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Plugins/WooCommerce.php b/src/Plugins/WooCommerce.php index dea1bab..44e1220 100755 --- a/src/Plugins/WooCommerce.php +++ b/src/Plugins/WooCommerce.php @@ -197,10 +197,10 @@ public function get_orders(): array { 'coupon' => $order->get_coupon_codes() ?? null, 'tracking_info' => $this->get_tracking_info( $order->get_id() ), ] ); + $this->tracking = []; } } - $this->tracking = []; return $this->orders; } From ab52c08023c9b9be256277c5f7e6bccd132c7656 Mon Sep 17 00:00:00 2001 From: pronob1010 Date: Tue, 30 Jan 2024 16:08:38 +0600 Subject: [PATCH 7/9] fix: clear after tracking url added --- src/Plugins/WooCommerce.php | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/Plugins/WooCommerce.php b/src/Plugins/WooCommerce.php index 44e1220..15900d8 100755 --- a/src/Plugins/WooCommerce.php +++ b/src/Plugins/WooCommerce.php @@ -159,16 +159,19 @@ public function get_formated_amount( float $amount ): string { return get_woocommerce_currency_symbol() . $amount; } - public function get_tracking_info($order_id){ - if ( in_array( 'aftership-woocommerce-tracking/aftership-woocommerce-tracking.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) ) { - $afterShip = new AfterShip_Actions(); - if($afterShip->get_tracking_items($order_id)){ - $this->tracking = array_merge($this->tracking, array('aftership' => $afterShip->get_tracking_items($order_id))); - } - } - - return $this->tracking; - } + public function get_tracking_info($order_id){ + if ( in_array( 'aftership-woocommerce-tracking/aftership-woocommerce-tracking.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) ) { + $afterShip = new AfterShip_Actions(); + $data = $afterShip->get_tracking_items($order_id); + $aftership_tracking_link = $afterShip->generate_tracking_page_link($data[0]); + + if($data){ + $this->tracking = array_merge($this->tracking, array('aftership' => ['data' => $data, 'url' => $aftership_tracking_link])); + } + } + + return $this->tracking; + } /** * Get the customer orders From 34ab2f9589d65ecae6ac416398e2459c7dd1d1a9 Mon Sep 17 00:00:00 2001 From: pronob1010 Date: Tue, 30 Jan 2024 16:10:22 +0600 Subject: [PATCH 8/9] fix: clear after tracking url added --- src/Plugins/WooCommerce.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Plugins/WooCommerce.php b/src/Plugins/WooCommerce.php index 15900d8..dc65928 100755 --- a/src/Plugins/WooCommerce.php +++ b/src/Plugins/WooCommerce.php @@ -163,7 +163,7 @@ public function get_tracking_info($order_id){ if ( in_array( 'aftership-woocommerce-tracking/aftership-woocommerce-tracking.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) ) { $afterShip = new AfterShip_Actions(); $data = $afterShip->get_tracking_items($order_id); - $aftership_tracking_link = $afterShip->generate_tracking_page_link($data[0]); + $aftership_tracking_link = $afterShip->generate_tracking_page_link($data[0]) ? $afterShip->generate_tracking_page_link($data[0]) : '#' ; if($data){ $this->tracking = array_merge($this->tracking, array('aftership' => ['data' => $data, 'url' => $aftership_tracking_link])); From f48d1e588c8c844b72aa4416f6bc1922b8435ff9 Mon Sep 17 00:00:00 2001 From: pronob1010 Date: Tue, 30 Jan 2024 19:26:49 +0600 Subject: [PATCH 9/9] chore: readme and version update --- readme.txt | 5 ++++- thrivedesk.php | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/readme.txt b/readme.txt index f45e5b6..58c186e 100755 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: thrivedesk Tags: livechat, chat, help desk, chat plugin, free live chat, community, helpdesk, chatbot, knowledge base, support, help center, customer care, woocommerce, surecart, freemius, thrivedesk, zendesk, mailchimp Requires at least: 4.9 Tested up to: 6.4 -Stable Tag: 1.2 +Stable Tag: 1.2.1 Requires PHP: 5.5 License: GNU General Public License v2.0 or later @@ -223,6 +223,9 @@ Privacy is our utmost priority, and we designed ThriveDesk in a way that aligned - Easy setup: Setup your Shared Inbox in less than a minute. == Changelog == += 1.2.1 = +- Feat: Woocommerce custom order ID support added. +- Feat: Woocommerce AfterShip plugin support added. = 1.2 = - Fix: User data conflict issue fixed. diff --git a/thrivedesk.php b/thrivedesk.php index e509d43..8573ca5 100755 --- a/thrivedesk.php +++ b/thrivedesk.php @@ -5,7 +5,7 @@ * Description: Live Chat, Help Desk & Knowledge Base plugin for WordPress * Plugin URI: https://www.thrivedesk.com/?utm_source=wp-plugins&utm_campaign=plugin-uri&utm_medium=wp-dash * Tags: live chat, helpdesk, free live chat, knowledge base, thrivedesk - * Version: 1.2 + * Version: 1.2.1 * Author: ThriveDesk * Author URI: https://profiles.wordpress.org/thrivedesk/ * Text Domain: thrivedesk @@ -50,7 +50,7 @@ final class ThriveDesk * * @var string */ - public $version = '1.2'; + public $version = '1.2.1'; /** * The single instance of this class