Merge pull request #116 from iyzoer/v2.2

Добавлена передача внешнего кода клиента при создании заказа
This commit is contained in:
Alex Lushpai 2018-09-28 17:50:52 +03:00 committed by GitHub
commit 6ba09d3ac5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 15 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
.env
bin/
vendor/
www/

View File

@ -4,12 +4,12 @@ class ModelRetailcrmOrder extends Model {
public function sendToCrm($order_data, $order_id)
{
if(isset($this->request->post['fromApi'])) return;
if (isset($this->request->post['fromApi'])) return;
$this->load->model('setting/setting');
$settings = $this->model_setting_setting->getSetting('retailcrm');
if(!empty($settings['retailcrm_url']) && !empty($settings['retailcrm_apikey'])) {
if (!empty($settings['retailcrm_url']) && !empty($settings['retailcrm_apikey'])) {
$this->load->model('catalog/product');
require_once DIR_SYSTEM . 'library/retailcrm/bootstrap.php';
@ -22,6 +22,9 @@ class ModelRetailcrmOrder extends Model {
$order = array();
if ($order_data['customer_id']) {
$order['customer']['externalId'] = $order_data['customer_id'];
} else {
$customers = $this->retailcrm->customersList(
array(
'name' => $order_data['telephone'],
@ -31,13 +34,14 @@ class ModelRetailcrmOrder extends Model {
100
);
if($customers) {
if ($customers) {
foreach ($customers['customers'] as $customer) {
$order['customer']['id'] = $customer['id'];
}
}
unset($customers);
}
$order['externalId'] = $order_id;
$order['firstName'] = $order_data['firstname'];