mirror of
https://github.com/retailcrm/prestashop-module.git
synced 2025-03-01 19:03:14 +03:00
Added payment status on order upload and payment add hooks. Fixed payment edit. Fixed delivery cost
This commit is contained in:
parent
1b1fa46707
commit
3c032aa171
@ -899,7 +899,8 @@ class RetailcrmOrderBuilder
|
||||
if (isset($payment[$paymentType]) && !empty($payment[$paymentType])) {
|
||||
$order_payment = array(
|
||||
'externalId' => $order->id . '#' . $order->reference,
|
||||
'amount' => round($order->total_paid, 2),
|
||||
'amount' => round($order->total_paid_real, 2),
|
||||
'status' => ((round($order->total_paid_real, 2) > 0) ? 'paid' : null),
|
||||
'type' => $payment[$paymentType]
|
||||
);
|
||||
}
|
||||
@ -940,13 +941,13 @@ class RetailcrmOrderBuilder
|
||||
$crmOrder['discountManualAmount'] = round($order->total_discounts, 2);
|
||||
}
|
||||
|
||||
if (isset($totalShipping) && ((int)$totalShipping) > 0) {
|
||||
if (isset($totalShipping) && round($totalShipping, 2) > 0) {
|
||||
$crmOrder['delivery']['cost'] = round($totalShipping, 2);
|
||||
} else {
|
||||
$crmOrder['delivery']['cost'] = 0.00;
|
||||
}
|
||||
|
||||
if (isset($totalShippingWithoutTax) && $totalShippingWithoutTax > 0) {
|
||||
if (isset($totalShippingWithoutTax) && round($totalShippingWithoutTax, 2) > 0) {
|
||||
$crmOrder['delivery']['netCost'] = round($totalShippingWithoutTax, 2);
|
||||
} else {
|
||||
$crmOrder['delivery']['netCost'] = 0.00;
|
||||
|
@ -665,9 +665,24 @@ class RetailCRM extends Module
|
||||
return false;
|
||||
}
|
||||
|
||||
$externalId = false;
|
||||
|
||||
$response = $this->api->ordersGet(RetailcrmTools::getCartOrderExternalId($params['cart']));
|
||||
|
||||
if ($response !== false && isset($response['order'])) {
|
||||
$externalId = RetailcrmTools::getCartOrderExternalId($params['cart']);
|
||||
} else {
|
||||
$order = Order::getByCartId($params['cart']->id);
|
||||
|
||||
$response = $this->api->ordersGet($order->id);
|
||||
if ($response !== false && isset($response['order'])) {
|
||||
$externalId = $order->id;
|
||||
}
|
||||
}
|
||||
|
||||
$status = (round($params['paymentCC']->amount, 2) > 0 ? 'paid' : null);
|
||||
|
||||
if ($externalId !== false) {
|
||||
$orderCRM = $response['order'];
|
||||
|
||||
if ($orderCRM && $orderCRM['payments']) {
|
||||
@ -676,24 +691,22 @@ class RetailCRM extends Module
|
||||
$updatePayment = $orderPayment;
|
||||
$updatePayment['amount'] = $params['paymentCC']->amount;
|
||||
$updatePayment['paidAt'] = $params['paymentCC']->date_add;
|
||||
if ($params['paymentCC']->amount == $orderCRM['totalSumm']) {
|
||||
$updatePayment['status'] = 'paid';
|
||||
}
|
||||
$updatePayment['status'] = $status;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($updatePayment)) {
|
||||
$this->api->ordersPaymentEdit($updatePayment);
|
||||
$this->api->ordersPaymentEdit($updatePayment, 'id');
|
||||
} else {
|
||||
$createPayment = array(
|
||||
'externalId' => $params['paymentCC']->id,
|
||||
'amount' => $params['paymentCC']->amount,
|
||||
'paidAt' => $params['paymentCC']->date_add,
|
||||
'type' => $payment,
|
||||
'status' => 'paid',
|
||||
'status' => $status,
|
||||
'order' => array(
|
||||
'externalId' => RetailcrmTools::getCartOrderExternalId($params['cart']),
|
||||
'externalId' => $externalId,
|
||||
),
|
||||
);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user