opencart-module/catalog/controller/module/retailcrm.php

46 lines
1.3 KiB
PHP
Raw Normal View History

2016-03-10 02:07:25 +03:00
<?php
/**
* Class ControllerModule
*
* @category RetailCrm
* @package RetailCrm
* @author RetailCrm <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion3
*/
class ControllerModuleRetailcrm extends Controller
{
/**
* Create order on event
*
* @param int $order_id order identificator
*
* @return void
*/
public function order_create($order_id)
{
$this->load->model('checkout/order');
$this->load->model('account/order');
$data = $this->model_checkout_order->getOrder($order_id);
$data['products'] = $this->model_account_order->getOrderProducts($order_id);
if (!isset($data['fromApi'])) {
$this->load->model('setting/setting');
$status = $this->model_setting_setting->getSetting('retailcrm');
2016-03-11 14:15:24 +03:00
if ($data['order_status_id'] > 0) {
$data['order_status'] = $status['retailcrm_status'][$data['order_status_id']];
}
2016-03-10 02:07:25 +03:00
2016-03-14 22:26:42 +03:00
$data['totals'][] = array(
'code' => 'shipping',
'value' => $this->session->data['shipping_method']['cost']
);
2016-03-10 02:07:25 +03:00
$this->load->model('retailcrm/order');
2016-03-11 14:15:24 +03:00
$this->model_retailcrm_order->sendToCrm($data, $data['order_id']);
2016-03-10 02:07:25 +03:00
}
}
}