Skip to content

Commit

Permalink
Merge pull request #74 from thrivedesk/feat/wc-integration-update
Browse files Browse the repository at this point in the history
feat : Added tracking info to customer orders and custom Order Id support with TD-WooCommerce widget.
  • Loading branch information
Rijoanul-Shanto authored Jan 30, 2024
2 parents 46ecdfb + f48d1e5 commit 2947dea
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down
29 changes: 25 additions & 4 deletions src/Plugins/WooCommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace ThriveDesk\Plugins;

use AfterShip_Actions;
use ThriveDesk\Plugin;
use WC_Order_Query;
use WC_Subscriptions_Product;
Expand All @@ -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.
*/
Expand Down Expand Up @@ -153,6 +159,20 @@ 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();
$data = $afterShip->get_tracking_items($order_id);
$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]));
}
}

return $this->tracking;
}

/**
* Get the customer orders
*
Expand All @@ -168,18 +188,19 @@ 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() ) ),
'order_status' => ucfirst( $order->get_status() ),
'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() ),
] );
$this->tracking = [];
}
}

Expand Down Expand Up @@ -208,7 +229,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() ) ),
Expand Down
4 changes: 2 additions & 2 deletions thrivedesk.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -50,7 +50,7 @@ final class ThriveDesk
*
* @var string
*/
public $version = '1.2';
public $version = '1.2.1';

/**
* The single instance of this class
Expand Down

0 comments on commit 2947dea

Please sign in to comment.