Merge pull request #10 from DmitryKorol/master

Bugfixes
This commit is contained in:
Alex Lushpai 2016-05-26 17:51:43 +04:00
commit af8eb0beee
9 changed files with 524 additions and 37 deletions

8
admin/controller/module/retailcrm.php Normal file → Executable file
View File

@ -37,6 +37,13 @@ class ControllerModuleRetailcrm extends Controller
'post.order.add',
'module/retailcrm/order_create'
);
$this->model_extension_event
->addEvent(
'retailcrm',
'post.order.history.add',
'module/retailcrm/order_edit'
);
}
}
@ -278,7 +285,6 @@ class ControllerModuleRetailcrm extends Controller
*/
public function order_create($order_id)
{
$this->load->model('checkout/order');
$this->load->model('account/order');

40
admin/model/retailcrm/history.php Normal file → Executable file
View File

@ -4,12 +4,21 @@ class ModelRetailcrmHistory extends Model
{
protected $createResult;
private $opencartApiClient;
public function request()
{
$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('retailcrm/references');
$this->load->model('catalog/product');
$this->load->model('localisation/zone');
@ -28,6 +37,10 @@ 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'],
@ -96,7 +109,6 @@ class ModelRetailcrmHistory extends Model
if (!empty($this->createResult['orders'])) {
$crm->ordersFixExternalIds($this->createResult['orders']);
}
}
protected function updateOrders($orders)
@ -113,14 +125,14 @@ class ModelRetailcrmHistory extends Model
$data['firstname'] = $order['firstName'];
$data['lastname'] = (!empty($order['lastName'])) ? $order['lastName'] : ' ';
$data['email'] = $order['email'];
$data['telephone'] = (!empty($order['phone']['number'])) ? $order['phone']['number'] : ' ';
$data['telephone'] = (!empty($order['phone'])) ? $order['phone'] : '';
$data['comment'] = !empty($order['customerComment']) ? $order['customerComment'] : '';
$data['fax'] = '';
$data['payment_address'] = '0';
$data['payment_firstname'] = $order['firstName'];
$data['payment_lastname'] = (!empty($order['lastName'])) ? $order['lastName'] : ' ';
$data['payment_address_1'] = $order['customer']['address']['text'];
$data['payment_address_1'] = isset($order['customer']['address']) ? $order['customer']['address']['text'] : '';
$data['payment_address_2'] = '';
$data['payment_company'] = '';
$data['payment_company_id'] = '';
@ -158,6 +170,7 @@ class ModelRetailcrmHistory extends Model
$data['shipping'] = $this->delivery[$order['delivery']['code']];
$data['shipping_method'] = $this->ocDelivery[$data['shipping']];
$data['shipping_code'] = $this->delivery[$order['delivery']['code']];
$data['payment'] = $this->payment[$order['paymentType']];
$data['payment_method'] = $this->ocPayment[$data['payment']];
$data['payment_code'] = $this->payment[$order['paymentType']];
@ -234,9 +247,13 @@ 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);
}
}
}
protected function createOrders($orders)
{
@ -281,13 +298,25 @@ 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);
}
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']);
}
$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));
}
$customer_id = $last[0]['customer_id'];
}
@ -314,7 +343,6 @@ class ModelRetailcrmHistory extends Model
$data['payment_city'] = !empty($order['customer']['address']['city']) ? $order['customer']['address']['city'] : $order['delivery']['address']['city'];
$data['payment_postcode'] = !empty($order['customer']['address']['index']) ? $order['customer']['address']['index'] : $order['delivery']['address']['index'];
$region = '';
if (!empty($order['delivery']['address']['region']) && is_int($order['delivery']['address']['region'])) {
@ -414,7 +442,11 @@ 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);
}
$last = $this->model_sale_order->getOrders($data = array('order' => 'DESC', 'limit' => 1, 'start' => 0));

4
admin/model/retailcrm/icml.php Normal file → Executable file
View File

