Unsupported operand types at `dokan-lite/includes/Commission/Settings/OrderItem.php:74`
Closed this issue · 0 comments
hasdfa commented
Bug Description
The error log
Critical Uncaught TypeError: Unsupported operand types: string / string in /WEBSITE_ROOT/public_html/wp-content/plugins/dokan-lite/includes/Commission/Settings/OrderItem.php:74
Additional context:
{
"error": {
"type": 1,
"file": "/WEBSITE_ROOT/public_html/wp-content/plugins/dokan-lite/includes/Commission/Settings/OrderItem.php",
"line": 74
},
"remote-logging": true,
"backtrace": [
"",
"#0 /WEBSITE_ROOT/public_html/wp-content/plugins/dokan-lite/includes/Commission/Strategies/OrderItem.php(92): WeDevs\\Dokan\\Commission\\Settings\\OrderItem->get()",
"#1 /WEBSITE_ROOT/public_html/wp-content/plugins/dokan-lite/includes/Commission/Strategies/AbstractStrategy.php(37): WeDevs\\Dokan\\Commission\\Strategies\\OrderItem->get_settings()",
"#2 /WEBSITE_ROOT/public_html/wp-content/plugins/dokan-lite/includes/Commission/Calculator.php(58): WeDevs\\Dokan\\Commission\\Strategies\\AbstractStrategy->create_formula()",
"#3 /WEBSITE_ROOT/public_html/wp-content/plugins/dokan-lite/includes/Commission.php(611): WeDevs\\Dokan\\Commission\\Calculator->calculate_commission('180', 1)",
"#4 /WEBSITE_ROOT/public_html/wp-content/plugins/dokan-lite/templates/orders/commission-meta-box-html.php(79): WeDevs\\Dokan\\Commission->get_commission(Array)",
"#5 /WEBSITE_ROOT/public_html/wp-content/plugins/dokan-lite/includes/functions.php(836): include('/home/customer/...')",
"#6 /WEBSITE_ROOT/public_html/wp-content/plugins/dokan-lite/includes/Order/Admin/Hooks.php(604): dokan_get_template_part('orders/commissi...', '', Array)",
"#7 /WEBSITE_ROOT/public_html/wp-admin/includes/template.php(1456): WeDevs\\Dokan\\Order\\Admin\\Hooks->commission_meta_box(Object(WP_Post), Array)",
"#8 /WEBSITE_ROOT/public_html/wp-admin/edit-form-advanced.php(722): do_meta_boxes(Object(WP_Screen), 'normal', Object(WP_Post))",
"#9 /WEBSITE_ROOT/public_html/wp-admin/post.php(206): require('/home/customer/...')",
"#10 {main}",
"thrown"
]
}
Step To Reproduce
Go to refund requests by vendors and try to approve it
Expected Behaviour
Everything works fine
Actual Behaviour
Critical Uncaught TypeError: Unsupported operand types: string / string
Additional Information
The patch we've done that worked
diff --git a/includes/Commission/Settings/OrderItem.php b/includes/Commission/Settings/OrderItem.php
index e3ee631c..c239927f 100644
--- a/includes/Commission/Settings/OrderItem.php
+++ b/includes/Commission/Settings/OrderItem.php
@@ -64,9 +64,9 @@ class OrderItem implements InterfaceSetting {
if ( $order_id && OrderUtil::is_hpos_enabled() ) {
$order = dokan()->order->get( $order_id );
- $item_total = $order->get_meta( '_dokan_item_total' );
+ $item_total = (float) $order->get_meta( '_dokan_item_total' );
} else {
- $item_total = get_post_meta( $order_id, '_dokan_item_total', true );
+ $item_total = (float) get_post_meta( $order_id, '_dokan_item_total', true );
}
$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 = ( ((float) $additional_flat) / $item_total ) * $product_price;
}
Environment (please complete the following information)
1. Dokan Version: v3.14.3
2. Dokan Pro Version: v3.14.1
3. WooCommerce Version: v9.5.1
4. Browser: Chrome (Chromium Engine Version 131.0.6778.140)
5. Current Theme: Storefront
6. WordPress version 6.7.1
7. PHP version 8.2.26