mirror of
https://github.com/retailcrm/opencart-module.git
synced 2024-11-22 05:06:07 +03:00
Custom fields for v5, default payment and shipping methods for history upload
This commit is contained in:
parent
cdc1c9cf6b
commit
6875bc5f61
@ -107,7 +107,7 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||
$moduleTitle = $this->getModuleTitle();
|
||||
$this->loadModels();
|
||||
$this->load->model('setting/setting');
|
||||
$this->{'model_' . $this->modelExtension}->install('analytics', $collector);
|
||||
$this->{'model_' . $this->modelExtension}->install('analytics', 'daemon_collector');
|
||||
$this->model_setting_setting->editSetting($collector, array($collector . '_status' => 1));
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||
$this->loadModels();
|
||||
$this->load->model('setting/setting');
|
||||
$this->model_setting_setting->editSetting($collector, array($collector . '_status' => 0));
|
||||
$this->{'model_' . $this->modelExtension}->uninstall('analytics', $collector);
|
||||
$this->{'model_' . $this->modelExtension}->uninstall('analytics', 'daemon_collector');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -161,6 +161,10 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||
$this->request->post[$moduleTitle . '_url'] = 'https://'.$crm_url;
|
||||
}
|
||||
|
||||
if ($this->request->post[$moduleTitle . '_custom_field_active'] == 0) {
|
||||
unset($this->request->post[$moduleTitle . '_custom_field']);
|
||||
}
|
||||
|
||||
$this->model_setting_setting->editSetting(
|
||||
$moduleTitle,
|
||||
$this->request->post
|
||||
@ -263,7 +267,13 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||
'text_error_custom_field',
|
||||
'text_error_cf_opencart',
|
||||
'text_error_cf_retailcrm',
|
||||
'retailcrm_dict_custom_fields'
|
||||
'retailcrm_dict_custom_fields',
|
||||
'text_payment',
|
||||
'text_shipping',
|
||||
'retailcrm_dict_default',
|
||||
'text_custom_field_activity',
|
||||
'text_orders_custom_fields',
|
||||
'text_customers_custom_fields'
|
||||
);
|
||||
|
||||
$_data = &$data;
|
||||
|
@ -17,7 +17,7 @@ $_['general_tab_text'] = 'General';
|
||||
$_['references_tab_text'] = 'References';
|
||||
$_['collector_tab_text'] = 'Daemon Collector';
|
||||
$_['collector_custom_text'] = 'Custom form';
|
||||
$_['custom_fields_tab_text'] = 'Пользовательские поля';
|
||||
$_['custom_fields_tab_text'] = 'Custom fields';
|
||||
$_['retailcrm_apiversion'] = 'API Version';
|
||||
$_['retailcrm_url'] = 'RetailCRM URL';
|
||||
$_['retailcrm_apikey'] = 'RetailCRM API Key';
|
||||
@ -32,6 +32,7 @@ $_['text_success_catalog'] = 'Catalog successfully unloaded';
|
||||
$_['text_error_order'] = 'Error! Order is not unloaded!';
|
||||
$_['text_error_order_id'] = 'Error! Enter the correct order number!';
|
||||
$_['text_collector_activity'] = 'Use Daemon Collector';
|
||||
$_['text_custom_field_activity'] = 'Send custom fields';
|
||||
$_['text_collector_form_capture']= 'Show capture form';
|
||||
$_['text_collector_period'] = 'Form show period (in minutes)';
|
||||
$_['text_label_promo'] = 'Text form title';
|
||||
@ -40,17 +41,22 @@ $_['field_name'] = 'Name';
|
||||
$_['field_email'] = 'Email';
|
||||
$_['field_phone'] = 'Phone';
|
||||
$_['text_require'] = 'Require';
|
||||
$_['text_payment'] = 'Payment';
|
||||
$_['text_shipping'] = 'Shipping';
|
||||
$_['text_orders_custom_fields'] = 'Orders custom fields';
|
||||
$_['text_customers_custom_fields'] = 'Customers custom fields';
|
||||
$_['text_error_collector_fields']= 'Fill in the field names Daemon Collector';
|
||||
$_['text_error_api'] = 'The selected version of the API is unavailable';
|
||||
$_['text_error_custom_field'] = 'Создайте пользовательские поля в карточке клиента в Opencart и RetailCRM, чтобы настроить их передачу';
|
||||
$_['text_error_cf_opencart'] = 'Отсутствуют пользовательские поля в Opencart';
|
||||
$_['text_error_cf_retailcrm'] = 'Отсутствуют пользовательские поля в RetailCRM';
|
||||
$_['text_error_save'] = 'Ошибка сохранения настроек';
|
||||
$_['text_error_custom_field'] = 'Create custom fields for customer in Opencart and RetailCRM, that to configure their transmission';
|
||||
$_['text_error_cf_opencart'] = 'None custom fields in Opencart';
|
||||
$_['text_error_cf_retailcrm'] = 'None custom fields in RetailCRM';
|
||||
$_['text_error_save'] = 'Error saving settings';
|
||||
|
||||
$_['retailcrm_dict_delivery'] = 'Shipment methods';
|
||||
$_['retailcrm_dict_status'] = 'Order statuses';
|
||||
$_['retailcrm_dict_payment'] = 'Payment methods';
|
||||
$_['retailcrm_dict_custom_fields'] = 'Настройка пользовательских полей';
|
||||
$_['retailcrm_dict_custom_fields'] = 'Configure custom fields';
|
||||
$_['retailcrm_dict_default'] = 'Default';
|
||||
|
||||
$_['column_total'] = 'Total';
|
||||
$_['product_summ'] = 'Amount';
|
||||
|
@ -32,6 +32,7 @@ $_['text_success_catalog'] = 'Каталог успешно выгруже
|
||||
$_['text_error_order'] = 'Ошибка! Заказ не выгружен!';
|
||||
$_['text_error_order_id'] = 'Ошибка! Введите корректный номер заказа!';
|
||||
$_['text_collector_activity'] = 'Использовать Демон Collector';
|
||||
$_['text_custom_field_activity'] = 'Передавать кастомые поля';
|
||||
$_['text_collector_form_capture']= 'Показывать форму захвата';
|
||||
$_['text_collector_period'] = 'Периодичность всплывания формы (в минутах)';
|
||||
$_['text_label_promo'] = 'Текст заголовка формы';
|
||||
@ -40,6 +41,10 @@ $_['field_name'] = 'Имя';
|
||||
$_['field_email'] = 'Email';
|
||||
$_['field_phone'] = 'Телефон';
|
||||
$_['text_require'] = 'Обязательно для заполнения';
|
||||
$_['text_payment'] = 'Оплата';
|
||||
$_['text_shipping'] = 'Доставка';
|
||||
$_['text_orders_custom_fields'] = 'Кастомные поля заказов';
|
||||
$_['text_customers_custom_fields'] = 'Кастомные поля клиентов';
|
||||
$_['text_error_collector_fields']= 'Заполните названия полей формы Демон Collector';
|
||||
$_['text_error_api'] = 'Недоступна выбранная версия API.';
|
||||
$_['text_error_custom_field'] = 'Создайте пользовательские поля в карточке клиента в Opencart и RetailCRM, чтобы настроить их передачу';
|
||||
@ -51,6 +56,7 @@ $_['retailcrm_dict_delivery'] = 'Способы доставки';
|
||||
$_['retailcrm_dict_status'] = 'Статусы';
|
||||
$_['retailcrm_dict_payment'] = 'Способы оплаты';
|
||||
$_['retailcrm_dict_custom_fields'] = 'Настройка пользовательских полей';
|
||||
$_['retailcrm_dict_default'] = 'По умалчанию';
|
||||
|
||||
$_['column_total'] = 'Итого';
|
||||
$_['product_summ'] = 'Сумма';
|
||||
|
@ -65,13 +65,15 @@ class ModelExtensionRetailcrmCustomer extends Model {
|
||||
$customFields = json_decode($customer['custom_field']);
|
||||
|
||||
foreach ($customFields as $key => $value) {
|
||||
if (isset($this->settings[$moduleTitle . '_custom_field'][$key])) {
|
||||
$customFieldsToCrm[$this->settings[$moduleTitle . '_custom_field'][$key]] = $value;
|
||||
if (isset($this->settings[$moduleTitle . '_custom_field']['c_' . $key])) {
|
||||
$customFieldsToCrm[$this->settings[$moduleTitle . '_custom_field']['c_' . $key]] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($customFieldsToCrm)) {
|
||||
$customerToCrm['customFields'] = $customFieldsToCrm;
|
||||
}
|
||||
}
|
||||
|
||||
return $customerToCrm;
|
||||
}
|
||||
|
@ -58,16 +58,15 @@ class ModelExtensionRetailcrmHistoryV3 extends Model
|
||||
$this->subtotalSettings = $this->model_setting_setting->getSetting($this->totalTitle . 'sub_total');
|
||||
$this->totalSettings = $this->model_setting_setting->getSetting($this->totalTitle . 'total');
|
||||
$this->shippingSettings = $this->model_setting_setting->getSetting($this->totalTitle . 'shipping');
|
||||
|
||||
$this->delivery = array_flip($settings[$moduleTitle . '_delivery']);
|
||||
$this->payment = array_flip($settings[$moduleTitle . '_payment']);
|
||||
$this->status = array_flip($settings[$moduleTitle . '_status']);
|
||||
|
||||
$this->payment_default = $settings[$moduleTitle . '_default_payment'];
|
||||
$this->delivery_default = $settings[$moduleTitle . '_default_shipping'];
|
||||
$this->ocPayment = $this->model_extension_retailcrm_references
|
||||
->getOpercartPaymentTypes();
|
||||
|
||||
$this->ocDelivery = $settings[$moduleTitle . '_delivery'];
|
||||
|
||||
$this->zones = $this->model_localisation_zone->getZones();
|
||||
|
||||
$updatedOrders = array();
|
||||
@ -180,12 +179,13 @@ class ModelExtensionRetailcrmHistoryV3 extends Model
|
||||
$paymentCountry = $this->getCountryByIsoCode($order['customer']['address']['countryIso']);
|
||||
}
|
||||
|
||||
$delivery = isset($order['delivery']['code']) ? $order['delivery']['code'] : null;
|
||||
$payment = isset($order['paymentType']) ? $order['paymentType'] : null;
|
||||
|
||||
$data['payment_country_id'] = isset($paymentCountry) ? $paymentCountry['country_id'] : 0;
|
||||
$data['payment_zone_id'] = $payment_zone_id;
|
||||
|
||||
$data['shipping_country_id'] = isset($shippingCountry) ? $shippingCountry['country_id'] : 0;
|
||||
$data['shipping_zone_id'] = $shipping_zone_id;
|
||||
|
||||
$data['shipping_address'] = '0';
|
||||
$data['shipping_firstname'] = $order['firstName'];
|
||||
$data['shipping_lastname'] = isset($order['lastName']) ? $order['lastName'] : $order['firstName'];
|
||||
@ -195,14 +195,12 @@ class ModelExtensionRetailcrmHistoryV3 extends Model
|
||||
$data['shipping_company_id'] = '';
|
||||
$data['shipping_city'] = $order['delivery']['address']['city'];
|
||||
$data['shipping_postcode'] = $order['delivery']['address']['index'];
|
||||
|
||||
$data['shipping'] = $this->delivery[$order['delivery']['code']];
|
||||
$data['shipping'] = $delivery != null ? $this->delivery[$delivery] : $this->delivery_default;
|
||||
$data['shipping_method'] = $this->ocDelivery[$data['shipping']];
|
||||
$data['shipping_code'] = $this->delivery[$order['delivery']['code']];
|
||||
|
||||
$data['payment'] = $this->payment[$order['paymentType']];
|
||||
$data['shipping_code'] = $delivery != null ? $this->delivery[$delivery] : $this->delivery_default;
|
||||
$data['payment'] = $payment != null ? $this->payment[$payment] : $this->payment_default;
|
||||
$data['payment_method'] = $this->ocPayment[$data['payment']];
|
||||
$data['payment_code'] = $this->payment[$order['paymentType']];
|
||||
$data['payment_code'] = $payment != null ? $this->payment[$payment] : $this->payment_default;
|
||||
|
||||
// this data will not retrive from crm for now
|
||||
$data['tax'] = '';
|
||||
@ -428,6 +426,9 @@ class ModelExtensionRetailcrmHistoryV3 extends Model
|
||||
$paymentCountry = $this->getCountryByIsoCode($order['customer']['address']['countryIso']);
|
||||
}
|
||||
|
||||
$delivery = isset($order['delivery']['code']) ? $order['delivery']['code'] : null;
|
||||
$payment = isset($order['paymentType']) ? $order['paymentType'] : null;
|
||||
|
||||
$data['payment_country_id'] = $paymentCountry ? $paymentCountry['country_id'] : 0;
|
||||
$data['payment_zone_id'] = $payment_zone_id;
|
||||
$data['shipping_country_id'] = $shippingCountry ? $shippingCountry['country_id'] : 0;
|
||||
@ -441,13 +442,12 @@ class ModelExtensionRetailcrmHistoryV3 extends Model
|
||||
$data['shipping_company_id'] = '';
|
||||
$data['shipping_city'] = $order['delivery']['address']['city'];
|
||||
$data['shipping_postcode'] = $order['delivery']['address']['index'];
|
||||
|
||||
$data['shipping'] = $this->delivery[$order['delivery']['code']];
|
||||
$data['shipping'] = $delivery != null ? $this->delivery[$delivery] : $this->delivery_default;
|
||||
$data['shipping_method'] = $this->ocDelivery[$data['shipping']];
|
||||
$data['shipping_code'] = $this->delivery[$order['delivery']['code']];
|
||||
$data['payment'] = $this->payment[$order['paymentType']];
|
||||
$data['shipping_code'] = $delivery != null ? $this->delivery[$delivery] : $this->delivery_default;
|
||||
$data['payment'] = $payment != null ? $this->payment[$payment] : $this->payment_default;
|
||||
$data['payment_method'] = $this->ocPayment[$data['payment']];
|
||||
$data['payment_code'] = $this->payment[$order['paymentType']];
|
||||
$data['payment_code'] = $payment != null ? $this->payment[$payment] : $this->payment_default;
|
||||
|
||||
// this data will not retrive from crm for now
|
||||
$data['tax'] = '';
|
||||
|
@ -5,6 +5,7 @@ class ModelExtensionRetailcrmHistoryV45 extends Model
|
||||
protected $createResult;
|
||||
|
||||
private $opencartApiClient;
|
||||
private $customFieldSetting;
|
||||
|
||||
public function request()
|
||||
{
|
||||
@ -82,7 +83,8 @@ class ModelExtensionRetailcrmHistoryV45 extends Model
|
||||
$this->delivery = array_flip($settings[$this->moduleTitle . '_delivery']);
|
||||
$this->payment = array_flip($settings[$this->moduleTitle . '_payment']);
|
||||
$this->status = array_flip($settings[$this->moduleTitle . '_status']);
|
||||
|
||||
$this->delivery_default = $settings[$this->moduleTitle . '_default_shipping'];
|
||||
$this->payment_default = $settings[$this->moduleTitle . '_default_payment'];
|
||||
$this->ocPayment = $this->model_extension_retailcrm_references
|
||||
->getOpercartPaymentTypes();
|
||||
|
||||
@ -90,6 +92,10 @@ class ModelExtensionRetailcrmHistoryV45 extends Model
|
||||
|
||||
$this->zones = $this->model_localisation_zone->getZones();
|
||||
|
||||
if (isset($settings[$this->moduleTitle . '_custom_field'])) {
|
||||
$this->customFieldSetting = array_flip($settings[$this->moduleTitle . '_custom_field']);
|
||||
}
|
||||
|
||||
$updatedOrders = array();
|
||||
$newOrders = array();
|
||||
|
||||
@ -163,7 +169,7 @@ class ModelExtensionRetailcrmHistoryV45 extends Model
|
||||
foreach ($orders as $order) {
|
||||
$store = $this->config->get('config_store_id');
|
||||
|
||||
if (isset($order['payments'])) {
|
||||
if ($order['payments']) {
|
||||
foreach ($order['payments'] as $orderPayment) {
|
||||
if (isset($orderPayment['externalId'])) {
|
||||
$payment = $orderPayment;
|
||||
@ -240,6 +246,7 @@ class ModelExtensionRetailcrmHistoryV45 extends Model
|
||||
$paymentCountry = $this->getCountryByIsoCode($order['customer']['address']['countryIso']);
|
||||
}
|
||||
|
||||
$delivery = isset($order['delivery']['code']) ? $order['delivery']['code'] : null;
|
||||
$data['payment_country_id'] = $paymentCountry ? $paymentCountry['country_id'] : 0;
|
||||
$data['payment_zone_id'] = $payment_zone_id;
|
||||
$data['shipping_country_id'] = $shippingCountry ? $shippingCountry['country_id'] : 0;
|
||||
@ -253,9 +260,9 @@ class ModelExtensionRetailcrmHistoryV45 extends Model
|
||||
$data['shipping_company_id'] = '';
|
||||
$data['shipping_city'] = $order['delivery']['address']['city'];
|
||||
$data['shipping_postcode'] = $order['delivery']['address']['index'];
|
||||
$data['shipping'] = $this->delivery[$order['delivery']['code']];
|
||||
$data['shipping'] = $delivery != null ? $this->delivery[$delivery] : $this->delivery_default;
|
||||
$data['shipping_method'] = $this->ocDelivery[$data['shipping']];
|
||||
$data['shipping_code'] = $this->delivery[$order['delivery']['code']];
|
||||
$data['shipping_code'] = $delivery != null ? $this->delivery[$delivery] : $this->delivery_default;
|
||||
|
||||
if (isset($payment)) {
|
||||
$data['payment'] = $this->payment[$payment['type']];
|
||||
@ -318,6 +325,17 @@ class ModelExtensionRetailcrmHistoryV45 extends Model
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($this->customFieldSetting) && $order['customFields']) {
|
||||
foreach ($order['customFields'] as $code => $value) {
|
||||
if (array_key_exists($code, $this->customFieldSetting)) {
|
||||
$fieldCode = str_replace('o_', '', $this->customFieldSetting[$code]);
|
||||
$customFields[$fieldCode] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$data['custom_field'] = isset($customFields) ? $customFields : '';
|
||||
}
|
||||
|
||||
$deliveryCost = !empty($order['delivery']['cost']) ? $order['delivery']['cost'] : 0;
|
||||
|
||||
if(isset($order['discount']) && $order['discount'] > 0) {
|
||||
@ -377,7 +395,7 @@ class ModelExtensionRetailcrmHistoryV45 extends Model
|
||||
foreach ($orders as $order) {
|
||||
$store = $this->config->get('config_store_id');
|
||||
|
||||
if (isset($order['payments'])) {
|
||||
if ($order['payments']) {
|
||||
$payment = end($order['payments']);
|
||||
} elseif (isset($order['paymentType'])) {
|
||||
$payment['type'] = $order['paymentType'];
|
||||
@ -498,6 +516,7 @@ class ModelExtensionRetailcrmHistoryV45 extends Model
|
||||
$paymentCountry = $this->getCountryByIsoCode($order['customer']['address']['countryIso']);
|
||||
}
|
||||
|
||||
$delivery = isset($order['delivery']['code']) ? $order['delivery']['code'] : null;
|
||||
$data['payment_country_id'] = $paymentCountry ? $paymentCountry['country_id'] : 0;
|
||||
$data['payment_zone_id'] = $payment_zone_id;
|
||||
$data['shipping_country_id'] = $shippingCountry ? $shippingCountry['country_id'] : 0;
|
||||
@ -511,15 +530,18 @@ class ModelExtensionRetailcrmHistoryV45 extends Model
|
||||
$data['shipping_company_id'] = '';
|
||||
$data['shipping_city'] = $order['delivery']['address']['city'];
|
||||
$data['shipping_postcode'] = $order['delivery']['address']['index'];
|
||||
|
||||
$data['shipping'] = $this->delivery[$order['delivery']['code']];
|
||||
$data['shipping'] = $delivery != null ? $this->delivery[$delivery] : $this->delivery_default;
|
||||
$data['shipping_method'] = $this->ocDelivery[$data['shipping']];
|
||||
$data['shipping_code'] = $this->delivery[$order['delivery']['code']];
|
||||
$data['shipping_code'] = $delivery != null ? $this->delivery[$delivery] : $this->delivery_default;
|
||||
|
||||
if (isset($payment)) {
|
||||
$data['payment'] = $this->payment[$payment['type']];
|
||||
$data['payment_method'] = $this->ocPayment[$data['payment']];
|
||||
$data['payment_code'] = $this->payment[$payment['type']];
|
||||
} else {
|
||||
$data['payment'] = $this->payment_default;
|
||||
$data['payment_method'] = $this->ocPayment[$data['payment']];
|
||||
$data['payment_code'] = $this->payment_default;
|
||||
}
|
||||
|
||||
// this data will not retrive from crm for now
|
||||
@ -572,6 +594,17 @@ class ModelExtensionRetailcrmHistoryV45 extends Model
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($this->customFieldSetting) && $order['customFields']) {
|
||||
foreach ($order['customFields'] as $code => $value) {
|
||||
if (array_key_exists($code, $this->customFieldSetting)) {
|
||||
$fieldCode = str_replace('o_', '', $this->customFieldSetting[$code]);
|
||||
$customFields[$fieldCode] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$data['custom_field'] = isset($customFields) ? $customFields : '';
|
||||
}
|
||||
|
||||
$deliveryCost = !empty($order['delivery']['cost']) ? $order['delivery']['cost'] : 0;
|
||||
|
||||
$data['order_total'] = array(
|
||||
@ -614,12 +647,6 @@ class ModelExtensionRetailcrmHistoryV45 extends Model
|
||||
|
||||
protected function updateCustomers($customers)
|
||||
{
|
||||
$settings = $this->model_setting_setting->getSetting($this->moduleTitle);
|
||||
|
||||
if (isset($settings[$this->moduleTitle . '_custom_field'])) {
|
||||
$settings = array_flip($settings[$this->moduleTitle . '_custom_field']);
|
||||
}
|
||||
|
||||
foreach ($customers as $customer) {
|
||||
|
||||
$customer_id = $customer['externalId'];
|
||||
@ -656,10 +683,11 @@ class ModelExtensionRetailcrmHistoryV45 extends Model
|
||||
|
||||
$customerData['address'] = array($customerAddress);
|
||||
|
||||
if ($settings && $customer['customFields']) {
|
||||
if (isset($this->customFieldSetting) && $customer['customFields']) {
|
||||
foreach ($customer['customFields'] as $code => $value) {
|
||||
if (array_key_exists($code, $settings)) {
|
||||
$customFields[$settings[$code]] = $value;
|
||||
if (array_key_exists($code, $this->customFieldSetting)) {
|
||||
$fieldCode = str_replace('c_', '', $this->customFieldSetting[$code]);
|
||||
$customFields[$fieldCode] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -172,6 +172,20 @@ class ModelExtensionRetailcrmOrder extends Model {
|
||||
$order['items'][] = $item;
|
||||
}
|
||||
|
||||
if (isset($this->settings[$this->moduleTitle . '_custom_field']) && $order_data['custom_field']) {
|
||||
$customFields = json_decode($order_data['custom_field']);
|
||||
|
||||
foreach ($customFields as $key => $value) {
|
||||
if (isset($this->settings[$moduleTitle . '_custom_field']['o_' . $key])) {
|
||||
$customFieldsToCrm[$this->settings[$this->moduleTitle . '_custom_field']['o_' . $key]] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($customFieldsToCrm)) {
|
||||
$order['customFields'] = $customFieldsToCrm;
|
||||
}
|
||||
}
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ class ModelExtensionRetailcrmReferences extends Model
|
||||
{
|
||||
return array(
|
||||
'opencart' => $this->getOpencartCustomFields(),
|
||||
'retailcrm' => $this->getApiCustomerCustomFields()
|
||||
'retailcrm' => $this->getApiCustomFields()
|
||||
);
|
||||
}
|
||||
|
||||
@ -119,14 +119,21 @@ class ModelExtensionRetailcrmReferences extends Model
|
||||
return (!$response->isSuccessful()) ? array() : $response->paymentTypes;
|
||||
}
|
||||
|
||||
public function getApiCustomerCustomFields()
|
||||
public function getApiCustomFields()
|
||||
{
|
||||
$this->initApi();
|
||||
|
||||
$filter = array('entity' => 'customer');
|
||||
$response = $this->retailcrm->customFieldsList($filter);
|
||||
$customers = $this->retailcrm->customFieldsList(array('entity' => 'customer'));
|
||||
$orders = $this->retailcrm->customFieldsList(array('entity' => 'order'));
|
||||
|
||||
return (!$response->isSuccessful()) ? array() : $response->customFields;
|
||||
$customFieldsCustomers = (!$customers->isSuccessful()) ? array() : $customers->customFields;
|
||||
$customFieldsOrders = (!$orders->isSuccessful()) ? array() : $orders->customFields;
|
||||
|
||||
if (!$customFieldsCustomers && !$customFieldsOrders) {
|
||||
return array();
|
||||
}
|
||||
|
||||
return array('customers' => $customFieldsCustomers, 'orders' => $customFieldsOrders);
|
||||
}
|
||||
|
||||
protected function initApi()
|
||||
|
@ -149,7 +149,32 @@
|
||||
<label for="retailcrm_payment_<?php echo $key; ?>"><?php echo $value; ?></label>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<h4><?php echo $retailcrm_dict_default; ?></h4>
|
||||
<div class="retailcrm_unit">
|
||||
<select id="retailcrm_default_payment" name="retailcrm_default_payment" >
|
||||
<?php foreach ($payments['opencart'] as $k => $v): ?>
|
||||
<option value="<?php echo $k;?>" <?php if(isset($saved_settings['retailcrm_default_payment']) && $k == $saved_settings['retailcrm_default_payment']):?>selected="selected"<?php endif;?>>
|
||||
<?php echo $v;?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<label for="retailcrm_default_payment"><?php echo $text_payment; ?></label>
|
||||
</div>
|
||||
<div class="retailcrm_unit">
|
||||
<select id="retailcrm_default_shipping" name="retailcrm_default_shipping" >
|
||||
<?php foreach ($delivery['opencart'] as $key => $value): ?>
|
||||
<optgroup label="<?php echo $value['title']; ?>">
|
||||
<?php unset($value['title']); ?>
|
||||
<?php foreach ($value as $v): ?>
|
||||
<option value="<?php echo $v['code'];?>" <?php if(isset($saved_settings['retailcrm_default_shipping']) && $v['code'] == $saved_settings['retailcrm_default_shipping']):?>selected="selected"<?php endif;?>>
|
||||
<?php echo $v['title'];?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</optgroup>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<label for="retailcrm_default_payment"><?php echo $text_shipping; ?></label>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endif; ?>
|
||||
@ -176,8 +201,6 @@
|
||||
<label for="retailcrm_collector" class="col-md-4"><?php echo $collector_site_key; ?></label>
|
||||
<input id="retailcrm_collector_site_key" type="text" name="retailcrm_collector[site_key]" value="<?php if (isset($saved_settings['retailcrm_collector']['site_key'])): echo $saved_settings['retailcrm_collector']['site_key']; endif; ?>">
|
||||
</div>
|
||||
<?php if (!empty($saved_settings['retailcrm_collector']['site_key']) &&
|
||||
$saved_settings['retailcrm_collector_active'] == 1) :?>
|
||||
<div class="retailcrm_unit">
|
||||
<label for="retailcrm_collector" class="col-md-4"><?php echo $text_collector_form_capture; ?></label>
|
||||
<label class="radio-inline">
|
||||
@ -193,8 +216,6 @@
|
||||
<?php echo $text_no; ?>
|
||||
</label>
|
||||
</div>
|
||||
<?php if (isset($saved_settings['retailcrm_collector']['form_capture']) &&
|
||||
$saved_settings['retailcrm_collector']['form_capture'] == 1) :?>
|
||||
<div class="retailcrm_unit">
|
||||
<label for="retailcrm_collector" class="col-md-4"><?php echo $text_collector_period; ?></label>
|
||||
<input id="retailcrm_collector_period" type="text" name="retailcrm_collector[period]" value="<?php if (isset($saved_settings['retailcrm_collector']['period'])): echo $saved_settings['retailcrm_collector']['period']; endif; ?>">
|
||||
@ -222,8 +243,6 @@
|
||||
<?php echo $text_no; ?>
|
||||
</label>
|
||||
</div>
|
||||
<?php if (isset($saved_settings['retailcrm_collector']['custom_form']) &&
|
||||
$saved_settings['retailcrm_collector']['custom_form'] == 1) :?>
|
||||
<?php foreach ($collectorFields as $field => $label) : ?>
|
||||
<div class="retailcrm_unit">
|
||||
<label for="retailcrm_collector" class="col-md-4"><?php echo $label; ?></label>
|
||||
@ -234,19 +253,46 @@
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php if (isset($saved_settings['retailcrm_apiversion']) && $saved_settings['retailcrm_apiversion'] == 'v5' && isset($customFields)) : ?>
|
||||
<div class="tab-pane" id="tab-custom_fields">
|
||||
<h4><?php echo $retailcrm_dict_custom_fields; ?></h4>
|
||||
<h3><?php echo $retailcrm_dict_custom_fields; ?></h3>
|
||||
<?php if ($customFields['retailcrm'] && $customFields['opencart']) : ?>
|
||||
<div class="retailcrm_unit">
|
||||
<label for="retailcrm_custom_field_active"><?php echo $text_custom_field_activity; ?></label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="retailcrm_custom_field_active" value="1" <?php if (isset($saved_settings['retailcrm_custom_field_active']) &&
|
||||
$saved_settings['retailcrm_custom_field_active'] == 1) :
|
||||
echo 'checked'; endif; ?>>
|
||||
<?php echo $text_yes; ?>
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="retailcrm_custom_field_active" value="0" <?php if (!isset($saved_settings['retailcrm_custom_field_active']) ||
|
||||
$saved_settings['retailcrm_custom_field_active'] == 0) :
|
||||
echo 'checked'; endif; ?>>
|
||||
<?php echo $text_no; ?>
|
||||
</label>
|
||||
</div>
|
||||
<h4><?php echo $text_customers_custom_fields; ?></h4>
|
||||
<?php foreach ($customFields['opencart'] as $customField) : ?>
|
||||
<?php $fid = $customField['custom_field_id'] ?>
|
||||
<?php $fid = 'c_' . $customField['custom_field_id'] ?>
|
||||
<div class="retailcrm_unit">
|
||||
<select id="retailcrm_custom_field_<?php echo $fid; ?>" name="retailcrm_custom_field[<?php echo $fid; ?>]" >
|
||||
<?php foreach ($customFields['retailcrm'] as $v): ?>
|
||||
<?php foreach ($customFields['retailcrm']['customers'] as $v): ?>
|
||||
<option value="<?php echo $v['code'];?>" <?php if(isset($saved_settings['retailcrm_custom_field'][$fid]) && $v['code'] == $saved_settings['retailcrm_custom_field'][$fid]):?>selected="selected"<?php endif;?>>
|
||||
<?php echo $v['name'];?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<label for="retailcrm_custom_field_<?php echo $fid; ?>"><?php echo $customField['name']; ?></label>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<h4><?php echo $text_orders_custom_fields; ?></h4>
|
||||
<?php foreach ($customFields['opencart'] as $customField) : ?>
|
||||
<?php $fid = 'o_' . $customField['custom_field_id'] ?>
|
||||
<div class="retailcrm_unit">
|
||||
<select id="retailcrm_custom_field_<?php echo $fid; ?>" name="retailcrm_custom_field[<?php echo $fid; ?>]" >
|
||||
<?php foreach ($customFields['retailcrm']['orders'] as $v): ?>
|
||||
<option value="<?php echo $v['code'];?>" <?php if(isset($saved_settings['retailcrm_custom_field'][$fid]) && $v['code'] == $saved_settings['retailcrm_custom_field'][$fid]):?>selected="selected"<?php endif;?>>
|
||||
<?php echo $v['name'];?>
|
||||
</option>
|
||||
|
@ -42,6 +42,9 @@
|
||||
{% if saved_settings.module_retailcrm_apikey is defined and saved_settings.module_retailcrm_apikey and saved_settings.module_retailcrm_url is defined and saved_settings.module_retailcrm_url %}
|
||||
<li><a href="#tab-references" data-toggle="tab">{{ references_tab_text }}</a></li>
|
||||
<li><a href="#tab-collector" data-toggle="tab">{{ collector_tab_text }}</a></li>
|
||||
{% if saved_settings.module_retailcrm_apiversion == 'v5' %}
|
||||
<li><a href="#tab-custom_fields" data-toggle="tab"> {{ custom_fields_tab_text }} </a></li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
||||
@ -147,7 +150,33 @@
|
||||
<label for="retailcrm_payment_{{ key }}">{{ value }}</label>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<h4>{{ retailcrm_dict_default }}</h4>
|
||||
<div class="retailcrm_unit">
|
||||
<select id="retailcrm_default_payment" name="retailcrm_default_payment" >
|
||||
{% for k, v in payments.opencart %}
|
||||
<option value="{{ k }}" {% if saved_settings.retailcrm_default_payment is defined and k == saved_settings.retailcrm_default_payment %} selected="selected" {% endif %}>
|
||||
{{ v }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<label for="retailcrm_default_payment">{{ text_payment }}</label>
|
||||
</div>
|
||||
<div class="retailcrm_unit">
|
||||
<select id="retailcrm_default_shipping" name="retailcrm_default_shipping" >
|
||||
{% for key, value in delivery.opencart %}
|
||||
<optgroup label="{{ value.title }}">
|
||||
{% for k, v in value %}
|
||||
{% if k != 'title' %}
|
||||
<option value="{{ v.code }}" {% if saved_settings.retailcrm_default_shipping is defined and v.code == saved_settings.retailcrm_default_shipping %} selected="selected" {% endif %}>
|
||||
{{ v.title }}
|
||||
</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</optgroup>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<label for="retailcrm_default_payment">{{ text_shipping }}</label>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
@ -174,8 +203,6 @@
|
||||
<label for="retailcrm_collector" class="col-md-4">{{ collector_site_key }}</label>
|
||||
<input id="retailcrm_collector_site_key" type="text" name="module_retailcrm_collector[site_key]" value="{% if saved_settings.module_retailcrm_collector.site_key is defined %}{{ saved_settings.module_retailcrm_collector.site_key }}{% endif %}">
|
||||
</div>
|
||||
{% if saved_settings.module_retailcrm_collector.site_key is not empty and
|
||||
saved_settings.module_retailcrm_collector_active == 1 %}
|
||||
<div class="retailcrm_unit">
|
||||
<label for="retailcrm_collector" class="col-md-4">{{ text_collector_form_capture }}</label>
|
||||
<label class="radio-inline">
|
||||
@ -191,22 +218,20 @@
|
||||
{{ text_no }}
|
||||
</label>
|
||||
</div>
|
||||
{% if saved_settings.module_retailcrm_collector.form_capture is defined and
|
||||
saved_settings.module_retailcrm_collector.form_capture == 1 %}
|
||||
<div class="retailcrm_unit">
|
||||
<label for="retailcrm_collector" class="col-md-4">{{ text_collector_period }}</label>
|
||||
<input id="retailcrm_collector_period" type="text" name="module_retailcrm_collector[period]" value="{% if saved_settings.module_retailcrm_collector.period is defined %}{{ saved_settings.module_retailcrm_collector.period }}{% endif %}">
|
||||
<label for="module_retailcrm_collector" class="col-md-4">{{ text_collector_period }}</label>
|
||||
<input id="module_retailcrm_collector_period" type="text" name="module_retailcrm_collector[period]" value="{% if saved_settings.module_retailcrm_collector.period is defined %}{{ saved_settings.module_retailcrm_collector.period }}{% endif %}">
|
||||
</div>
|
||||
<div class="retailcrm_unit">
|
||||
<label for="retailcrm_collector" class="col-md-4">{{ text_label_promo }}</label>
|
||||
<input id="retailcrm_collector[]" type="text" name="module_retailcrm_collector[label_promo]" value="{% if saved_settings.module_retailcrm_collector.label_promo is defined %}{{ saved_settings.module_retailcrm_collector.label_promo }}{% endif %}">
|
||||
<label for="module_retailcrm_collector" class="col-md-4">{{ text_label_promo }}</label>
|
||||
<input id="module_retailcrm_collector[]" type="text" name="module_retailcrm_collector[label_promo]" value="{% if saved_settings.module_retailcrm_collector.label_promo is defined %}{{ saved_settings.module_retailcrm_collector.label_promo }}{% endif %}">
|
||||
</div>
|
||||
<div class="retailcrm_unit">
|
||||
<label for="retailcrm_collector" class="col-md-4">{{ text_label_send }}</label>
|
||||
<input id="retailcrm_collector_label_send" type="text" name="module_retailcrm_collector[label_send]" value="{% if saved_settings.module_retailcrm_collector.label_send is defined %} {{ saved_settings.module_retailcrm_collector.label_send }} {% endif %}">
|
||||
<label for="module_retailcrm_collector" class="col-md-4">{{ text_label_send }}</label>
|
||||
<input id="module_retailcrm_collector_label_send" type="text" name="module_retailcrm_collector[label_send]" value="{% if saved_settings.module_retailcrm_collector.label_send is defined %}{{ saved_settings.module_retailcrm_collector.label_send }}{% endif %}">
|
||||
</div>
|
||||
<div class="retailcrm_unit">
|
||||
<label for="retailcrm_collector" class="col-md-4">{{ collector_custom_text }}</label>
|
||||
<label for="module_retailcrm_collector" class="col-md-4">{{ collector_custom_text }}</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="module_retailcrm_collector[custom_form]" value="1" {% if saved_settings.module_retailcrm_collector.custom_form is defined and
|
||||
saved_settings.module_retailcrm_collector.custom_form == 1 %} {{ 'checked' }}
|
||||
@ -214,43 +239,68 @@
|
||||
{{ text_yes }}
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="module_retailcrm_collector[custom_form]" value="0" {% if saved_settings.module_retailcrm_collector.custom_form is defined or
|
||||
<input type="radio" name="module_retailcrm_collector[custom_form]" value="0" {% if saved_settings.module_retailcrm_collector.custom_form is not defined or
|
||||
saved_settings.module_retailcrm_collector.custom_form == 0 %} {{ 'checked' }}
|
||||
{% endif %}>
|
||||
{{ text_no }}
|
||||
</label>
|
||||
</div>
|
||||
{% if saved_settings.module_retailcrm_collector.custom_form is defined and
|
||||
saved_settings.module_retailcrm_collector.custom_form == 1 %}
|
||||
{% for field, label in collectorFields %}
|
||||
<div class="retailcrm_unit">
|
||||
<label for="retailcrm_collector" class="col-md-4">{{ label }}</label>
|
||||
<div class="col-md-8">
|
||||
{# <input id="retailcrm_collector" type="text" name="module_retailcrm_collector[custom][{{ field }}]" value="{% if saved_settings.module_retailcrm_collector.custom.{{ field }} is defined %} {{ saved_settings.module_retailcrm_collector.custom.{{ field }} {% endif %}"> #}
|
||||
<input type="checkbox" name="module_retailcrm_collector[require][{{ field }}_require]" value="1" {% if saved_settings.module_retailcrm_collector.require.field ~'_require' %} {{ 'checked' }} {% endif %}>
|
||||
<input id="module_retailcrm_collector" type="text" name="module_retailcrm_collector[custom][{{ field }}]" value="{% if saved_settings.module_retailcrm_collector.custom[field] is defined %} {{ saved_settings.module_retailcrm_collector.custom[field] }} {% endif %}">
|
||||
<input type="checkbox" name="module_retailcrm_collector[require][{{ field }}_require]" value="1" {% if saved_settings.module_retailcrm_collector.require[field ~'_require'] %} checked {% endif %}>
|
||||
<label for="retailcrm_collector">{{ text_require }}</label>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if saved_settings.retailcrm_apiversion is defined and saved_settings.retailcrm_apiversion == 'v5' and customFields is defined %}
|
||||
{% if saved_settings.module_retailcrm_apiversion is defined and saved_settings.module_retailcrm_apiversion == 'v5' and customFields is defined %}
|
||||
<div class="tab-pane" id="tab-custom_fields">
|
||||
<h4>{{ retailcrm_dict_custom_fields }}</h4>
|
||||
{% if customFields.retailcrm is not empty and customFields.opencart is not empty %}
|
||||
{% for customField in customFields.opencart %}
|
||||
{% set fid = customField.custom_field_id %}
|
||||
<div class="retailcrm_unit">
|
||||
<select id="retailcrm_custom_field_{{ fid }}" name="retailcrm_custom_field[{{ fid }}]" >
|
||||
{% for v in customFields.retailcrm %}
|
||||
<option value="{{ v.code }}" {% if saved_settings.retailcrm_custom_field.fid is defined and v.code == saved_settings.retailcrm_custom_field.fid %} selected="selected" {% endif %}>
|
||||
<label for="retailcrm_custom_field_active">{{ text_custom_field_activity }}</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="module_retailcrm_custom_field_active" value="1" {% if saved_settings.module_retailcrm_custom_field_active is defined and
|
||||
saved_settings.module_retailcrm_custom_field_active == 1 %}
|
||||
checked {% endif %} >
|
||||
{{ text_yes }}
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="module_retailcrm_custom_field_active" value="0" {% if saved_settings.module_retailcrm_custom_field_active is not defined or
|
||||
saved_settings.module_retailcrm_custom_field_active == 0 %}
|
||||
checked {% endif %} >
|
||||
{{ text_no }}
|
||||
</label>
|
||||
</div>
|
||||
<h4>{{ text_customers_custom_fields }}</h4>
|
||||
{% for customField in customFields.opencart %}
|
||||
{% set fid = 'c_' ~ customField.custom_field_id %}
|
||||
<div class="retailcrm_unit">
|
||||
<select id="module_retailcrm_custom_field_{{ fid }}" name="module_retailcrm_custom_field[{{ fid }}]" >
|
||||
{% for v in customFields.retailcrm.customers %}
|
||||
<option value="{{ v.code }}" {% if saved_settings.module_retailcrm_custom_field[fid] is defined and v.code == saved_settings.module_retailcrm_custom_field[fid] %} selected="selected" {% endif %}>
|
||||
{{ v.name }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<label for="retailcrm_custom_field_{{ fid }}">{{ customField.name }}</label>
|
||||
<label for="module_retailcrm_custom_field_{{ fid }}">{{ customField.name }}</label>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<h4>{{ text_orders_custom_fields }}</h4>
|
||||
{% for customField in customFields.opencart %}
|
||||
{% set fid = 'o_' ~ customField.custom_field_id %}
|
||||
<div class="retailcrm_unit">
|
||||
<select id="module_retailcrm_custom_field_{{ fid }}" name="module_retailcrm_custom_field[{{ fid }}]" >
|
||||
{% for v in customFields.retailcrm.orders %}
|
||||
<option value="{{ v.code }}" {% if saved_settings.module_retailcrm_custom_field[fid] is defined and v.code == saved_settings.module_retailcrm_custom_field[fid] %} selected="selected" {% endif %}>
|
||||
{{ v.name }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<label for="module_retailcrm_custom_field_{{ fid }}">{{ customField.name }}</label>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% elseif customFields.retailcrm is empty and customFields.opencart is empty %}
|
||||
|
@ -20,7 +20,11 @@ class ControllerExtensionAnalyticsDaemonCollector extends Controller {
|
||||
$cntEmpty = 0;
|
||||
|
||||
foreach ($setting['custom'] as $field => $label) {
|
||||
if (empty($label)) { $cntEmpty += 1; continue; }
|
||||
if (empty($label)) {
|
||||
$cntEmpty += 1;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isset($setting['require'][$field . '_require'])) {
|
||||
$customForm .= "\n\t'$field': { required: true, label: '$label' },";
|
||||
@ -46,7 +50,7 @@ class ControllerExtensionAnalyticsDaemonCollector extends Controller {
|
||||
});";
|
||||
} else {
|
||||
$captureForm = "_rc('require', 'capture-form', {
|
||||
'period': " . $settings['retailcrm_collector']['period'] . ",
|
||||
'period': " . $settings[$moduleTitle . '_collector']['period'] . ",
|
||||
" . $customForm . "
|
||||
});";
|
||||
}
|
||||
@ -67,14 +71,18 @@ class ControllerExtensionAnalyticsDaemonCollector extends Controller {
|
||||
$captureForm = "";
|
||||
}
|
||||
|
||||
$js = "<script type=\"text/javascript\">
|
||||
(function(_,r,e,t,a,i,l){_['retailCRMObject']=a;_[a]=_[a]||function(){(_[a].q=_[a].q||[]).push(arguments)};_[a].l=1*new Date();l=r.getElementsByTagName(e)[0];i=r.createElement(e);i.async=!0;i.src=t;l.parentNode.insertBefore(i,l)})(window,document,'script','https://collector.retailcrm.pro/w.js','_rc');
|
||||
|
||||
_rc('create', '" . $siteCode . "', {
|
||||
if (!$customer) {
|
||||
$initClient = "_rc('create', '" . $siteCode . "');";
|
||||
} else {
|
||||
$initClient = "_rc('create', '" . $siteCode . "', {
|
||||
" . $customer . "
|
||||
});
|
||||
" . $captureForm . "
|
||||
_rc('send', 'pageView');
|
||||
});";
|
||||
}
|
||||
|
||||
$js = "<script type=\"text/javascript\">
|
||||
(function(_,r,e,t,a,i,l){_['retailCRMObject']=a;_[a]=_[a]||function(){(_[a].q=_[a].q||[]).push(arguments)};_[a].l=1*new Date();l=r.getElementsByTagName(e)[0];i=r.createElement(e);i.async=!0;i.src=t;l.parentNode.insertBefore(i,l)})(window,document,'script','https://collector.retailcrm.pro/w.js','_rc');"
|
||||
. $initClient . $captureForm .
|
||||
"_rc('send', 'pageView');
|
||||
</script>";
|
||||
|
||||
return html_entity_decode($js, ENT_QUOTES, 'UTF-8');
|
||||
|
@ -55,13 +55,15 @@ class ModelExtensionRetailcrmCustomer extends Model {
|
||||
$customFields = json_decode($customer['custom_field']);
|
||||
|
||||
foreach ($customFields as $key => $value) {
|
||||
if (isset($this->settings[$moduleTitle . '_custom_field'][$key])) {
|
||||
$customFieldsToCrm[$this->settings[$moduleTitle . '_custom_field'][$key]] = $value;
|
||||
if (isset($this->settings[$moduleTitle . '_custom_field']['c_' . $key])) {
|
||||
$customFieldsToCrm[$this->settings[$moduleTitle . '_custom_field']['c_' . $key]] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($customFieldsToCrm)) {
|
||||
$customerToCrm['customFields'] = $customFieldsToCrm;
|
||||
}
|
||||
}
|
||||
|
||||
return $customerToCrm;
|
||||
}
|
||||
|
@ -63,10 +63,12 @@ class ModelExtensionRetailcrmOrder extends Model {
|
||||
|
||||
if ($this->settings[$this->moduleTitle . '_apiversion'] == 'v5' && $response->isSuccessful()) {
|
||||
$response_order = $this->retailcrm->ordersGet($order_id);
|
||||
if ($response_order->isSuccessful()) $order_info = $response_order['order'];
|
||||
if ($response_order->isSuccessful()) {
|
||||
$order_info = $response_order['order'];
|
||||
}
|
||||
|
||||
foreach ($order_info['payments'] as $payment_data) {
|
||||
if ($payment_data['externalId'] == $order_id) {
|
||||
if (isset($payment_data['externalId']) && $payment_data['externalId'] == $order_id) {
|
||||
$payment = $payment_data;
|
||||
}
|
||||
}
|
||||
@ -234,6 +236,20 @@ class ModelExtensionRetailcrmOrder extends Model {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->settings[$this->moduleTitle . '_custom_field']) && $order_data['custom_field']) {
|
||||
$customFields = $order_data['custom_field'];
|
||||
|
||||
foreach ($customFields as $key => $value) {
|
||||
if (isset($this->settings[$this->moduleTitle . '_custom_field']['o_' . $key])) {
|
||||
$customFieldsToCrm[$this->settings[$this->moduleTitle . '_custom_field']['o_' . $key]] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($customFieldsToCrm)) {
|
||||
$order['customFields'] = $customFieldsToCrm;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $order;
|
||||
|
@ -138,8 +138,13 @@ class OpencartApiClient {
|
||||
'lastname' => $data['lastname'],
|
||||
'email' => $data['email'],
|
||||
'telephone' => !empty($data['telephone']) ? $data['telephone'] : '0000',
|
||||
'fax' => $data['fax'],
|
||||
'fax' => $data['fax']
|
||||
);
|
||||
|
||||
if (isset($data['custom_field'])) {
|
||||
$customer['custom_field'] = $data['custom_field'];
|
||||
}
|
||||
|
||||
$this->request('customer', array(), $customer);
|
||||
|
||||
$products = array();
|
||||
|
@ -63,7 +63,7 @@
|
||||
<field id="shipment_date" group="order">shipmentDate</field>
|
||||
<field id="shipped" group="order">shipped</field>
|
||||
<!--<field id="order_product" group="order">item</field>-->
|
||||
<field id="payment" group="order">payments</field>
|
||||
<field id="payment" group="order">payment</field>
|
||||
<field id="payments.amount" group="order">amount</field>
|
||||
<field id="payments.paid_at" group="order">paidAt</field>
|
||||
<field id="payments.comment" group="order">comment</field>
|
||||
|
Loading…
Reference in New Issue
Block a user