Fixed error in abandoned carts for PS below 1.7.1 version

This commit is contained in:
max-baranikov 2021-04-05 14:30:03 +03:00 committed by GitHub
parent f4984faa43
commit 520149394e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -675,12 +675,16 @@ class RetailCRM extends Module
if ($response !== false && isset($response['order'])) {
$externalId = RetailcrmTools::getCartOrderExternalId($params['cart']);
} else {
$order = Order::getByCartId($params['cart']->id);
if (version_compare(_PS_VERSION_, '1.7.1.0', '>=')) {
$id_order = (int)Order::getIdByCartId((int)$params['cart']->id);
} else {
$id_order = (int)Order::getOrderByCartId((int)$params['cart']->id);
}
if($order !== null) {
$response = $this->api->ordersGet($order->id);
if ($id_order > 0) {
$response = $this->api->ordersGet($id_order);
if ($response !== false && isset($response['order'])) {
$externalId = $order->id;
$externalId = $id_order;
}
}
}