This commit is contained in:
dkorol 2016-04-07 15:31:04 +03:00
parent 7cceb9852c
commit a4261d544c
2 changed files with 19 additions and 20 deletions

View File

@ -18,9 +18,6 @@ class ModelRetailcrmOrder extends Model {
$order = array(); $order = array();
$payment_code = $order_data['payment_code'];
$delivery_code = $order_data['shipping_code'];
$customers = $this->retailcrm->customersList( $customers = $this->retailcrm->customersList(
array( array(
'name' => $order_data['telephone'], 'name' => $order_data['telephone'],
@ -44,30 +41,34 @@ class ModelRetailcrmOrder extends Model {
$order['customerComment'] = $order_data['comment']; $order['customerComment'] = $order_data['comment'];
$deliveryCost = 0; $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 ;
if (!empty($orderTotals)) {
foreach ($orderTotals as $totals) { foreach ($orderTotals as $totals) {
if ($totals['code'] == 'shipping') { if ($totals['code'] == 'shipping') {
$deliveryCost = $totals['value']; $deliveryCost = $totals['value'];
} }
} }
}
$order['createdAt'] = date('Y-m-d H:i:s'); $order['createdAt'] = date('Y-m-d H:i:s');
$payment_code = $order_data['payment_code'];
$order['paymentType'] = $settings['retailcrm_payment'][$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( $order['delivery'] = array(
'code' => $settings['retailcrm_delivery'][$delivery_code], 'code' => $settings['retailcrm_delivery'][$delivery_code],
'cost' => $deliveryCost, 'cost' => $deliveryCost,
'address' => array( 'address' => array(
'index' => $order_data['shipping_postcode'], 'index' => $order_data['shipping_postcode'],
'city' => $order_data['shipping_city'], 'city' => $order_data['shipping_city'],
'country' => $order_data['shipping_country_id'], 'countryIso' => $order_data['shipping_iso_code_2'],
'region' => $order_data['shipping_zone_id'], 'region' => $order_data['shipping_zone'],
'text' => implode(', ', array( 'text' => implode(', ', array(
$order_data['shipping_postcode'], $order_data['shipping_postcode'],
$country, (isset($order_data['shipping_country'])) ? $order_data['shipping_country'] : '',
$order_data['shipping_city'], $order_data['shipping_city'],
$order_data['shipping_address_1'], $order_data['shipping_address_1'],
$order_data['shipping_address_2'] $order_data['shipping_address_2']

View File

@ -18,9 +18,6 @@ class ModelRetailcrmOrder extends Model {
$order = array(); $order = array();
$payment_code = $order_data['payment_code'];
$delivery_code = $order_data['shipping_code'];
$customers = $this->retailcrm->customersList( $customers = $this->retailcrm->customersList(
array( array(
'name' => $order_data['telephone'], 'name' => $order_data['telephone'],
@ -56,21 +53,22 @@ class ModelRetailcrmOrder extends Model {
} }
$order['createdAt'] = date('Y-m-d H:i:s'); $order['createdAt'] = date('Y-m-d H:i:s');
$payment_code = $order_data['payment_code'];
$order['paymentType'] = $settings['retailcrm_payment'][$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( $order['delivery'] = array(
'code' => $settings['retailcrm_delivery'][$delivery_code], 'code' => $settings['retailcrm_delivery'][$delivery_code],
'cost' => $deliveryCost, 'cost' => $deliveryCost,
'address' => array( 'address' => array(
'index' => $order_data['shipping_postcode'], 'index' => $order_data['shipping_postcode'],
'city' => $order_data['shipping_city'], 'city' => $order_data['shipping_city'],
'country' => $order_data['shipping_country_id'], 'countryIso' => $order_data['shipping_iso_code_2'],
'region' => $order_data['shipping_zone_id'], 'region' => $order_data['shipping_zone'],
'text' => implode(', ', array( 'text' => implode(', ', array(
$order_data['shipping_postcode'], $order_data['shipping_postcode'],
$country, (isset($order_data['shipping_country'])) ? $order_data['shipping_country'] : '',
$order_data['shipping_city'], $order_data['shipping_city'],
$order_data['shipping_address_1'], $order_data['shipping_address_1'],
$order_data['shipping_address_2'] $order_data['shipping_address_2']