mirror of
https://github.com/retailcrm/opencart-module.git
synced 2025-04-10 12:41:05 +00:00
removed opencart 2+ compatibility
This commit is contained in:
parent
185d28f2b6
commit
4a5bb38866
7 changed files with 25 additions and 564 deletions
|
@ -27,24 +27,6 @@ class ControllerModuleRetailcrm extends Controller
|
|||
$this->load->model('setting/setting');
|
||||
$this->model_setting_setting
|
||||
->editSetting('retailcrm', array('retailcrm_status' => 1));
|
||||
|
||||
if (version_compare(VERSION, '2.0.1.0', '>')) {
|
||||
$this->load->model('extension/event');
|
||||
|
||||
$this->model_extension_event
|
||||
->addEvent(
|
||||
'retailcrm',
|
||||
'post.order.add',
|
||||
'module/retailcrm/order_create'
|
||||
);
|
||||
|
||||
$this->model_extension_event
|
||||
->addEvent(
|
||||
'retailcrm',
|
||||
'post.order.history.add',
|
||||
'module/retailcrm/order_edit'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -57,11 +39,6 @@ class ControllerModuleRetailcrm extends Controller
|
|||
$this->load->model('setting/setting');
|
||||
$this->model_setting_setting
|
||||
->editSetting('retailcrm', array('retailcrm_status' => 0));
|
||||
|
||||
if (version_compare(VERSION, '2.0.1.0', '>')) {
|
||||
$this->load->model('extension/event');
|
||||
$this->model_extension_event->deleteEvent('retailcrm');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -73,9 +50,6 @@ class ControllerModuleRetailcrm extends Controller
|
|||
{
|
||||
|
||||
$this->load->model('setting/setting');
|
||||
if (version_compare(VERSION, '2.0.1.0', '>')) {
|
||||
$this->load->model('extension/module');
|
||||
}
|
||||
$this->load->model('retailcrm/references');
|
||||
$this->load->language('module/retailcrm');
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
@ -93,11 +67,7 @@ class ControllerModuleRetailcrm extends Controller
|
|||
'SSL'
|
||||
);
|
||||
|
||||
if (version_compare(VERSION, '2.0.1.0', '<')) {
|
||||
$this->redirect($redirect);
|
||||
} else {
|
||||
$this->response->redirect($redirect);
|
||||
}
|
||||
$this->redirect($redirect);
|
||||
}
|
||||
|
||||
$text_strings = array(
|
||||
|
@ -117,13 +87,9 @@ class ControllerModuleRetailcrm extends Controller
|
|||
'retailcrm_dict_payment',
|
||||
);
|
||||
|
||||
if (version_compare(VERSION, '2.0.1.0', '<')) {
|
||||
$_data = &$this->data;
|
||||
$this->load->model('setting/extension');
|
||||
} else {
|
||||
$this->load->model('extension/extension');
|
||||
$_data = &$data;
|
||||
}
|
||||
|
||||
$_data = &$this->data;
|
||||
$this->load->model('setting/extension');
|
||||
|
||||
foreach ($text_strings as $text) {
|
||||
$_data[$text] = $this->language->get($text);
|
||||
|
@ -225,23 +191,13 @@ class ControllerModuleRetailcrm extends Controller
|
|||
$this->load->model('design/layout');
|
||||
$_data['layouts'] = $this->model_design_layout->getLayouts();
|
||||
|
||||
if (version_compare(VERSION, '2.0.1.0', '<')) {
|
||||
$this->template = 'module/retailcrm.1.x.tpl';
|
||||
$this->children = array(
|
||||
'common/header',
|
||||
'common/footer',
|
||||
);
|
||||
$this->template = 'module/retailcrm.1.x.tpl';
|
||||
$this->children = array(
|
||||
'common/header',
|
||||
'common/footer',
|
||||
);
|
||||
|
||||
$this->response->setOutput($this->render());
|
||||
} else {
|
||||
$_data['header'] = $this->load->controller('common/header');
|
||||
$_data['column_left'] = $this->load->controller('common/column_left');
|
||||
$_data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput(
|
||||
$this->load->view('module/retailcrm.2.x.tpl', $_data)
|
||||
);
|
||||
}
|
||||
$this->response->setOutput($this->render());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,15 +10,8 @@ class ModelRetailcrmHistory extends Model
|
|||
{
|
||||
$this->load->model('setting/setting');
|
||||
$this->load->model('setting/store');
|
||||
if(version_compare(VERSION, '2.0.0', '>=')) {
|
||||
$this->load->model('user/api');
|
||||
}
|
||||
$this->load->model('sale/order');
|
||||
if (version_compare(VERSION, '2.1.0.0', '>=')) {
|
||||
$this->load->model('customer/customer');
|
||||
} else {
|
||||
$this->load->model('sale/customer');
|
||||
}
|
||||
$this->load->model('sale/customer');
|
||||
$this->load->model('retailcrm/references');
|
||||
$this->load->model('catalog/product');
|
||||
$this->load->model('localisation/zone');
|
||||
|
@ -37,10 +30,6 @@ class ModelRetailcrmHistory extends Model
|
|||
return false;
|
||||
}
|
||||
|
||||
if(version_compare(VERSION, '2.0.0', '>=')) {
|
||||
$this->opencartApiClient = new OpencartApiClient($this->registry);
|
||||
}
|
||||
|
||||
$crm = new RetailcrmProxy(
|
||||
$settings['retailcrm_url'],
|
||||
$settings['retailcrm_apikey'],
|
||||
|
@ -247,11 +236,7 @@ class ModelRetailcrmHistory extends Model
|
|||
$data['order_status_id'] = $tmpOrder['order_status_id'];
|
||||
}
|
||||
|
||||
if(version_compare(VERSION, '2.0.0', '>=')) {
|
||||
$this->opencartApiClient->editOrder($order['externalId'], $data);
|
||||
} else {
|
||||
$this->model_sale_order->editOrder($order['externalId'], $data);
|
||||
}
|
||||
$this->model_sale_order->editOrder($order['externalId'], $data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -298,25 +283,13 @@ class ModelRetailcrmHistory extends Model
|
|||
),
|
||||
);
|
||||
|
||||
if (version_compare(VERSION, '2.1.0.0', '>=')) {
|
||||
$this->model_customer_customer->addCustomer($cData);
|
||||
} else {
|
||||
$this->model_sale_customer->addCustomer($cData);
|
||||
}
|
||||
$this->model_sale_customer->addCustomer($cData);
|
||||
|
||||
if (!empty($order['email'])) {
|
||||
if (version_compare(VERSION, '2.1.0.0', '>=')) {
|
||||
$tryToFind = $this->model_customer_customer->getCustomerByEmail($order['email']);
|
||||
} else {
|
||||
$tryToFind = $this->model_sale_customer->getCustomerByEmail($order['email']);
|
||||
}
|
||||
$tryToFind = $this->model_sale_customer->getCustomerByEmail($order['email']);
|
||||
$customer_id = $tryToFind['customer_id'];
|
||||
} else {
|
||||
if (version_compare(VERSION, '2.1.0.0', '>=')) {
|
||||
$last = $this->model_customer_customer->getCustomers($data = array('order' => 'DESC', 'limit' => 1));
|
||||
} else {
|
||||
$last = $this->model_sale_customer->getCustomers($data = array('order' => 'DESC', 'limit' => 1));
|
||||
}
|
||||
$last = $this->model_sale_customer->getCustomers($data = array('order' => 'DESC', 'limit' => 1));
|
||||
$customer_id = $last[0]['customer_id'];
|
||||
}
|
||||
|
||||
|
@ -442,11 +415,7 @@ class ModelRetailcrmHistory extends Model
|
|||
$data['fromApi'] = true;
|
||||
$data['order_status_id'] = 1;
|
||||
|
||||
if(version_compare(VERSION, '2.0.0', '>=')) {
|
||||
$this->opencartApiClient->addOrder($data);
|
||||
} else {
|
||||
$this->model_sale_order->addOrder($data);
|
||||
}
|
||||
$this->model_sale_order->addOrder($data);
|
||||
|
||||
$last = $this->model_sale_order->getOrders($data = array('order' => 'DESC', 'limit' => 1, 'start' => 0));
|
||||
|
||||
|
|
|
@ -208,18 +208,6 @@ class ModelRetailcrmIcml extends Model
|
|||
{
|
||||
$this->load->model('tool/image');
|
||||
|
||||
if (version_compare(VERSION, '2.2', '>=')) {
|
||||
$currentTheme = $this->config->get('config_theme');
|
||||
$width = $this->config->get($currentTheme . '_image_related_width') ? $this->config->get($currentTheme . '_image_related_width') : 200;
|
||||
$height = $this->config->get($currentTheme . '_image_related_height') ? $this->config->get($currentTheme . '_image_related_height') : 200;
|
||||
|
||||
return $this->model_tool_image->resize(
|
||||
$image,
|
||||
$width,
|
||||
$height
|
||||
);
|
||||
}
|
||||
|
||||
return $this->model_tool_image->resize(
|
||||
$image,
|
||||
$this->config->get('config_image_product_width'),
|
||||
|
|
|
@ -1,110 +0,0 @@
|
|||
<?php echo $header; ?>
|
||||
<?php echo $column_left;?>
|
||||
|
||||
<div id="content">
|
||||
<div class="page-header">
|
||||
<div class="container-fluid">
|
||||
<div class="pull-right">
|
||||
<button type="submit" form="form-retailcrm" data-toggle="tooltip" title="<?php echo $button_save; ?>" class="btn btn-primary"><i class="fa fa-save"></i></button>
|
||||
<a href="<?php echo $cancel; ?>" data-toggle="tooltip" title="<?php echo $button_cancel; ?>" class="btn btn-default"><i class="fa fa-reply"></i></a></div>
|
||||
<h1><?php echo $heading_title; ?></h1>
|
||||
<ul class="breadcrumb">
|
||||
<?php foreach ($breadcrumbs as $breadcrumb) { ?>
|
||||
<li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-fluid">
|
||||
<?php if ($error_warning) : ?>
|
||||
<div class="alert alert-danger">
|
||||
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||
<i class="fa fa-exclamation-circle"></i> <?php echo $error_warning; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (isset($saved_settings['retailcrm_url'])): ?>
|
||||
<div class="alert alert-info"><i class="fa fa-exclamation-circle"></i>
|
||||
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||
<?php echo $text_notice; ?>
|
||||
<a href="<?php echo $saved_settings['retailcrm_url']; ?>/admin/settings#t-main"><?php echo $saved_settings['retailcrm_url']; ?>/admin/settings#t-main</a>
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form-retailcrm">
|
||||
<input type="hidden" name="retailcrm_status" value="1">
|
||||
|
||||
<h3><?php echo $retailcrm_base_settings; ?></h3>
|
||||
<div class="retailcrm_unit">
|
||||
<label for="retailcrm_url"><?php echo $retailcrm_url; ?></label><br>
|
||||
<input id="retailcrm_url" type="text" name="retailcrm_url" value="<?php if (isset($saved_settings['retailcrm_url'])): echo $saved_settings['retailcrm_url']; endif; ?>">
|
||||
</div>
|
||||
<div class="retailcrm_unit">
|
||||
<label for="retailcrm_apikey"><?php echo $retailcrm_apikey; ?></label><br>
|
||||
<input id="retailcrm_apikey" type="text" name="retailcrm_apikey" value="<?php if (isset($saved_settings['retailcrm_apikey'])): echo $saved_settings['retailcrm_apikey']; endif;?>">
|
||||
</div>
|
||||
|
||||
<?php if (isset($saved_settings['retailcrm_apikey']) && $saved_settings['retailcrm_apikey'] != '' && isset($saved_settings['retailcrm_url']) && $saved_settings['retailcrm_url'] != ''): ?>
|
||||
|
||||
<?php if (!empty($retailcrm_errors)) : ?>
|
||||
<?php foreach($retailcrm_errors as $retailcrm_error): ?>
|
||||
<div class="warning"><?php echo $retailcrm_error ?></div>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<h3><?php echo $retailcrm_dict_settings; ?></h3>
|
||||
|
||||
<h4><?php echo $retailcrm_dict_delivery; ?></h4>
|
||||
<?php foreach ($delivery['opencart'] as $key => $value): ?>
|
||||
<div class="retailcrm_unit">
|
||||
<select id="retailcrm_delivery_<?php echo $key; ?>" name="retailcrm_delivery[<?php echo $key; ?>]" >
|
||||
<?php foreach ($delivery['retailcrm'] as $k => $v): ?>
|
||||
<option value="<?php echo $v['code'];?>" <?php if(isset($saved_settings['retailcrm_delivery'][$key]) && $v['code'] == $saved_settings['retailcrm_delivery'][$key]):?>selected="selected"<?php endif;?>>
|
||||
<?php echo $v['name'];?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<label for="retailcrm_delivery_<?php echo $key; ?>"><?php echo $value; ?></label>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<h4><?php echo $retailcrm_dict_status; ?></h4>
|
||||
<?php foreach ($statuses['opencart'] as $status): ?>
|
||||
<?php $uid = $status['order_status_id']?>
|
||||
<div class="retailcrm_unit">
|
||||
<select id="retailcrm_status_<?php echo $uid; ?>" name="retailcrm_status[<?php echo $uid; ?>]" >
|
||||
<?php foreach ($statuses['retailcrm'] as $k => $v): ?>
|
||||
<option value="<?php echo $v['code'];?>" <?php if(isset($saved_settings['retailcrm_status'][$uid]) && $v['code'] == $saved_settings['retailcrm_status'][$uid]):?>selected="selected"<?php endif;?>>
|
||||
<?php echo $v['name'];?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<label for="retailcrm_status_<?php echo $status['order_status_id']; ?>"><?php echo $status['name']; ?></label>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<h4><?php echo $retailcrm_dict_payment; ?></h4>
|
||||
<?php foreach ($payments['opencart'] as $key => $value): ?>
|
||||
<div class="retailcrm_unit">
|
||||
<select id="retailcrm_payment_<?php echo $key; ?>" name="retailcrm_payment[<?php echo $key; ?>]" >
|
||||
<?php foreach ($payments['retailcrm'] as $k => $v): ?>
|
||||
<option value="<?php echo $v['code'];?>" <?php if(isset($saved_settings['retailcrm_payment'][$key]) && $v['code'] == $saved_settings['retailcrm_payment'][$key]):?>selected="selected"<?php endif;?>>
|
||||
<?php echo $v['name'];?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<label for="retailcrm_payment_<?php echo $key; ?>"><?php echo $value; ?></label>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endif; ?>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php echo $footer; ?>
|
|
@ -34,17 +34,10 @@ if (!defined('DIR_APPLICATION')) {
|
|||
require_once(DIR_SYSTEM . 'startup.php');
|
||||
|
||||
// Application Classes
|
||||
if (version_compare(VERSION, '2.2', '>=')) {
|
||||
require_once(DIR_SYSTEM . 'library/cart/currency.php');
|
||||
require_once(DIR_SYSTEM . 'library/cart/user.php');
|
||||
require_once(DIR_SYSTEM . 'library/cart/weight.php');
|
||||
require_once(DIR_SYSTEM . 'library/cart/length.php');
|
||||
} else {
|
||||
require_once(DIR_SYSTEM . 'library/currency.php');
|
||||
require_once(DIR_SYSTEM . 'library/user.php');
|
||||
require_once(DIR_SYSTEM . 'library/weight.php');
|
||||
require_once(DIR_SYSTEM . 'library/length.php');
|
||||
}
|
||||
require_once(DIR_SYSTEM . 'library/currency.php');
|
||||
require_once(DIR_SYSTEM . 'library/user.php');
|
||||
require_once(DIR_SYSTEM . 'library/weight.php');
|
||||
require_once(DIR_SYSTEM . 'library/length.php');
|
||||
|
||||
// Registry
|
||||
$registry = new Registry();
|
||||
|
@ -68,10 +61,7 @@ foreach ($query->rows as $setting) {
|
|||
if (!$setting['serialized']) {
|
||||
$config->set($setting['key'], $setting['value']);
|
||||
} else {
|
||||
if (version_compare(VERSION, '2.2', '>='))
|
||||
$config->set($setting['key'], json_decode($setting['value']), true);
|
||||
else
|
||||
$config->set($setting['key'], unserialize($setting['value']));
|
||||
$config->set($setting['key'], unserialize($setting['value']));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,13 +73,6 @@ $registry->set('url', $url);
|
|||
$log = new Log($config->get('config_error_filename'));
|
||||
$registry->set('log', $log);
|
||||
|
||||
|
||||
// Event
|
||||
if (version_compare(VERSION, '2.2', '>=')) {
|
||||
$event = new Event($registry);
|
||||
$registry->set('event', $event);
|
||||
}
|
||||
|
||||
function error_handler($errno, $errstr, $errfile, $errline) {
|
||||
global $log, $config;
|
||||
|
||||
|
@ -153,17 +136,10 @@ $registry->set('language', $language);
|
|||
$document = new Document();
|
||||
$registry->set('document', $document);
|
||||
|
||||
if (version_compare(VERSION, '2.2', '>=')) {
|
||||
$registry->set('currency', new Cart\Currency($registry));
|
||||
$registry->set('weight', new Cart\Weight($registry));
|
||||
$registry->set('length', new Cart\Length($registry));
|
||||
$registry->set('user', new Cart\User($registry));
|
||||
} else {
|
||||
$registry->set('currency', new Currency($registry));
|
||||
$registry->set('weight', new Weight($registry));
|
||||
$registry->set('length', new Length($registry));
|
||||
$registry->set('user', new User($registry));
|
||||
}
|
||||
$registry->set('currency', new Currency($registry));
|
||||
$registry->set('weight', new Weight($registry));
|
||||
$registry->set('length', new Length($registry));
|
||||
$registry->set('user', new User($registry));
|
||||
|
||||
$controller = new Front($registry);
|
||||
$action = new Action($cli_action);
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
<?php
|
||||
echo $_SERVER['REMOTE_ADDR'];
|
|
@ -1,316 +0,0 @@
|
|||
<?php
|
||||
|
||||
class OpencartApiClient {
|
||||
|
||||
private $opencartStoreId = 0;
|
||||
private $cookieFileName;
|
||||
private $registry;
|
||||
private $apiToken;
|
||||
|
||||
/* Совместимость с объектами ОС, например $this->model_module_name */
|
||||
public function __get($name) {
|
||||
return $this->registry->get($name);
|
||||
}
|
||||
|
||||
public function __construct(Registry &$registry) {
|
||||
$this->registry = $registry;
|
||||
|
||||
$settings = $this->model_setting_setting->getSetting('retailcrm');
|
||||
$this->cookieFileName = $settings['retailcrm_apikey'];
|
||||
|
||||
$this->auth();
|
||||
}
|
||||
|
||||
private function getCookieValue($cookieName) {
|
||||
$cookieFile = file_get_contents(DIR_APPLICATION . '/' . $this->cookieFileName . '.txt');
|
||||
$cookieFile = explode("\n", $cookieFile);
|
||||
|
||||
$cookies = array();
|
||||
foreach($cookieFile as $line) {
|
||||
if(empty($line) OR $line{0} == '#')
|
||||
continue;
|
||||
|
||||
$params = explode("\t", $line);
|
||||
$cookies[$params[5]] = $params[6];
|
||||
}
|
||||
|
||||
if(isset($cookies[$cookieName]))
|
||||
return $cookies[$cookieName];
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function request($method, $getParams, $postParams) {
|
||||
$opencartStoreInfo = $this->model_setting_store->getStore($this->opencartStoreId);
|
||||
|
||||
if(version_compare(VERSION, '2.1.0', '>=') && !empty($this->apiToken)) {
|
||||
$getParams['token'] = $this->apiToken;
|
||||
}
|
||||
|
||||
$postParams['fromApi'] = true;
|
||||
|
||||
if ($opencartStoreInfo) {
|
||||
$url = $opencartStoreInfo['ssl'];
|
||||
} else {
|
||||
$url = HTTPS_CATALOG;
|
||||
}
|
||||
|
||||
$curl = curl_init();
|
||||
|
||||
// Set SSL if required
|
||||
if (substr($url, 0, 5) == 'https') {
|
||||
curl_setopt($curl, CURLOPT_PORT, 443);
|
||||
}
|
||||
|
||||
curl_setopt($curl, CURLOPT_HEADER, false);
|
||||
curl_setopt($curl, CURLINFO_HEADER_OUT, true);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($curl, CURLOPT_FORBID_REUSE, false);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($curl, CURLOPT_URL, $url . 'index.php?route=api/' . $method . (!empty($getParams) ? '&' . http_build_query($getParams) : ''));
|
||||
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($postParams));
|
||||
|
||||
curl_setopt($curl, CURLOPT_COOKIEFILE, DIR_APPLICATION . '/' . $this->cookieFileName . '.txt');
|
||||
curl_setopt($curl, CURLOPT_COOKIEJAR, DIR_APPLICATION . '/' . $this->cookieFileName . '.txt');
|
||||
|
||||
$json = json_decode(curl_exec($curl), true);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
return $json;
|
||||
}
|
||||
|
||||
private function auth() {
|
||||
$apiUsers = $this->model_user_api->getApis();
|
||||
|
||||
$api = array();
|
||||
foreach ($apiUsers as $apiUser) {
|
||||
if($apiUser['status'] == 1) {
|
||||
if(version_compare(VERSION, '2.1.0', '>=')) {
|
||||
$api = array(
|
||||
'api_id' => $apiUser['api_id'],
|
||||
'key' => $apiUser['key']
|
||||
);
|
||||
} else {
|
||||
$api = array(
|
||||
'api_id' => $apiUser['api_id'],
|
||||
'username' => $apiUser['username'],
|
||||
'password' => $apiUser['password']
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!isset($api['api_id']))
|
||||
return false;
|
||||
|
||||
if(version_compare(VERSION, '2.1.0', '>=')) {
|
||||
$alreadyBinded = false;
|
||||
|
||||
$innerIp = $this->getInnerIpAddr();
|
||||
$apiIps = $this->model_user_api->getApiIps($api['api_id']);
|
||||
foreach($apiIps as $apiIp) {
|
||||
if($apiIp['ip'] == $innerIp)
|
||||
$alreadyBinded = true;
|
||||
}
|
||||
|
||||
if(!$alreadyBinded) {
|
||||
$this->model_user_api->addApiIp($api['api_id'], $innerIp);
|
||||
}
|
||||
}
|
||||
|
||||
$apiAnswer = $this->request('login', array(), $apiUser);
|
||||
|
||||
if(version_compare(VERSION, '2.1.0', '>=')) {
|
||||
$this->apiToken = $apiAnswer['token'];
|
||||
}
|
||||
|
||||
return $apiAnswer;
|
||||
}
|
||||
|
||||
public function editOrder($order_id, $data) {
|
||||
$data['telephone'] = trim($data['telephone']);
|
||||
$customer = array(
|
||||
'currency' => isset($data['currency']) ? $data['currency'] : '',
|
||||
'customer' => $data['customer'],
|
||||
'customer_id' => $data['customer_id'],
|
||||
'customer_group_id' => $data['customer_group_id'],
|
||||
'firstname' => $data['firstname'],
|
||||
'lastname' => $data['lastname'],
|
||||
'email' => $data['email'],
|
||||
'telephone' => !empty($data['telephone']) ? $data['telephone'] : '0000',
|
||||
'fax' => $data['fax'],
|
||||
);
|
||||
$this->request('customer', array(), $customer);
|
||||
|
||||
$products = array();
|
||||
foreach ($data['order_product'] as $order_product) {
|
||||
$products[] = array(
|
||||
'product_id' => $order_product['product_id'],
|
||||
'quantity' => $order_product['quantity']
|
||||
);
|
||||
}
|
||||
$this->request('cart/add', array(), array('product' => $products));
|
||||
|
||||
$payment_address = array(
|
||||
'payment_address' => $data['payment_address'],
|
||||
'firstname' => $data['payment_firstname'],
|
||||
'lastname' => $data['payment_lastname'],
|
||||
'company' => $data['payment_company'],
|
||||
'address_1'=> $data['payment_address_1'],
|
||||
'address_2' => $data['payment_address_2'],
|
||||
'city' => !empty($data['payment_city']) ? $data['payment_city'] : 'none',
|
||||
'postcode' => $data['payment_postcode'],
|
||||
'country_id' => $data['payment_country_id'],
|
||||
'zone_id' => !empty($data['payment_zone_id']) ? $data['payment_zone_id'] : 0,
|
||||
);
|
||||
$this->request('payment/address', array(), $payment_address);
|
||||
|
||||
$this->request('payment/methods', array(), array());
|
||||
$payment_method = array(
|
||||
'payment_method' => $data['payment_code']
|
||||
);
|
||||
$this->request('payment/method', array(), $payment_method);
|
||||
|
||||
$shipping_address = array(
|
||||
'shipping_address' => $data['shipping_address'],
|
||||
'firstname' => $data['shipping_firstname'],
|
||||
'lastname' => $data['shipping_lastname'],
|
||||
'company' => $data['shipping_company'],
|
||||
'address_1' => $data['shipping_address_1'],
|
||||
'address_2' => $data['shipping_address_2'],
|
||||
'city' => !empty($data['shipping_city']) ? $data['shipping_city'] : 'none',
|
||||
'postcode' => $data['shipping_postcode'],
|
||||
'country_id' => $data['shipping_country_id'],
|
||||
'zone_id' => !empty($data['shipping_zone_id']) ? $data['shipping_zone_id'] : 0,
|
||||
);
|
||||
$this->request('shipping/address', array(), $shipping_address);
|
||||
|
||||
$this->request('shipping/methods', array(), array());
|
||||
$shipping_method = array(
|
||||
'shipping_method' => $data['shipping_code']
|
||||
);
|
||||
$this->request('shipping/method', array(), $shipping_method);
|
||||
|
||||
$order = array(
|
||||
'shipping_method' => $data['shipping_code'],
|
||||
'payment_method' => $data['payment_code'],
|
||||
'order_status_id' => $data['order_status_id'],
|
||||
'comment' => $data['comment'],
|
||||
'affiliate_id' => $data['affiliate_id'],
|
||||
);
|
||||
$this->request('order/edit', array('order_id' => $order_id), $order);
|
||||
}
|
||||
|
||||
public function addOrder($data) {
|
||||
$currency = $this->getCookieValue('currency');
|
||||
if($currency) {
|
||||
$a = $this->request('currency', array(), array('currency' => $currency));
|
||||
}
|
||||
|
||||
$customer = array(
|
||||
'store_id' => $data['store_id'],
|
||||
'currency' => $currency != false ? $currency : '',
|
||||
'customer' => $data['customer'],
|
||||
'customer_id' => $data['customer_id'],
|
||||
'customer_group_id' => $data['customer_group_id'],
|
||||
'firstname' => $data['firstname'],
|
||||
'lastname' => $data['lastname'],
|
||||
'email' => $data['email'],
|
||||
'telephone' => $data['telephone'],
|
||||
'fax' => $data['fax'],
|
||||
);
|
||||
$this->request('customer', array(), $customer);
|
||||
|
||||
$products = array();
|
||||
foreach($data['order_product'] as $product) {
|
||||
$product = array(
|
||||
'product_id' => $product['product_id'],
|
||||
'quantity' => $product['quantity'],
|
||||
);
|
||||
$products[] = $product;
|
||||
}
|
||||
$this->request('cart/add', array(), array('product' => $products));
|
||||
|
||||
$payment_address = array(
|
||||
'payment_address' => $data['payment_address'],
|
||||
'firstname' => $data['payment_firstname'],
|
||||
'lastname' => $data['payment_lastname'],
|
||||
'company' => $data['payment_company'],
|
||||
'address_1' => $data['payment_address_1'],
|
||||
'address_2' => $data['payment_address_2'],
|
||||
'city' => $data['payment_city'],
|
||||
'postcode' => $data['payment_postcode'],
|
||||
'country_id' => $data['payment_country_id'],
|
||||
'zone_id' => $data['payment_zone_id'],
|
||||
);
|
||||
$this->request('payment/address', array(), $payment_address);
|
||||
|
||||
$shipping_address = array(
|
||||
'shipping_address' => $data['shipping_address'],
|
||||
'firstname' => $data['shipping_firstname'],
|
||||
'lastname' => $data['shipping_lastname'],
|
||||
'company' => $data['shipping_company'],
|
||||
'address_1' => $data['shipping_address_1'],
|
||||
'address_2' => $data['shipping_address_2'],
|
||||
'city' => $data['shipping_city'],
|
||||
'postcode' => $data['shipping_postcode'],
|
||||
'country_id' => $data['shipping_country_id'],
|
||||
'zone_id' => !empty($data['shipping_zone_id']) ? $data['shipping_zone_id'] : 0,
|
||||
);
|
||||
$this->request('shipping/address', array(), $shipping_address);
|
||||
|
||||
$this->request('shipping/methods', array(), array());
|
||||
$shipping_method = array(
|
||||
'shipping_method' => $data['shipping_code']
|
||||
);
|
||||
$this->request('shipping/method', array(), $shipping_method);
|
||||
|
||||
$this->request('payment/methods', array(), array());
|
||||
$payment_method = array(
|
||||
'payment_method' => $data['payment_code']
|
||||
);
|
||||
$this->request('payment/method', array(), $payment_method);
|
||||
|
||||
$order = array(
|
||||
'shipping_method' => $data['shipping_code'],
|
||||
'payment_method' => $data['payment_code'],
|
||||
'order_status_id' => $data['order_status_id'],
|
||||
'comment' => $data['comment'],
|
||||
'affiliate_id' => $data['affiliate_id'],
|
||||
);
|
||||
$this->request('order/add', array(), $order);
|
||||
}
|
||||
|
||||
private function getInnerIpAddr() {
|
||||
$opencartStoreInfo = $this->model_setting_store->getStore($this->opencartStoreId);
|
||||
|
||||
if ($opencartStoreInfo) {
|
||||
$url = $opencartStoreInfo['ssl'];
|
||||
} else {
|
||||
$url = HTTPS_CATALOG;
|
||||
}
|
||||
|
||||
$curl = curl_init();
|
||||
|
||||
// Set SSL if required
|
||||
if (substr($url, 0, 5) == 'https') {
|
||||
curl_setopt($curl, CURLOPT_PORT, 443);
|
||||
}
|
||||
|
||||
curl_setopt($curl, CURLOPT_HEADER, false);
|
||||
curl_setopt($curl, CURLINFO_HEADER_OUT, true);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($curl, CURLOPT_FORBID_REUSE, false);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($curl, CURLOPT_URL, $url . 'system/cron/getmyip.php');
|
||||
|
||||
return curl_exec($curl);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue