'discounts'
This commit is contained in:
@@ -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=====');
|
||||
|
||||
Reference in New Issue
Block a user