@ -63,6 +63,8 @@ class ModelRetailcrmIcml extends Model
{
$categories = $this->model_catalog_category->getCategories(array());
foreach($categories as $category) {
$category = $this->model_catalog_category->getCategory($category['category_id']);
$e = $this->eCategories->appendChild(
$this->dd->createElement(
'category', $category['name']
@ -118,7 +120,7 @@ class ModelRetailcrmIcml extends Model
if (!empty($categories)) {
foreach ($categories as $category) {
$e->appendChild($this->dd->createElement('category'))
$e->appendChild($this->dd->createElement('categoryId'))
->appendChild(
$this->dd->createTextNode($category)
);

View File

@ -18,9 +18,6 @@ class ModelRetailcrmOrder extends Model {
$order = array();
$payment_code = $order_data['payment_code'];
$delivery_code = $order_data['shipping_code'];
$customers = $this->retailcrm->customersList(
array(
'name' => $order_data['telephone'],
@ -44,30 +41,34 @@ class ModelRetailcrmOrder extends Model {
$order['customerComment'] = $order_data['comment'];
$deliveryCost = 0;
$orderTotals = isset($order_data['totals']) ? $order_data['totals'] : $order_data['order_total'] ;
$altTotals = isset($order_data['order_total']) ? $order_data['order_total'] : "";
$orderTotals = isset($order_data['totals']) ? $order_data['totals'] : $altTotals ;
if (!empty($orderTotals)) {
foreach ($orderTotals as $totals) {
if ($totals['code'] == 'shipping') {
$deliveryCost = $totals['value'];
}
}
}
$order['createdAt'] = date('Y-m-d H:i:s');
$payment_code = $order_data['payment_code'];
$order['paymentType'] = $settings['retailcrm_payment'][$payment_code];
$country = (isset($order_data['shipping_country'])) ? $order_data['shipping_country'] : '' ;
$delivery_code = $order_data['shipping_code'];
$order['delivery'] = array(
'code' => $settings['retailcrm_delivery'][$delivery_code],
'cost' => $deliveryCost,
'address' => array(
'index' => $order_data['shipping_postcode'],
'city' => $order_data['shipping_city'],
'country' => $order_data['shipping_country_id'],
'region' => $order_data['shipping_zone_id'],
'countryIso' => $order_data['shipping_iso_code_2'],
'region' => $order_data['shipping_zone'],
'text' => implode(', ', array(
$order_data['shipping_postcode'],
$country,
(isset($order_data['shipping_country'])) ? $order_data['shipping_country'] : '',
$order_data['shipping_city'],
$order_data['shipping_address_1'],
$order_data['shipping_address_2']
@ -171,4 +172,3 @@ class ModelRetailcrmOrder extends Model {
}
}
}

28
catalog/controller/module/retailcrm.php Normal file → Executable file
View File

@ -42,4 +42,32 @@ class ControllerModuleRetailcrm extends Controller
$this->model_retailcrm_order->sendToCrm($data, $data['order_id']);
}
}
public function order_edit($order_id) {
$this->load->model('checkout/order');
$this->load->model('account/order');
$data = $this->model_checkout_order->getOrder($order_id);
if($data['order_status_id'] == 0) return;
$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');
if ($data['order_status_id'] > 0) {
$data['order_status'] = $status['retailcrm_status'][$data['order_status_id']];
}
$data['totals'][] = array(
'code' => 'shipping',
'value' => isset($this->session->data['shipping_method']) ? $this->session->data['shipping_method']['cost'] : ''
);
$this->load->model('retailcrm/order');
$this->model_retailcrm_order->changeInCrm($data, $data['order_id']);
}
}
}

98
catalog/model/retailcrm/order.php Normal file → Executable file
View File

@ -4,6 +4,8 @@ class ModelRetailcrmOrder extends Model {
public function sendToCrm($order_data, $order_id)
{
if(isset($this->request->post['fromApi'])) return;
$this->load->model('setting/setting');
$settings = $this->model_setting_setting->getSetting('retailcrm');
@ -18,9 +20,6 @@ class ModelRetailcrmOrder extends Model {
$order = array();
$payment_code = $order_data['payment_code'];
$delivery_code = $order_data['shipping_code'];
$customers = $this->retailcrm->customersList(
array(
'name' => $order_data['telephone'],
@ -55,13 +54,101 @@ class ModelRetailcrmOrder extends Model {
}
}
$order['createdAt'] = date('Y-m-d H:i:s');
$payment_code = $order_data['payment_code'];
$order['paymentType'] = $settings['retailcrm_payment'][$payment_code];
// Совместимость с 1.5.5, когда этот метод вызывается из model/checkout/order->createOrder(), а не из controller/module/retailcrm->order_create()
if(!isset($order_data['shipping_iso_code_2']) && isset($order_data['shipping_country_id'])) {
$this->load->model('localisation/country');
$shipping_country = $this->model_localisation_country->getCountry($order_data['shipping_country_id']);
$order_data['shipping_iso_code_2'] = $shipping_country['iso_code_2'];
}
$delivery_code = $order_data['shipping_code'];
$order['delivery'] = array(
'code' => !empty($delivery_code) ? $settings['retailcrm_delivery'][$delivery_code] : '',
'cost' => $deliveryCost,
'address' => array(
'index' => $order_data['shipping_postcode'],
'city' => $order_data['shipping_city'],
'countryIso' => $order_data['shipping_iso_code_2'],
'region' => $order_data['shipping_zone'],
'text' => implode(', ', array(
$order_data['shipping_postcode'],
(isset($order_data['shipping_country'])) ? $order_data['shipping_country'] : '',
$order_data['shipping_city'],
$order_data['shipping_address_1'],
$order_data['shipping_address_2']
))
)
);
$orderProducts = isset($order_data['products']) ? $order_data['products'] : $order_data['order_product'];
foreach ($orderProducts as $product) {
$order['items'][] = array(
'productId' => $product['product_id'],
'productName' => $product['name'],
'initialPrice' => $product['price'],
'quantity' => $product['quantity'],
);
}
if (isset($order_data['order_status_id']) && $order_data['order_status_id'] > 0) {
$order['status'] = $settings['retailcrm_status'][$order_data['order_status_id']];
}
$this->retailcrm->ordersCreate($order);
}
}
public function changeInCrm($order_data, $order_id)
{
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'])) {
require_once DIR_SYSTEM . 'library/retailcrm/bootstrap.php';
$this->retailcrm = new RetailcrmProxy(
$settings['retailcrm_url'],
$settings['retailcrm_apikey'],
DIR_SYSTEM . 'logs/retailcrm.log'
);
$order = array();
$payment_code = $order_data['payment_code'];
$delivery_code = $order_data['shipping_code'];
$order['externalId'] = $order_id;
$order['firstName'] = $order_data['firstname'];
$order['lastName'] = $order_data['lastname'];
$order['email'] = $order_data['email'];
$order['phone'] = $order_data['telephone'];
$order['customerComment'] = $order_data['comment'];
$deliveryCost = 0;
$orderTotals = isset($order_data['totals']) ? $order_data['totals'] : $order_data['order_total'] ;
foreach ($orderTotals as $totals) {
if ($totals['code'] == 'shipping') {
$deliveryCost = $totals['value'];
}
}
$order['createdAt'] = date('Y-m-d H:i:s');
$order['paymentType'] = $settings['retailcrm_payment'][$payment_code];
$country = (isset($order_data['shipping_country'])) ? $order_data['shipping_country'] : '' ;
$order['delivery'] = array(
'code' => $settings['retailcrm_delivery'][$delivery_code],
'code' => !empty($delivery_code) ? $settings['retailcrm_delivery'][$delivery_code] : '',
'cost' => $deliveryCost,
'address' => array(
'index' => $order_data['shipping_postcode'],
@ -93,8 +180,7 @@ class ModelRetailcrmOrder extends Model {
$order['status'] = $settings['retailcrm_status'][$order_data['order_status_id']];
}
$this->retailcrm->ordersCreate($order);
$this->retailcrm->ordersEdit($order);
}
}
}

27
system/cron/dispatch.php Normal file → Executable file
View File

@ -3,13 +3,18 @@
// Ensure $cli_action is set
if (!isset($cli_action)) {
echo 'ERROR: $cli_action must be set in calling script.';
$log->write('ERROR: $cli_action must be set in calling script.');
http_response_code(400);
exit;
}
// Version
define('VERSION', '1.5.6');
$version = '1.5.6';
$indexFile = file_get_contents(realpath(dirname(__FILE__)) . '/../../index.php');
preg_match("/define\([\s]*['\"]VERSION['\"][\s]*,[\s]*['\"](.*)['\"][\s]*\)[\s]*;/mi", $indexFile, $versionMatches);
if(isset($versionMatches[1])) {
$version = $versionMatches[1];
}
define('VERSION', $version);
// Configuration (note we're using the admin config)
require_once(realpath(dirname(__FILE__)) . '/../../admin/config.php');
@ -101,18 +106,28 @@ $request = new Request();
$registry->set('request', $request);
$response = new Response();
$response->addHeader('Content-Type: text/html; charset=utf-8');
$cache = new Cache('file');
$registry->set('cache', $cache);
$registry->set('response', $response);
$session = new Session();
$registry->set('session', $session);
$languages = array();
$languages = array();
$query = $db->query("SELECT * FROM " . DB_PREFIX . "language");
foreach ($query->rows as $result) {
$languages[$result['code']] = $result;
}
$config->set('config_language_id', $languages[$config->get('config_admin_language')]['language_id']);
$language = new Language($languages[$config->get('config_admin_language')]['directory']);
$language->load($languages[$config->get('config_admin_language')]['filename']);
$adminLanguageCode = $config->get('config_admin_language');
$config->set('config_language_id', $languages[$adminLanguageCode]['language_id']);
$language = new Language($languages[$adminLanguageCode]['directory']);
if(isset($languages[$adminLanguageCode]['filename'])) {
$language->load($languages[$adminLanguageCode]['filename']);
} else {
$language->load($languages[$adminLanguageCode]['directory']);
}
$registry->set('language', $language);
$document = new Document();

2
system/cron/getmyip.php Normal file
View File

@ -0,0 +1,2 @@
<?php
echo $_SERVER['REMOTE_ADDR'];

View File

@ -0,0 +1,316 @@
<?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);
}
}