fix(2meet-data-optimizer-woocommerce-addon): record no negative commission for a fully refunded taxed order

- the amounts follow Marketplace::get_order_profit() (what the vendor is
  paid), which subtracts the full order tax after refunds; a fully refunded
  taxed order came out at subtotal = commission = -tax. The subtotal is now
  floored at 0 (security review M2); partial refunds keep matching what
  Marketplace pays
- Verify: WCOrdersInterceptorTest (full refund with tax), integration 28, unit 11, phpcs
- PR: PR-112 (2.3 acceptance security review)
This commit is contained in:
2026-09-27 17:23:16 +08:00
parent 22afabc649
commit c2bd02e9ec
2 changed files with 21 additions and 0 deletions
@@ -149,6 +149,10 @@ class TMDO_WC_Orders_Interceptor extends TMDO_Interceptor_Base {
if ( ! get_option( 'hp_vendor_include_taxes' ) ) {
$subtotal -= (float) $order->get_total_tax();
}
// Marketplace subtracts the full tax even after a refund; a fully
// refunded taxed order would otherwise record a negative amount.
$subtotal = max( 0.0, $subtotal );
$vendor_payout = max( 0.0, $subtotal * $vendor_share - $fee );
$commission = $subtotal - $vendor_payout;
$commission_rate = round( ( 1 - $vendor_share ) * 100, 2 ); // Platform percentage, as set in Marketplace.