From 14795c351e523947dcfdaf5b91cd540133af2fa4 Mon Sep 17 00:00:00 2001 From: Alex Lushpai Date: Thu, 28 Aug 2014 18:39:02 +0400 Subject: [PATCH] fix paths, fix data format, change code injection path, update docs --- catalog/{ => model}/intarocrm/order.php | 0 doc/Install.md | 8 +++---- system/library/intarocrm/apihelper.php | 28 +++++++++++++------------ system/library/intarocrm/composer.json | 2 +- 4 files changed, 19 insertions(+), 19 deletions(-) rename catalog/{ => model}/intarocrm/order.php (100%) diff --git a/catalog/intarocrm/order.php b/catalog/model/intarocrm/order.php similarity index 100% rename from catalog/intarocrm/order.php rename to catalog/model/intarocrm/order.php diff --git a/doc/Install.md b/doc/Install.md index 5c726bb..2b6f59a 100644 --- a/doc/Install.md +++ b/doc/Install.md @@ -46,11 +46,9 @@ $this->load->model('intarocrm/order'); $this->model_intarocrm_order->send($data, $order_id); ``` -Add this lines into /catalog/model/checkout/order.php script, into addOrder method before return statement and -into /admin/model/sale/order.php script, into addOrder & editOrder methods at the end of these methods - - - +Add this lines into: +* /catalog/controller/checkout/confirm.php script, into index method before setOutput call +* /admin/model/sale/order.php script, into addOrder & editOrder methods at the end of these methods #### Export new order from CRM to shop diff --git a/system/library/intarocrm/apihelper.php b/system/library/intarocrm/apihelper.php index 327426c..47a7fb1 100644 --- a/system/library/intarocrm/apihelper.php +++ b/system/library/intarocrm/apihelper.php @@ -52,7 +52,7 @@ class ApiHelper $customer['firstName'] = $data['firstname']; $customer['lastName'] = $data['lastname']; $customer['email'] = $data['email']; - $customer['phones']['number'] = $data['telephone']; + $customer['phones'] = array(array('number' => $data['telephone'])); $customer['address']['text'] = implode(', ', array( $data['payment_postcode'], @@ -63,15 +63,18 @@ class ApiHelper )); try { - $this->intaroApi->customerEdit($customer); + $this->customer = $this->intaroApi->customerEdit($customer); } catch (IntaroCrm\Exception\ApiException $e) { + $this->customer = $e->getMessage(); $this->log->addError('['.$this->domain.'] RestApi::orderCreate:' . $e->getMessage()); $this->log->addError('['.$this->domain.'] RestApi::orderCreate:' . json_encode($order)); } catch (IntaroCrm\Exception\CurlException $e) { + $this->customer = $e->getMessage(); $this->log->addError('['.$this->domain.'] RestApi::orderCreate::Curl:' . $e->getMessage()); } } + unset($customer); unset($customers); $order['externalId'] = $data['order_id']; @@ -81,27 +84,26 @@ class ApiHelper $order['phone'] = $data['telephone']; $order['customerComment'] = $data['comment']; - $order['deliveryCost'] = 0; + $deliveryCost = 0; foreach ($data['totals'] as $totals) { if ($totals['code'] == 'shipping') { - $order['deliveryCost'] = $totals['value']; + $deliveryCost = $totals['value']; } } - $order['deliveryAddress']['text'] = implode(', ', array( - $data['shipping_postcode'], - $data['shipping_country'], - $data['shipping_city'], - $data['shipping_address_1'], - $data['shipping_address_2'] - )); - $order['createdAt'] = date('Y-m-d H:i:s'); $order['paymentType'] = $settings['intarocrm_payment'][$payment_code]; $order['delivery'] = array( 'code' => $settings['intarocrm_delivery'][$delivery_code], - 'cost' => $order['deliveryCost'] + 'cost' => $deliveryCost, + 'address' => array('text' => implode(', ', array( + $data['shipping_postcode'], + $data['shipping_country'], + $data['shipping_city'], + $data['shipping_address_1'], + $data['shipping_address_2'] + ))) ); diff --git a/system/library/intarocrm/composer.json b/system/library/intarocrm/composer.json index 202739e..855f512 100644 --- a/system/library/intarocrm/composer.json +++ b/system/library/intarocrm/composer.json @@ -16,7 +16,7 @@ }, "require": { "php": ">=5.3", - "intarocrm/rest-api-client": "1.2.*", + "intarocrm/rest-api-client": "1.3.*", "symfony/console": "dev-master", "monolog/monolog": "dev-master" },