Localization, universal analytics
This commit is contained in:
parent
8af75f020c
commit
52218b0d22
@ -1,3 +1,7 @@
|
|||||||
|
## 2018-03-21 v.2.1.2
|
||||||
|
* Добавлена локализация плагина
|
||||||
|
* Добавлена интеграция с UA
|
||||||
|
|
||||||
## 2018-03-12 v.2.1.1
|
## 2018-03-12 v.2.1.1
|
||||||
* Исправлена ошибка редактирования информации о клиенте
|
* Исправлена ошибка редактирования информации о клиенте
|
||||||
|
|
||||||
|
@ -28,8 +28,8 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->id = 'integration-retailcrm';
|
$this->id = 'integration-retailcrm';
|
||||||
$this->method_title = __( 'RetailCRM', 'woocommerce-integration-retailcrm' );
|
$this->method_title = __('RetailCRM', 'retailcrm');
|
||||||
$this->method_description = __( 'Интеграция с системой управления Retailcrm.', 'woocommerce-integration-retailcrm' );
|
$this->method_description = __('Integration with eComlogic managament system.', 'retailcrm');
|
||||||
|
|
||||||
// Load the settings.
|
// Load the settings.
|
||||||
|
|
||||||
@ -46,19 +46,19 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) :
|
|||||||
public function init_form_fields() {
|
public function init_form_fields() {
|
||||||
|
|
||||||
$this->form_fields = array(
|
$this->form_fields = array(
|
||||||
array( 'title' => __( 'General Options', 'woocommerce' ), 'type' => 'title', 'desc' => '', 'id' => 'general_options' ),
|
array( 'title' => __( 'General Options', 'retailcrm' ), 'type' => 'title', 'desc' => '', 'id' => 'general_options' ),
|
||||||
|
|
||||||
'api_url' => array(
|
'api_url' => array(
|
||||||
'title' => __( 'API URL', 'woocommerce-integration-retailcrm' ),
|
'title' => __( 'API URL', 'retailcrm' ),
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'description' => __( 'Введите адрес вашей CRM (https://yourdomain.retailcrm.ru).', 'woocommerce-integration-retailcrm' ),
|
'description' => __( 'Enter with your API URL (https://yourdomain.ecomlogic.com).', 'retailcrm' ),
|
||||||
'desc_tip' => true,
|
'desc_tip' => true,
|
||||||
'default' => ''
|
'default' => ''
|
||||||
),
|
),
|
||||||
'api_key' => array(
|
'api_key' => array(
|
||||||
'title' => __( 'API Key', 'woocommerce-integration-retailcrm' ),
|
'title' => __( 'API Key', 'retailcrm' ),
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'description' => __( 'Введите ключ API. Вы можете найти его в интерфейсе администратора Retailcrm.', 'woocommerce-integration-retailcrm' ),
|
'description' => __( 'Enter with your API Key. You can find this in eComlogic admin interface.', 'retailcrm' ),
|
||||||
'desc_tip' => true,
|
'desc_tip' => true,
|
||||||
'default' => ''
|
'default' => ''
|
||||||
)
|
)
|
||||||
@ -67,15 +67,15 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) :
|
|||||||
$api_version_list = array('v4' => 'v4','v5' => 'v5');
|
$api_version_list = array('v4' => 'v4','v5' => 'v5');
|
||||||
|
|
||||||
$this->form_fields[] = array(
|
$this->form_fields[] = array(
|
||||||
'title' => __( 'Настройки API', 'woocommerce' ),
|
'title' => __( 'API settings', 'retailcrm' ),
|
||||||
'type' => 'title',
|
'type' => 'title',
|
||||||
'description' => '',
|
'description' => '',
|
||||||
'id' => 'api_options'
|
'id' => 'api_options'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->form_fields['api_version'] = array(
|
$this->form_fields['api_version'] = array(
|
||||||
'title' => __( 'API версия', 'textdomain' ),
|
'title' => __( 'API version', 'retailcrm' ),
|
||||||
'description' => __( 'Выберите версию API, которую Вы хотите использовать', 'textdomain' ),
|
'description' => __( 'Select the API version you want to use', 'retailcrm' ),
|
||||||
'css' => 'min-width:50px;',
|
'css' => 'min-width:50px;',
|
||||||
'class' => 'select',
|
'class' => 'select',
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
@ -84,7 +84,7 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) :
|
|||||||
);
|
);
|
||||||
|
|
||||||
$this->form_fields[] = array(
|
$this->form_fields[] = array(
|
||||||
'title' => __( 'Настройки каталога', 'woocommerce' ),
|
'title' => __( 'Catalog settings', 'retailcrm' ),
|
||||||
'type' => 'title',
|
'type' => 'title',
|
||||||
'description' => '',
|
'description' => '',
|
||||||
'id' => 'catalog_options'
|
'id' => 'catalog_options'
|
||||||
@ -92,8 +92,8 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) :
|
|||||||
|
|
||||||
foreach (get_post_statuses() as $status_key => $status_value) {
|
foreach (get_post_statuses() as $status_key => $status_value) {
|
||||||
$this->form_fields['p_' . $status_key] = array(
|
$this->form_fields['p_' . $status_key] = array(
|
||||||
'title' => __( $status_value, 'textdomain' ),
|
'title' => $status_value,
|
||||||
'label' => __( ' ', 'textdomain' ),
|
'label' => ' ',
|
||||||
'description' => '',
|
'description' => '',
|
||||||
'class' => 'checkbox',
|
'class' => 'checkbox',
|
||||||
'type' => 'checkbox',
|
'type' => 'checkbox',
|
||||||
@ -127,18 +127,18 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->form_fields[] = array(
|
$this->form_fields[] = array(
|
||||||
'title' => __( 'Способы оформления заказа', 'woocommerce' ),
|
'title' => __('Order methods', 'retailcrm'),
|
||||||
'type' => 'heading',
|
'type' => 'heading',
|
||||||
'description' => '',
|
'description' => '',
|
||||||
'id' => 'order_methods_options'
|
'id' => 'order_methods_options'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->form_fields['order_methods'] = array(
|
$this->form_fields['order_methods'] = array(
|
||||||
'label' => __( ' ', 'textdomain' ),
|
'label' => ' ',
|
||||||
'title' => 'Способы оформления заказа, доступные для выгрузки из RetailCRM',
|
'title' => __('Ordering methods available for downloading from eComlogic', 'retailcrm'),
|
||||||
'class' => '',
|
'class' => '',
|
||||||
'type' => 'multiselect',
|
'type' => 'multiselect',
|
||||||
'description' => 'Выберите способы оформления для заказов, которые будут выгружаться из RetailCRM на сайт',
|
'description' => __('Select the order methods that will be uploaded from eComlogic to site', 'retailcrm'),
|
||||||
'options' => $order_methods_option,
|
'options' => $order_methods_option,
|
||||||
'select_buttons' => true
|
'select_buttons' => true
|
||||||
);
|
);
|
||||||
@ -158,7 +158,7 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) :
|
|||||||
$wc_shipping_list = get_wc_shipping_methods();
|
$wc_shipping_list = get_wc_shipping_methods();
|
||||||
|
|
||||||
$this->form_fields[] = array(
|
$this->form_fields[] = array(
|
||||||
'title' => __( 'Способы доставки', 'woocommerce' ),
|
'title' => __('Shipping methods', 'retailcrm'),
|
||||||
'type' => 'heading',
|
'type' => 'heading',
|
||||||
'description' => '',
|
'description' => '',
|
||||||
'id' => 'shipping_options'
|
'id' => 'shipping_options'
|
||||||
@ -167,8 +167,8 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) :
|
|||||||
foreach ( $wc_shipping_list as $shipping_code => $shipping ) {
|
foreach ( $wc_shipping_list as $shipping_code => $shipping ) {
|
||||||
if ( isset( $shipping['enabled'] ) && $shipping['enabled'] == 'yes' ) {
|
if ( isset( $shipping['enabled'] ) && $shipping['enabled'] == 'yes' ) {
|
||||||
$this->form_fields[$shipping_code] = array(
|
$this->form_fields[$shipping_code] = array(
|
||||||
'title' => __( $shipping['title'], 'textdomain' ),
|
'title' => __($shipping['title'], 'woocommerce'),
|
||||||
'description' => __( $shipping['description'], 'textdomain' ),
|
'description' => __($shipping['description'], 'woocommerce'),
|
||||||
'css' => 'min-width:350px;',
|
'css' => 'min-width:350px;',
|
||||||
'class' => 'select',
|
'class' => 'select',
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
@ -193,7 +193,7 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) :
|
|||||||
$wc_payment = new WC_Payment_Gateways();
|
$wc_payment = new WC_Payment_Gateways();
|
||||||
|
|
||||||
$this->form_fields[] = array(
|
$this->form_fields[] = array(
|
||||||
'title' => __( 'Способы оплаты', 'woocommerce' ),
|
'title' => __('Payment methods', 'retailcrm'),
|
||||||
'type' => 'heading',
|
'type' => 'heading',
|
||||||
'description' => '',
|
'description' => '',
|
||||||
'id' => 'payment_options'
|
'id' => 'payment_options'
|
||||||
@ -204,8 +204,8 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) :
|
|||||||
$key = $payment->id;
|
$key = $payment->id;
|
||||||
$name = $key;
|
$name = $key;
|
||||||
$this->form_fields[$name] = array(
|
$this->form_fields[$name] = array(
|
||||||
'title' => __( $payment->method_title, 'textdomain' ),
|
'title' => __($payment->method_title, 'woocommerce'),
|
||||||
'description' => __( $payment->method_description, 'textdomain' ),
|
'description' => __($payment->method_description, 'woocommerce'),
|
||||||
'css' => 'min-width:350px;',
|
'css' => 'min-width:350px;',
|
||||||
'class' => 'select',
|
'class' => 'select',
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
@ -230,7 +230,7 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) :
|
|||||||
$wc_statuses = wc_get_order_statuses();
|
$wc_statuses = wc_get_order_statuses();
|
||||||
|
|
||||||
$this->form_fields[] = array(
|
$this->form_fields[] = array(
|
||||||
'title' => __( 'Статусы', 'woocommerce' ),
|
'title' => __('Statuses', 'retailcrm'),
|
||||||
'type' => 'heading',
|
'type' => 'heading',
|
||||||
'description' => '',
|
'description' => '',
|
||||||
'id' => 'statuses_options'
|
'id' => 'statuses_options'
|
||||||
@ -239,7 +239,7 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) :
|
|||||||
foreach ( $wc_statuses as $idx => $name ) {
|
foreach ( $wc_statuses as $idx => $name ) {
|
||||||
$uid = str_replace('wc-', '', $idx);
|
$uid = str_replace('wc-', '', $idx);
|
||||||
$this->form_fields[$uid] = array(
|
$this->form_fields[$uid] = array(
|
||||||
'title' => __( $name, 'textdomain' ),
|
'title' => __($name, 'woocommerce'),
|
||||||
'css' => 'min-width:350px;',
|
'css' => 'min-width:350px;',
|
||||||
'class' => 'select',
|
'class' => 'select',
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
@ -253,18 +253,48 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) :
|
|||||||
* Inventories options
|
* Inventories options
|
||||||
*/
|
*/
|
||||||
$this->form_fields[] = array(
|
$this->form_fields[] = array(
|
||||||
'title' => __( 'Настройки выгрузки остатков', 'woocommerce' ),
|
'title' => __('Inventories settings', 'retailcrm'),
|
||||||
'type' => 'heading',
|
'type' => 'heading',
|
||||||
'description' => '',
|
'description' => '',
|
||||||
'id' => 'invent_options'
|
'id' => 'invent_options'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->form_fields['sync'] = array(
|
$this->form_fields['sync'] = array(
|
||||||
'label' => __( 'Выгружать остатки из CRM', 'textdomain' ),
|
'label' => __('Sync inventories', 'retailcrm'),
|
||||||
'title' => 'Остатки',
|
'title' => __('Inventories', 'retailcrm'),
|
||||||
'class' => 'checkbox',
|
'class' => 'checkbox',
|
||||||
'type' => 'checkbox',
|
'type' => 'checkbox',
|
||||||
'description' => 'Отметьте данный пункт, если хотите выгружать остатки товаров из CRM в магазин.'
|
'description' => __('Check this checkbox if you want to unload the rest of the products from CRM to site.', 'retailcrm')
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UA options
|
||||||
|
*/
|
||||||
|
$this->form_fields[] = array(
|
||||||
|
'title' => __('UA settings', 'retailcrm'),
|
||||||
|
'type' => 'heading',
|
||||||
|
'description' => '',
|
||||||
|
'id' => 'invent_options'
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->form_fields['ua'] = array(
|
||||||
|
'label' => __('Activate UA', 'retailcrm'),
|
||||||
|
'title' => __('UA', 'retailcrm'),
|
||||||
|
'class' => 'checkbox',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'description' => __('Check this checkbox if you want to unload information to UA.', 'retailcrm')
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->form_fields['ua_code'] = array(
|
||||||
|
'title' => __('UA code', 'retailcrm'),
|
||||||
|
'class' => 'input',
|
||||||
|
'type' => 'input'
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->form_fields['ua_custom'] = array(
|
||||||
|
'title' => __('Custom parameter', 'retailcrm'),
|
||||||
|
'class' => 'input',
|
||||||
|
'type' => 'input'
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -274,17 +304,17 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) :
|
|||||||
|
|
||||||
if (!isset($options['uploads'])) {
|
if (!isset($options['uploads'])) {
|
||||||
$this->form_fields[] = array(
|
$this->form_fields[] = array(
|
||||||
'title' => __( 'Выгрузка клиентов и заказов', 'woocommerce' ),
|
'title' => __('Uploads settings', 'retailcrm'),
|
||||||
'type' => 'heading',
|
'type' => 'heading',
|
||||||
'description' => '',
|
'description' => '',
|
||||||
'id' => 'upload_options'
|
'id' => 'upload_options'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->form_fields['upload-button'] = array(
|
$this->form_fields['upload-button'] = array(
|
||||||
'label' => 'Выгрузить',
|
'label' => __('Upload', 'retailcrm'),
|
||||||
'title' => __( 'Выгрузка клиентов и заказов', 'woocommerce-integration-retailcrm' ),
|
'title' => __('Upload all customers and orders', 'retailcrm' ),
|
||||||
'type' => 'button',
|
'type' => 'button',
|
||||||
'description' => __( 'Пакетная выгрузка существующих клиентов и заказов.', 'woocommerce-integration-retailcrm' ),
|
'description' => __('Batch unloading of existing customers and orders.', 'retailcrm' ),
|
||||||
'desc_tip' => true,
|
'desc_tip' => true,
|
||||||
'id' => 'uploads-retailcrm'
|
'id' => 'uploads-retailcrm'
|
||||||
);
|
);
|
||||||
@ -294,17 +324,17 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) :
|
|||||||
* Generate icml file
|
* Generate icml file
|
||||||
*/
|
*/
|
||||||
$this->form_fields[] = array(
|
$this->form_fields[] = array(
|
||||||
'title' => __( 'Генерация каталога товаров', 'woocommerce' ),
|
'title' => __( 'Generate ICML catalog', 'retailcrm' ),
|
||||||
'type' => 'title',
|
'type' => 'title',
|
||||||
'description' => '',
|
'description' => '',
|
||||||
'id' => 'icml_options'
|
'id' => 'icml_options'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->form_fields[] = array(
|
$this->form_fields[] = array(
|
||||||
'label' => 'Сгенерировать',
|
'label' => __('Generate', 'retailcrm'),
|
||||||
'title' => __( 'Генерация icml', 'woocommerce-integration-retailcrm' ),
|
'title' => __('Generate ICML', 'retailcrm'),
|
||||||
'type' => 'button',
|
'type' => 'button',
|
||||||
'description' => __( 'Данный функционал позволяет сгенерировать каталог товаров для выгрузки в CRM.', 'woocommerce-integration-retailcrm' ),
|
'description' => __('This functionality allows you to generate a catalog of products for downloading to CRM.', 'retailcrm'),
|
||||||
'desc_tip' => true,
|
'desc_tip' => true,
|
||||||
'id' => 'icml-retailcrm'
|
'id' => 'icml-retailcrm'
|
||||||
);
|
);
|
||||||
@ -407,7 +437,7 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) :
|
|||||||
|
|
||||||
if ($response && $response->isSuccessful()) {
|
if ($response && $response->isSuccessful()) {
|
||||||
if (!in_array($versionMap[$value], $response['versions'])) {
|
if (!in_array($versionMap[$value], $response['versions'])) {
|
||||||
WC_Admin_Settings::add_error( esc_html__( '"Выбранная версия API недоступна"', 'woocommerce-integration-retailcrm' ) );
|
WC_Admin_Settings::add_error( esc_html__( 'The selected version of the API is unavailable', 'retailcrm' ) );
|
||||||
$value = '';
|
$value = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -433,7 +463,7 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) :
|
|||||||
$response = $api->apiVersions();
|
$response = $api->apiVersions();
|
||||||
|
|
||||||
if ($response == NULL) {
|
if ($response == NULL) {
|
||||||
WC_Admin_Settings::add_error( esc_html__( '"Введите корректный адрес CRM"', 'woocommerce-integration-retailcrm' ) );
|
WC_Admin_Settings::add_error( esc_html__( 'Enter the correct CRM address', 'retailcrm' ) );
|
||||||
$value = '';
|
$value = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -462,7 +492,7 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$response->isSuccessful()) {
|
if (!$response->isSuccessful()) {
|
||||||
WC_Admin_Settings::add_error( esc_html__( '"Введитe правильный API ключ"', 'woocommerce-integration-retailcrm' ) );
|
WC_Admin_Settings::add_error( esc_html__( 'Enter the correct API key', 'retailcrm' ) );
|
||||||
$value = '';
|
$value = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
woo-retailcrm/languages/index.php
Normal file
2
woo-retailcrm/languages/index.php
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<?php // Silence is golden
|
||||||
|
|
BIN
woo-retailcrm/languages/retailcrm-ru_RU.mo
Normal file
BIN
woo-retailcrm/languages/retailcrm-ru_RU.mo
Normal file
Binary file not shown.
@ -1,11 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Version: 2.1.1
|
* Version: 2.1.2
|
||||||
* Plugin Name: WooCommerce RetailCRM
|
* Plugin Name: WooCommerce RetailCRM
|
||||||
* Plugin URI: https://wordpress.org/plugins/woo-retailcrm/
|
* Plugin URI: https://wordpress.org/plugins/woo-retailcrm/
|
||||||
* Description: Integration plugin for WooCommerce & RetailCRM
|
* Description: Integration plugin for WooCommerce & RetailCRM
|
||||||
* Author: RetailDriver LLC
|
* Author: RetailDriver LLC
|
||||||
* Author URI: http://retailcrm.ru/
|
* Author URI: http://retailcrm.ru/
|
||||||
|
* Text Domain: retailcrm
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) {
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
@ -246,7 +247,7 @@ function create_customer($customer_id) {
|
|||||||
$customer_class->createCustomer($customer_id);
|
$customer_class->createCustomer($customer_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_customer($customer_id, $data) {
|
function update_customer($customer_id) {
|
||||||
if ( ! class_exists( 'WC_Retailcrm_Customers' ) ) {
|
if ( ! class_exists( 'WC_Retailcrm_Customers' ) ) {
|
||||||
include_once( check_custom_customers() );
|
include_once( check_custom_customers() );
|
||||||
}
|
}
|
||||||
@ -324,7 +325,7 @@ function ajax_upload() {
|
|||||||
type: "POST",
|
type: "POST",
|
||||||
url: '<?php echo $ajax_url; ?>?action=do_upload',
|
url: '<?php echo $ajax_url; ?>?action=do_upload',
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
alert('Заказы и клиенты выгружены');
|
alert('<?php echo __('Customers and orders were unloaded', 'retailcrm'); ?>');
|
||||||
console.log('AJAX response : ',response);
|
console.log('AJAX response : ',response);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -342,7 +343,7 @@ function ajax_generate_icml() {
|
|||||||
type: "POST",
|
type: "POST",
|
||||||
url: '<?php echo $ajax_url; ?>?action=generate_icml',
|
url: '<?php echo $ajax_url; ?>?action=generate_icml',
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
alert('Каталог товаров сформирован');
|
alert('<?php echo __('Catalog were generated', 'retailcrm'); ?>');
|
||||||
console.log('AJAX response : ',response);
|
console.log('AJAX response : ',response);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -360,11 +361,91 @@ function update_order($order_id) {
|
|||||||
$order_class->updateOrder($order_id);
|
$order_class->updateOrder($order_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function initialize_analytics() {
|
||||||
|
$options = array_filter(get_option( 'woocommerce_integration-retailcrm_settings' ));
|
||||||
|
|
||||||
|
if (isset($options['ua']) && $options['ua'] == 'yes') {
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||||
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||||
|
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||||
|
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||||
|
|
||||||
|
ga('create', '<?php echo $options['ua_code']; ?>', 'auto');
|
||||||
|
|
||||||
|
function getRetailCrmCookie(name) {
|
||||||
|
var matches = document.cookie.match(new RegExp(
|
||||||
|
'(?:^|; )' + name + '=([^;]*)'
|
||||||
|
));
|
||||||
|
return matches ? decodeURIComponent(matches[1]) : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
ga('set', 'dimension<?php echo $options['ua_custom']; ?>', getRetailCrmCookie('_ga'));
|
||||||
|
ga('send', 'pageview');
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function send_analytics() {
|
||||||
|
$options = array_filter(get_option( 'woocommerce_integration-retailcrm_settings' ));
|
||||||
|
|
||||||
|
if (isset($_GET['key']) && isset($options['ua']) && $options['ua'] == 'yes') {
|
||||||
|
$orderid = wc_get_order_id_by_order_key($_GET['key']);
|
||||||
|
$order = new WC_Order($orderid);
|
||||||
|
foreach ($order->get_items() as $item) {
|
||||||
|
$uid = ($item['variation_id'] > 0) ? $item['variation_id'] : $item['product_id'] ;
|
||||||
|
$_product = wc_get_product($uid);
|
||||||
|
if ($_product) {
|
||||||
|
$order_item = array(
|
||||||
|
'id' => $uid,
|
||||||
|
'name' => $item['name'],
|
||||||
|
'price' => (float)$_product->get_price(),
|
||||||
|
'quantity' => $item['qty'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$order_items[] = $order_item;
|
||||||
|
}
|
||||||
|
|
||||||
|
$url = parse_url(get_site_url());
|
||||||
|
$domain = $url['host'];
|
||||||
|
?>
|
||||||
|
<script type="text/javascript">
|
||||||
|
ga('require', 'ecommerce', 'ecommerce.js');
|
||||||
|
ga('ecommerce:addTransaction', {
|
||||||
|
'id': <?php echo $order->get_data()['id']; ?>,
|
||||||
|
'affiliation': '<?php echo $domain; ?>',
|
||||||
|
'revenue': <?php echo $order->get_total(); ?>,
|
||||||
|
'shipping': <?php echo $order->get_total_tax(); ?>,
|
||||||
|
'tax': <?php echo $order->get_shipping_total(); ?>
|
||||||
|
});
|
||||||
|
<?php
|
||||||
|
foreach ($order_items as $item) {?>
|
||||||
|
ga('ecommerce:addItem', {
|
||||||
|
'id': <?php echo $order->get_data()['id']; ?>,
|
||||||
|
'sku': <?php echo $item['id']; ?>,
|
||||||
|
'name': '<?php echo $item['name']; ?>',
|
||||||
|
'price': <?php echo $item['price']; ?>,
|
||||||
|
'quantity': <?php echo $item['quantity']; ?>
|
||||||
|
});
|
||||||
|
<?php
|
||||||
|
}?>
|
||||||
|
ga('ecommerce:send');
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function retailcrm_load_plugin_textdomain() {
|
||||||
|
load_plugin_textdomain('retailcrm', FALSE, basename( dirname( __FILE__ ) ) . '/languages/');
|
||||||
|
}
|
||||||
|
|
||||||
register_activation_hook( __FILE__, 'retailcrm_install' );
|
register_activation_hook( __FILE__, 'retailcrm_install' );
|
||||||
register_deactivation_hook( __FILE__, 'retailcrm_deactivation' );
|
register_deactivation_hook( __FILE__, 'retailcrm_deactivation' );
|
||||||
|
|
||||||
if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option( 'active_plugins')))) {
|
if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option( 'active_plugins')))) {
|
||||||
load_plugin_textdomain('wc_retailcrm', false, dirname(plugin_basename( __FILE__ )) . '/');
|
add_action('plugins_loaded', 'retailcrm_load_plugin_textdomain');
|
||||||
add_filter('cron_schedules', 'filter_cron_schedules', 10, 1);
|
add_filter('cron_schedules', 'filter_cron_schedules', 10, 1);
|
||||||
add_action('woocommerce_checkout_order_processed', 'retailcrm_process_order', 10, 1);
|
add_action('woocommerce_checkout_order_processed', 'retailcrm_process_order', 10, 1);
|
||||||
add_action('retailcrm_history', 'retailcrm_history_get');
|
add_action('retailcrm_history', 'retailcrm_history_get');
|
||||||
@ -380,4 +461,6 @@ if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_
|
|||||||
add_action('woocommerce_created_customer', 'create_customer', 10, 1);
|
add_action('woocommerce_created_customer', 'create_customer', 10, 1);
|
||||||
add_action('woocommerce_update_customer', 'update_customer', 10, 1);
|
add_action('woocommerce_update_customer', 'update_customer', 10, 1);
|
||||||
add_action('woocommerce_update_order', 'update_order', 11, 1);
|
add_action('woocommerce_update_order', 'update_order', 11, 1);
|
||||||
|
add_action('wp_print_scripts', 'initialize_analytics', 98);
|
||||||
|
add_action('wp_print_footer_scripts', 'send_analytics', 99);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @link https://wordpress.org/plugins/woo-retailcrm/
|
* @link https://wordpress.org/plugins/woo-retailcrm/
|
||||||
* @since 2.1.1
|
* @since 2.1.2
|
||||||
*
|
*
|
||||||
* @package RetailCRM
|
* @package RetailCRM
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user