Skip to content

Commit

Permalink
Error on approved refund request when empty Commission _dokan_additio…
Browse files Browse the repository at this point in the history
…nal_fee #4018 (#2485)

* fix: fetal error when admin commission additional fee is empty

* update: convert empty string to float procedure

* update: hpos enabled check remove & $item_total less than 0

* update : false check item_total value
  • Loading branch information
osmansufy authored Dec 27, 2024
1 parent 5743350 commit 2e2adeb
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions includes/Commission/Settings/OrderItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,14 @@ 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 ) {
$additional_flat = ( $additional_flat / $item_total ) * $product_price;
$additional_flat = ( floatval( $additional_flat ) / $item_total ) * $product_price;
}

$settings = new Setting();
Expand Down

0 comments on commit 2e2adeb

Please sign in to comment.