mirror of
https://github.com/retailcrm/prestashop-module.git
synced 2025-03-02 19:33: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])) {
|
if (isset($payment[$paymentType]) && !empty($payment[$paymentType])) {
|
||||||
$order_payment = array(
|
$order_payment = array(
|
||||||
'externalId' => $order->id . '#' . $order->reference,
|
'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]
|
'type' => $payment[$paymentType]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -940,13 +941,13 @@ class RetailcrmOrderBuilder
|
|||||||
$crmOrder['discountManualAmount'] = round($order->total_discounts, 2);
|
$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);
|
$crmOrder['delivery']['cost'] = round($totalShipping, 2);
|
||||||
} else {
|
} else {
|
||||||
$crmOrder['delivery']['cost'] = 0.00;
|
$crmOrder['delivery']['cost'] = 0.00;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($totalShippingWithoutTax) && $totalShippingWithoutTax > 0) {
|
if (isset($totalShippingWithoutTax) && round($totalShippingWithoutTax, 2) > 0) {
|
||||||
$crmOrder['delivery']['netCost'] = round($totalShippingWithoutTax, 2);
|
$crmOrder['delivery']['netCost'] = round($totalShippingWithoutTax, 2);
|
||||||
} else {
|
} else {
|
||||||
$crmOrder['delivery']['netCost'] = 0.00;
|
$crmOrder['delivery']['netCost'] = 0.00;
|
||||||
|
@ -665,9 +665,24 @@ class RetailCRM extends Module
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$externalId = false;
|
||||||
|
|
||||||
$response = $this->api->ordersGet(RetailcrmTools::getCartOrderExternalId($params['cart']));
|
$response = $this->api->ordersGet(RetailcrmTools::getCartOrderExternalId($params['cart']));
|
||||||
|
|
||||||
if ($response !== false && isset($response['order'])) {
|
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'];
|
$orderCRM = $response['order'];
|
||||||
|
|
||||||
if ($orderCRM && $orderCRM['payments']) {
|
if ($orderCRM && $orderCRM['payments']) {
|
||||||
@ -676,24 +691,22 @@ class RetailCRM extends Module
|
|||||||
$updatePayment = $orderPayment;
|
$updatePayment = $orderPayment;
|
||||||
$updatePayment['amount'] = $params['paymentCC']->amount;
|
$updatePayment['amount'] = $params['paymentCC']->amount;
|
||||||
$updatePayment['paidAt'] = $params['paymentCC']->date_add;
|
$updatePayment['paidAt'] = $params['paymentCC']->date_add;
|
||||||
if ($params['paymentCC']->amount == $orderCRM['totalSumm']) {
|
$updatePayment['status'] = $status;
|
||||||
$updatePayment['status'] = 'paid';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($updatePayment)) {
|
if (isset($updatePayment)) {
|
||||||
$this->api->ordersPaymentEdit($updatePayment);
|
$this->api->ordersPaymentEdit($updatePayment, 'id');
|
||||||
} else {
|
} else {
|
||||||
$createPayment = array(
|
$createPayment = array(
|
||||||
'externalId' => $params['paymentCC']->id,
|
'externalId' => $params['paymentCC']->id,
|
||||||
'amount' => $params['paymentCC']->amount,
|
'amount' => $params['paymentCC']->amount,
|
||||||
'paidAt' => $params['paymentCC']->date_add,
|
'paidAt' => $params['paymentCC']->date_add,
|
||||||
'type' => $payment,
|
'type' => $payment,
|
||||||
'status' => 'paid',
|
'status' => $status,
|
||||||
'order' => array(
|
'order' => array(
|
||||||
'externalId' => RetailcrmTools::getCartOrderExternalId($params['cart']),
|
'externalId' => $externalId,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user