From a4261d544c1e255e32b99aa57f2f823ab1e49bdc Mon Sep 17 00:00:00 2001 From: dkorol Date: Thu, 7 Apr 2016 15:31:04 +0300 Subject: [PATCH] bugfixes --- admin/model/retailcrm/order.php | 25 +++++++++++++------------ catalog/model/retailcrm/order.php | 14 ++++++-------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/admin/model/retailcrm/order.php b/admin/model/retailcrm/order.php index cf89d9a..808642a 100644 --- a/admin/model/retailcrm/order.php +++ b/admin/model/retailcrm/order.php @@ -18,9 +18,6 @@ class ModelRetailcrmOrder extends Model { $order = array(); - $payment_code = $order_data['payment_code']; - $delivery_code = $order_data['shipping_code']; - $customers = $this->retailcrm->customersList( array( 'name' => $order_data['telephone'], @@ -44,30 +41,34 @@ class ModelRetailcrmOrder extends Model { $order['customerComment'] = $order_data['comment']; $deliveryCost = 0; - $orderTotals = isset($order_data['totals']) ? $order_data['totals'] : $order_data['order_total'] ; + $altTotals = isset($order_data['order_total']) ? $order_data['order_total'] : ""; + $orderTotals = isset($order_data['totals']) ? $order_data['totals'] : $altTotals ; - foreach ($orderTotals as $totals) { - if ($totals['code'] == 'shipping') { - $deliveryCost = $totals['value']; + if (!empty($orderTotals)) { + foreach ($orderTotals as $totals) { + if ($totals['code'] == 'shipping') { + $deliveryCost = $totals['value']; + } } } $order['createdAt'] = date('Y-m-d H:i:s'); + + $payment_code = $order_data['payment_code']; $order['paymentType'] = $settings['retailcrm_payment'][$payment_code]; - $country = (isset($order_data['shipping_country'])) ? $order_data['shipping_country'] : '' ; - + $delivery_code = $order_data['shipping_code']; $order['delivery'] = array( 'code' => $settings['retailcrm_delivery'][$delivery_code], 'cost' => $deliveryCost, 'address' => array( 'index' => $order_data['shipping_postcode'], 'city' => $order_data['shipping_city'], - 'country' => $order_data['shipping_country_id'], - 'region' => $order_data['shipping_zone_id'], + 'countryIso' => $order_data['shipping_iso_code_2'], + 'region' => $order_data['shipping_zone'], 'text' => implode(', ', array( $order_data['shipping_postcode'], - $country, + (isset($order_data['shipping_country'])) ? $order_data['shipping_country'] : '', $order_data['shipping_city'], $order_data['shipping_address_1'], $order_data['shipping_address_2'] diff --git a/catalog/model/retailcrm/order.php b/catalog/model/retailcrm/order.php index f2df393..8cd772d 100644 --- a/catalog/model/retailcrm/order.php +++ b/catalog/model/retailcrm/order.php @@ -18,9 +18,6 @@ class ModelRetailcrmOrder extends Model { $order = array(); - $payment_code = $order_data['payment_code']; - $delivery_code = $order_data['shipping_code']; - $customers = $this->retailcrm->customersList( array( 'name' => $order_data['telephone'], @@ -56,21 +53,22 @@ class ModelRetailcrmOrder extends Model { } $order['createdAt'] = date('Y-m-d H:i:s'); + + $payment_code = $order_data['payment_code']; $order['paymentType'] = $settings['retailcrm_payment'][$payment_code]; - $country = (isset($order_data['shipping_country'])) ? $order_data['shipping_country'] : '' ; - + $delivery_code = $order_data['shipping_code']; $order['delivery'] = array( 'code' => $settings['retailcrm_delivery'][$delivery_code], 'cost' => $deliveryCost, 'address' => array( 'index' => $order_data['shipping_postcode'], 'city' => $order_data['shipping_city'], - 'country' => $order_data['shipping_country_id'], - 'region' => $order_data['shipping_zone_id'], + 'countryIso' => $order_data['shipping_iso_code_2'], + 'region' => $order_data['shipping_zone'], 'text' => implode(', ', array( $order_data['shipping_postcode'], - $country, + (isset($order_data['shipping_country'])) ? $order_data['shipping_country'] : '', $order_data['shipping_city'], $order_data['shipping_address_1'], $order_data['shipping_address_2']