From c9303df5ac2ccfa3457d581a6a09b4a307b53345 Mon Sep 17 00:00:00 2001 From: dholly Date: Fri, 15 May 2026 21:08:56 +0700 Subject: [PATCH] 'discounts' --- inc/class-zoho.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/inc/class-zoho.php b/inc/class-zoho.php index b322259..ed404e7 100644 --- a/inc/class-zoho.php +++ b/inc/class-zoho.php @@ -283,6 +283,27 @@ class WZHF_Zoho { 'line_items'=>$lines, 'notes'=>'WC Order #'.$order->get_order_number() ); + + // передаем скидку в зохо + $discount_amount = (float)$order->get_total_discount(); // сумма купонов без налога + if ($discount_amount > 0) { + $body['discount'] = $discount_amount; + $body['discount_type'] = 'entity_level'; + $body['is_discount_before_tax'] = true; + + // купоны в заметки + $coupon_codes = method_exists($order, 'get_coupon_codes') ? $order->get_coupon_codes() : array(); + if (!empty($coupon_codes)) { + $body['notes'] .= ' | Coupons: ' . implode(', ', $coupon_codes); + } + + WZHF_Logger::log('SO create:discount-applied', array( + 'order_id' => $order->get_id(), + 'discount' => $discount_amount, + 'coupons' => $coupon_codes + )); + } + error_log('=====LOG START====='); error_log(json_encode($body)); error_log('=====LOG END====='); @@ -290,4 +311,4 @@ class WZHF_Zoho { if(!$res || empty($res['salesorder'])) return array(null, ($err ? $err : 'unknown')); return array($res['salesorder'],null); } -} +} \ No newline at end of file