From 6a23502a2920c9a2e7b79046edb863adcff328aa Mon Sep 17 00:00:00 2001 From: pronob1010 Date: Thu, 16 May 2024 19:05:08 +0600 Subject: [PATCH 1/3] fix: wc issue and autonami namespace --- includes/views/partials/integrations.php | 2 +- src/Api.php | 14 +++++- src/Plugins/WooCommerce.php | 59 ++++++++++++------------ 3 files changed, 44 insertions(+), 31 deletions(-) mode change 100644 => 100755 includes/views/partials/integrations.php diff --git a/includes/views/partials/integrations.php b/includes/views/partials/integrations.php old mode 100644 new mode 100755 index 1ac09e9..d60d2d7 --- a/includes/views/partials/integrations.php +++ b/includes/views/partials/integrations.php @@ -41,7 +41,7 @@ 'connected' => $wppostsync->get_plugin_data( 'connected' ), ], [ - 'namespace' => 'wp-marketing-automations', + 'namespace' => 'autonami', 'name' => __( 'FunnelKit', 'thrivedesk' ), 'image' => 'autonami.png', 'category' => 'CRM', diff --git a/src/Api.php b/src/Api.php index 683c7c3..6f99fe3 100755 --- a/src/Api.php +++ b/src/Api.php @@ -227,12 +227,18 @@ public function get_woocommerce_product_list() { foreach ( $products as $product_id ) { $product = wc_get_product( $product_id ); + $thumbnail_id = get_post_thumbnail_id( $product_id ); + $image_src_array = []; + + if( $thumbnail_id){ + $image_src_array = wp_get_attachment_image_src( $thumbnail_id ); + } $productInfo = array( "product_id" => $product_id, "title" => $product->get_name(), "product_permalink" => get_permalink( $product_id ), - "image" => wp_get_attachment_image_src( get_post_thumbnail_id( $product_id ) )[0], + "image" => is_array( $image_src_array ) && ! empty( $image_src_array ) ? $image_src_array[0] : '', "sale_price" => get_woocommerce_currency_symbol() . $product->get_regular_price(), "stock" => ( 'instock' === $product->get_stock_status() ) ? 'In Stock' : 'Out of Stock', ); @@ -270,6 +276,12 @@ public function wc_order_add_new_item( string $order_id, $item ) { $item->set_product_id( $product->id ); $item->set_subtotal( $product->price ?? 0 ); $item->set_total( $product->price * $this->quantity ?? 0 ); + + // if(is_plugin_active('wt-woocommerce-sequential-order-numbers-pro/wt-advanced-order-number-pro.php')) + // { + // if customer use this type of plugin, wc doesn't have the same order number as the plugin. + // } + $order = wc_get_order( $order_id ); $order->add_item( $item ); $order->calculate_totals(); diff --git a/src/Plugins/WooCommerce.php b/src/Plugins/WooCommerce.php index 2b4c1df..bbd980b 100755 --- a/src/Plugins/WooCommerce.php +++ b/src/Plugins/WooCommerce.php @@ -342,8 +342,8 @@ public function get_order_items( $order ): array { } foreach ( $items as $item ) { - - $product_id = $item->get_variation_id() ?? $item->get_product_id(); + $productInfo = []; + $product_id = $item->get_variation_id() ? $item->get_variation_id() : $item->get_product_id(); $product = wc_get_product($product_id); if ( class_exists( 'WC_Subscriptions_Product' ) && WC_Subscriptions_Product::is_subscription( $product ) ) { @@ -357,33 +357,34 @@ public function get_order_items( $order ): array { "expiration_date" => WC_Subscriptions_Product::get_expiration_date( $product ), ]; } - - $productInfo = array( - "product_id" => $product_id, - "title" => $product->get_name(), - "product_permalink" => get_permalink($product_id), - "quantity" => $item["quantity"], - "total_tax" => $this->get_formated_amount( (float) $item["total_tax"] ), - "image" => wp_get_attachment_image_src( get_post_thumbnail_id($product_id) )[0], - "type" => $product->get_type(), - "status" => $product->get_status(), - "sku" => $product->get_sku(), - "price" => $this->get_formated_amount( (float) $item["subtotal"] ), - "regular_price" => $this->get_formated_amount( (float) $product->get_regular_price() ), - "sale_price" => $this->get_formated_amount( (float) $product->get_sale_price() ), - "tax_status" => $product->get_tax_status(), - "stock" => $product->get_stock_quantity(), - "stock_status" => $product->get_stock_status(), - "weight" => $product->get_weight(), - "discount" => $this->get_formated_amount( (float) $item->get_total() ), - "subscription" => $subscription_info, - - ); - - $subscription_info = []; - - if ( array_key_exists( $item->get_id(), $license_info ) ) { - $productInfo['license'] = $license_info[ $item->get_id() ]; + + if($product){ + $productInfo = array( + "product_id" => $product_id, + "title" => $product->get_name(), + "product_permalink" => get_permalink($product_id), + "quantity" => $item["quantity"], + "total_tax" => $this->get_formated_amount( (float) $item["total_tax"] ), + "image" => wp_get_attachment_image_src( get_post_thumbnail_id($product_id) )[0], + "type" => $product->get_type(), + "status" => $product->get_status(), + "sku" => $product->get_sku(), + "price" => $this->get_formated_amount( (float) $item["subtotal"] ), + "regular_price" => $this->get_formated_amount( (float) $product->get_regular_price() ), + "sale_price" => $this->get_formated_amount( (float) $product->get_sale_price() ), + "tax_status" => $product->get_tax_status(), + "stock" => $product->get_stock_quantity(), + "stock_status" => $product->get_stock_status(), + "weight" => $product->get_weight(), + "discount" => $this->get_formated_amount( (float) $item->get_total() ), + "subscription" => $subscription_info, + ); + + $subscription_info = []; + + if ( array_key_exists( $item->get_id(), $license_info ) ) { + $productInfo['license'] = $license_info[ $item->get_id() ]; + } } array_push( $download_item, $productInfo ); From 203ce6f27fbc6e0aaf560b009ae8fbc332e408ef Mon Sep 17 00:00:00 2001 From: pronob1010 Date: Thu, 16 May 2024 19:08:55 +0600 Subject: [PATCH 2/3] wip: readme update --- readme.txt | 5 ++++- thrivedesk.php | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/readme.txt b/readme.txt index bdee062..0f91e27 100755 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: thrivedesk Tags: helpdesk, support ticket, livechat, support plugin, ticket system chat, chatbot, knowledge base, support, help center, customer care, woocommerce, surecart, freemius, thrivedesk Requires at least: 4.9 Tested up to: 6.4 -Stable Tag: 2.0.2 +Stable Tag: 2.0.3 Requires PHP: 5.5 License: GNU General Public License v2.0 or later @@ -232,6 +232,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 == += 2.0.3 = +- Fix: WooCommerce product data missing issue + = 2.0.2 = - Update: Enhanced WooCommerce integration diff --git a/thrivedesk.php b/thrivedesk.php index 95e1490..4bb8b9b 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: 2.0.2 + * Version: 2.0.3 * Author: ThriveDesk * Author URI: https://profiles.wordpress.org/thrivedesk/ * Text Domain: thrivedesk @@ -51,7 +51,7 @@ final class ThriveDesk * * @var string */ - public $version = '2.0.2'; + public $version = '2.0.3'; /** * The single instance of this class From 967634dd30e2682017444957ba738e88201cb585 Mon Sep 17 00:00:00 2001 From: pronob1010 Date: Thu, 16 May 2024 19:10:53 +0600 Subject: [PATCH 3/3] chore: readme update --- readme.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.txt b/readme.txt index 0f91e27..631b6d5 100755 --- a/readme.txt +++ b/readme.txt @@ -234,6 +234,7 @@ Privacy is our utmost priority, and we designed ThriveDesk in a way that aligned == Changelog == = 2.0.3 = - Fix: WooCommerce product data missing issue +- Fix : FunnelKit namespace issue = 2.0.2 = - Update: Enhanced WooCommerce integration