mirror of
https://github.com/retailcrm/opencart-module.git
synced 2024-11-24 14:16:07 +03:00
Merge pull request #116 from iyzoer/v2.2
Добавлена передача внешнего кода клиента при создании заказа
This commit is contained in:
commit
6ba09d3ac5
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
.env
|
||||||
|
bin/
|
||||||
|
vendor/
|
||||||
|
www/
|
@ -4,12 +4,12 @@ class ModelRetailcrmOrder extends Model {
|
|||||||
|
|
||||||
public function sendToCrm($order_data, $order_id)
|
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');
|
$this->load->model('setting/setting');
|
||||||
$settings = $this->model_setting_setting->getSetting('retailcrm');
|
$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');
|
$this->load->model('catalog/product');
|
||||||
|
|
||||||
require_once DIR_SYSTEM . 'library/retailcrm/bootstrap.php';
|
require_once DIR_SYSTEM . 'library/retailcrm/bootstrap.php';
|
||||||
@ -22,6 +22,9 @@ class ModelRetailcrmOrder extends Model {
|
|||||||
|
|
||||||
$order = array();
|
$order = array();
|
||||||
|
|
||||||
|
if ($order_data['customer_id']) {
|
||||||
|
$order['customer']['externalId'] = $order_data['customer_id'];
|
||||||
|
} else {
|
||||||
$customers = $this->retailcrm->customersList(
|
$customers = $this->retailcrm->customersList(
|
||||||
array(
|
array(
|
||||||
'name' => $order_data['telephone'],
|
'name' => $order_data['telephone'],
|
||||||
@ -31,13 +34,14 @@ class ModelRetailcrmOrder extends Model {
|
|||||||
100
|
100
|
||||||
);
|
);
|
||||||
|
|
||||||
if($customers) {
|
if ($customers) {
|
||||||
foreach ($customers['customers'] as $customer) {
|
foreach ($customers['customers'] as $customer) {
|
||||||
$order['customer']['id'] = $customer['id'];
|
$order['customer']['id'] = $customer['id'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($customers);
|
unset($customers);
|
||||||
|
}
|
||||||
|
|
||||||
$order['externalId'] = $order_id;
|
$order['externalId'] = $order_id;
|
||||||
$order['firstName'] = $order_data['firstname'];
|
$order['firstName'] = $order_data['firstname'];
|
||||||
|
Loading…
Reference in New Issue
Block a user