From b946c43db7ff7a0d6055ed496dc7e9d25499a5f7 Mon Sep 17 00:00:00 2001 From: gonzalo Date: Mon, 18 Mar 2024 10:10:48 -0300 Subject: [PATCH] closes #1921 for magento 2.1 --- Model/Api/Order.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Model/Api/Order.php b/Model/Api/Order.php index 1ffb6a1c..77d23dbc 100644 --- a/Model/Api/Order.php +++ b/Model/Api/Order.php @@ -398,7 +398,7 @@ protected function GeneratePOSTPayload(\Magento\Sales\Model\Order $order, $mailc } else { $data['order_total'] = $order->getGrandTotal(); $data['tax_total'] = $order->getTaxAmount(); - $data['discount_total'] = abs($order->getDiscountAmount()); + $data['discount_total'] =$order->getDiscountAmount() ? abs($order->getDiscountAmount()) : 0; $data['shipping_total'] = $order->getShippingAmount(); } @@ -452,7 +452,7 @@ protected function GeneratePOSTPayload(\Magento\Sales\Model\Order $order, $mailc "product_variant_id" => $variant, "quantity" => (int)$item->getQtyOrdered(), "price" => $item->getPrice(), - "discount" => abs($item->getDiscountAmount()) + "discount" => $item->getDiscountAmount() ? abs($item->getDiscountAmount()) : 0 ]; } } @@ -718,7 +718,7 @@ protected function _getPromoData(\Magento\Sales\Model\Order $order) if ($code->getCouponId() !== null) { $rule = $this->ruleRepository->getById($code->getRuleId()); if ($rule->getRuleId() !== null) { - $amountDiscounted = $order->getBaseDiscountAmount(); + $amountDiscounted = $order->getBaseDiscountAmount() ? $order->getBaseDiscountAmount() : 0; $type = $rule->getSimpleAction(); if ($type == 'by_percent') { $type = 'percentage';