From 8f18519811e26f9a05a2cc46d922d642707cd26e Mon Sep 17 00:00:00 2001 From: osman sufy Date: Tue, 17 Dec 2024 12:36:55 +0600 Subject: [PATCH 1/4] fix: fetal error when admin commission additional fee is empty --- includes/Commission/Settings/OrderItem.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/Commission/Settings/OrderItem.php b/includes/Commission/Settings/OrderItem.php index e3ee631cea..a2f0f12836 100644 --- a/includes/Commission/Settings/OrderItem.php +++ b/includes/Commission/Settings/OrderItem.php @@ -71,7 +71,8 @@ public function get(): Setting { $product_price = (float) wc_format_decimal( $this->product_price_to_calculate_commission ); if ( $order_id && $item_total ) { - $additional_flat = ( $additional_flat / $item_total ) * $product_price; + $empty_safe_additional_flat = empty( $additional_flat ) ? 0 : $additional_flat; + $additional_flat = ( $empty_safe_additional_flat / $item_total ) * $product_price; } $settings = new Setting(); From 7531b43f1e0485f118ee008b15290f4fc5eb3079 Mon Sep 17 00:00:00 2001 From: osman sufy Date: Thu, 19 Dec 2024 14:51:42 +0600 Subject: [PATCH 2/4] update: convert empty string to float procedure --- includes/Commission/Settings/OrderItem.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/includes/Commission/Settings/OrderItem.php b/includes/Commission/Settings/OrderItem.php index a2f0f12836..bbb4f42728 100644 --- a/includes/Commission/Settings/OrderItem.php +++ b/includes/Commission/Settings/OrderItem.php @@ -71,8 +71,7 @@ public function get(): Setting { $product_price = (float) wc_format_decimal( $this->product_price_to_calculate_commission ); if ( $order_id && $item_total ) { - $empty_safe_additional_flat = empty( $additional_flat ) ? 0 : $additional_flat; - $additional_flat = ( $empty_safe_additional_flat / $item_total ) * $product_price; + $additional_flat = ( floatval( $additional_flat ) / $item_total ) * $product_price; } $settings = new Setting(); From 3758043996810830d6668223ba20921285b25323 Mon Sep 17 00:00:00 2001 From: osman sufy Date: Thu, 19 Dec 2024 17:57:42 +0600 Subject: [PATCH 3/4] update: hpos enabled check remove & $item_total less than 0 --- includes/Commission/Settings/OrderItem.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/includes/Commission/Settings/OrderItem.php b/includes/Commission/Settings/OrderItem.php index bbb4f42728..e3cfe2e454 100644 --- a/includes/Commission/Settings/OrderItem.php +++ b/includes/Commission/Settings/OrderItem.php @@ -62,15 +62,13 @@ public function get(): Setting { */ $order_id = wc_get_order_id_by_order_item_id( $this->order_item_id ); - if ( $order_id && OrderUtil::is_hpos_enabled() ) { + if ( $order_id ) { $order = dokan()->order->get( $order_id ); - $item_total = $order->get_meta( '_dokan_item_total' ); - } else { - $item_total = get_post_meta( $order_id, '_dokan_item_total', true ); + $item_total = floatval( $order->get_meta( '_dokan_item_total' ) ); } $product_price = (float) wc_format_decimal( $this->product_price_to_calculate_commission ); - if ( $order_id && $item_total ) { + if ( $order_id && $item_total > 0 ) { $additional_flat = ( floatval( $additional_flat ) / $item_total ) * $product_price; } From a66507dc2efa4518782c74f5587708ff4e6a3ba4 Mon Sep 17 00:00:00 2001 From: Osman Goni Sufy <47870515+osmansufy@users.noreply.github.com> Date: Fri, 27 Dec 2024 10:26:22 +0600 Subject: [PATCH 4/4] update : false check item_total value --- includes/Commission/Settings/OrderItem.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Commission/Settings/OrderItem.php b/includes/Commission/Settings/OrderItem.php index e3cfe2e454..96089d9496 100644 --- a/includes/Commission/Settings/OrderItem.php +++ b/includes/Commission/Settings/OrderItem.php @@ -68,7 +68,7 @@ public function get(): Setting { } $product_price = (float) wc_format_decimal( $this->product_price_to_calculate_commission ); - if ( $order_id && $item_total > 0 ) { + if ( $order_id && $item_total ) { $additional_flat = ( floatval( $additional_flat ) / $item_total ) * $product_price; }