From 52218b0d22d05f474b5fc9d9ff8bd5f4ef3ea427 Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Wed, 21 Mar 2018 11:03:16 +0300 Subject: [PATCH] Localization, universal analytics --- CHANGELOG.md | 4 + .../include/class-wc-retailcrm-base.php | 110 +++++++++++------- woo-retailcrm/languages/index.php | 2 + woo-retailcrm/languages/retailcrm-ru_RU.mo | Bin 0 -> 5167 bytes woo-retailcrm/retailcrm.php | 93 ++++++++++++++- woo-retailcrm/uninstall.php | 2 +- 6 files changed, 165 insertions(+), 46 deletions(-) create mode 100644 woo-retailcrm/languages/index.php create mode 100644 woo-retailcrm/languages/retailcrm-ru_RU.mo diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ec4b75..c94b27e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2018-03-21 v.2.1.2 +* Добавлена локализация плагина +* Добавлена интеграция с UA + ## 2018-03-12 v.2.1.1 * Исправлена ошибка редактирования информации о клиенте diff --git a/woo-retailcrm/include/class-wc-retailcrm-base.php b/woo-retailcrm/include/class-wc-retailcrm-base.php index 95b00f3..4b47186 100644 --- a/woo-retailcrm/include/class-wc-retailcrm-base.php +++ b/woo-retailcrm/include/class-wc-retailcrm-base.php @@ -28,8 +28,8 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) : } $this->id = 'integration-retailcrm'; - $this->method_title = __( 'RetailCRM', 'woocommerce-integration-retailcrm' ); - $this->method_description = __( 'Интеграция с системой управления Retailcrm.', 'woocommerce-integration-retailcrm' ); + $this->method_title = __('RetailCRM', 'retailcrm'); + $this->method_description = __('Integration with eComlogic managament system.', 'retailcrm'); // Load the settings. @@ -46,19 +46,19 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) : public function init_form_fields() { $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( - 'title' => __( 'API URL', 'woocommerce-integration-retailcrm' ), + 'title' => __( 'API URL', 'retailcrm' ), '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, 'default' => '' ), 'api_key' => array( - 'title' => __( 'API Key', 'woocommerce-integration-retailcrm' ), + 'title' => __( 'API Key', 'retailcrm' ), '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, 'default' => '' ) @@ -67,15 +67,15 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) : $api_version_list = array('v4' => 'v4','v5' => 'v5'); $this->form_fields[] = array( - 'title' => __( 'Настройки API', 'woocommerce' ), + 'title' => __( 'API settings', 'retailcrm' ), 'type' => 'title', 'description' => '', 'id' => 'api_options' ); $this->form_fields['api_version'] = array( - 'title' => __( 'API версия', 'textdomain' ), - 'description' => __( 'Выберите версию API, которую Вы хотите использовать', 'textdomain' ), + 'title' => __( 'API version', 'retailcrm' ), + 'description' => __( 'Select the API version you want to use', 'retailcrm' ), 'css' => 'min-width:50px;', 'class' => 'select', 'type' => 'select', @@ -84,7 +84,7 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) : ); $this->form_fields[] = array( - 'title' => __( 'Настройки каталога', 'woocommerce' ), + 'title' => __( 'Catalog settings', 'retailcrm' ), 'type' => 'title', 'description' => '', 'id' => 'catalog_options' @@ -92,8 +92,8 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) : foreach (get_post_statuses() as $status_key => $status_value) { $this->form_fields['p_' . $status_key] = array( - 'title' => __( $status_value, 'textdomain' ), - 'label' => __( ' ', 'textdomain' ), + 'title' => $status_value, + 'label' => ' ', 'description' => '', 'class' => 'checkbox', 'type' => 'checkbox', @@ -127,18 +127,18 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) : } $this->form_fields[] = array( - 'title' => __( 'Способы оформления заказа', 'woocommerce' ), + 'title' => __('Order methods', 'retailcrm'), 'type' => 'heading', 'description' => '', 'id' => 'order_methods_options' ); $this->form_fields['order_methods'] = array( - 'label' => __( ' ', 'textdomain' ), - 'title' => 'Способы оформления заказа, доступные для выгрузки из RetailCRM', + 'label' => ' ', + 'title' => __('Ordering methods available for downloading from eComlogic', 'retailcrm'), 'class' => '', 'type' => 'multiselect', - 'description' => 'Выберите способы оформления для заказов, которые будут выгружаться из RetailCRM на сайт', + 'description' => __('Select the order methods that will be uploaded from eComlogic to site', 'retailcrm'), 'options' => $order_methods_option, 'select_buttons' => true ); @@ -158,7 +158,7 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) : $wc_shipping_list = get_wc_shipping_methods(); $this->form_fields[] = array( - 'title' => __( 'Способы доставки', 'woocommerce' ), + 'title' => __('Shipping methods', 'retailcrm'), 'type' => 'heading', 'description' => '', 'id' => 'shipping_options' @@ -167,8 +167,8 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) : foreach ( $wc_shipping_list as $shipping_code => $shipping ) { if ( isset( $shipping['enabled'] ) && $shipping['enabled'] == 'yes' ) { $this->form_fields[$shipping_code] = array( - 'title' => __( $shipping['title'], 'textdomain' ), - 'description' => __( $shipping['description'], 'textdomain' ), + 'title' => __($shipping['title'], 'woocommerce'), + 'description' => __($shipping['description'], 'woocommerce'), 'css' => 'min-width:350px;', 'class' => 'select', 'type' => 'select', @@ -193,7 +193,7 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) : $wc_payment = new WC_Payment_Gateways(); $this->form_fields[] = array( - 'title' => __( 'Способы оплаты', 'woocommerce' ), + 'title' => __('Payment methods', 'retailcrm'), 'type' => 'heading', 'description' => '', 'id' => 'payment_options' @@ -204,8 +204,8 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) : $key = $payment->id; $name = $key; $this->form_fields[$name] = array( - 'title' => __( $payment->method_title, 'textdomain' ), - 'description' => __( $payment->method_description, 'textdomain' ), + 'title' => __($payment->method_title, 'woocommerce'), + 'description' => __($payment->method_description, 'woocommerce'), 'css' => 'min-width:350px;', 'class' => 'select', 'type' => 'select', @@ -230,7 +230,7 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) : $wc_statuses = wc_get_order_statuses(); $this->form_fields[] = array( - 'title' => __( 'Статусы', 'woocommerce' ), + 'title' => __('Statuses', 'retailcrm'), 'type' => 'heading', 'description' => '', 'id' => 'statuses_options' @@ -239,7 +239,7 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) : foreach ( $wc_statuses as $idx => $name ) { $uid = str_replace('wc-', '', $idx); $this->form_fields[$uid] = array( - 'title' => __( $name, 'textdomain' ), + 'title' => __($name, 'woocommerce'), 'css' => 'min-width:350px;', 'class' => 'select', 'type' => 'select', @@ -253,18 +253,48 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) : * Inventories options */ $this->form_fields[] = array( - 'title' => __( 'Настройки выгрузки остатков', 'woocommerce' ), + 'title' => __('Inventories settings', 'retailcrm'), 'type' => 'heading', 'description' => '', 'id' => 'invent_options' ); $this->form_fields['sync'] = array( - 'label' => __( 'Выгружать остатки из CRM', 'textdomain' ), - 'title' => 'Остатки', + 'label' => __('Sync inventories', 'retailcrm'), + 'title' => __('Inventories', 'retailcrm'), 'class' => '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'])) { $this->form_fields[] = array( - 'title' => __( 'Выгрузка клиентов и заказов', 'woocommerce' ), + 'title' => __('Uploads settings', 'retailcrm'), 'type' => 'heading', 'description' => '', 'id' => 'upload_options' ); $this->form_fields['upload-button'] = array( - 'label' => 'Выгрузить', - 'title' => __( 'Выгрузка клиентов и заказов', 'woocommerce-integration-retailcrm' ), + 'label' => __('Upload', 'retailcrm'), + 'title' => __('Upload all customers and orders', 'retailcrm' ), 'type' => 'button', - 'description' => __( 'Пакетная выгрузка существующих клиентов и заказов.', 'woocommerce-integration-retailcrm' ), + 'description' => __('Batch unloading of existing customers and orders.', 'retailcrm' ), 'desc_tip' => true, 'id' => 'uploads-retailcrm' ); @@ -294,17 +324,17 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) : * Generate icml file */ $this->form_fields[] = array( - 'title' => __( 'Генерация каталога товаров', 'woocommerce' ), + 'title' => __( 'Generate ICML catalog', 'retailcrm' ), 'type' => 'title', 'description' => '', 'id' => 'icml_options' ); $this->form_fields[] = array( - 'label' => 'Сгенерировать', - 'title' => __( 'Генерация icml', 'woocommerce-integration-retailcrm' ), + 'label' => __('Generate', 'retailcrm'), + 'title' => __('Generate ICML', 'retailcrm'), '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, 'id' => 'icml-retailcrm' ); @@ -407,7 +437,7 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) : if ($response && $response->isSuccessful()) { 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 = ''; } @@ -433,7 +463,7 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) : $response = $api->apiVersions(); 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 = ''; } @@ -462,7 +492,7 @@ if ( ! class_exists( 'WC_Retailcrm_Base' ) ) : } 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 = ''; } diff --git a/woo-retailcrm/languages/index.php b/woo-retailcrm/languages/index.php new file mode 100644 index 0000000..9c87d13 --- /dev/null +++ b/woo-retailcrm/languages/index.php @@ -0,0 +1,2 @@ +~`n(U5ur`erZ z&CJFz5>gVUl;Si&4HXxOLPZ}c9+2bMi5;7JNMu7y5bq+{S5D0cPTXl_TSAvo_+Ty^?vZF1PkDY7>|JWg3l#* z5)>IO_)+j@;6vb5@EPzo;3T+xd%XSv_$cF3;3vUL;3MGM;1TdP_%wLm`{Mma!4ES& z0p16`nBX_T4>102vVH}8knx*f7Q6vwz;{8h_W_)F0Mww!+Y3Gg4uK-~Ti^%5S3&XP z2jC9yZEzU;T{8b5N=5Gu{>i=pQ1tBwp9ei~8~AIGBkH%H=>I*4De4{YbKqYyLmU zXD?U)tKbpv7a&{Jd*Bn`HjK}KPlBhwDky&Z0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l1(KR_DCZg}#2;dYakgt$o*)z-X@Hu(IN=!c25)@8#*w8U^7U*<)?qT%KZ_T3V0 zS{Gxv-94)s33D8P*?ukT2pPKdk`cZVZ|_ohUHpM@R)t3KR>B3u(J)bg!03j#iG|Et z*aH_Zxe~3z#bGBl13stM8rK2>?&-8ww5o5@tv&L!?%pAa_C7Hqvx!*P) zF``6nR!6UiUAJ)Qx`ZJKt%)+mFT)RxO5&Lul&rtN>?$;%96cOm3G3rz5ZW<_q>j6l zG{Q{=bj>q$@*NRqg0j^QiB5y0q4GOI@)lEPBGymMobO%QLpl+VJb@rM8t8dfC6tD1^x=h&LDUs_l?R&S)sXUp!= zO=4+ZWJ$W>C^jLD>Ou8Jlr)12CMj;=rBEg+Q*Dg0`7aO94whoA;!Zny32&Rslafy{ zb*C-_Kt3UzSKVFlSL!F0)Jb%e5;-fCY8sdf48ND8l(0!^(WJk$@VK&iyA`1jW=w6H z_HFc%N_Ps6_woPVF_`$ zFEB4xgw)4|$cfhC-hG3z7N##tTN8)6mtyCB6AtdU8t*90PBm`Is>RN4OIp%Kv}Eo) z)JTe7#~6MAU=FFiRSn6{f-Y6uKVnJm6fHwc>s%-3*y8^GpU$MaNH^vG{~xgb1b+32 A)c^nh literal 0 HcmV?d00001 diff --git a/woo-retailcrm/retailcrm.php b/woo-retailcrm/retailcrm.php index be34c8a..8db7d09 100644 --- a/woo-retailcrm/retailcrm.php +++ b/woo-retailcrm/retailcrm.php @@ -1,11 +1,12 @@ createCustomer($customer_id); } -function update_customer($customer_id, $data) { +function update_customer($customer_id) { if ( ! class_exists( 'WC_Retailcrm_Customers' ) ) { include_once( check_custom_customers() ); } @@ -324,7 +325,7 @@ function ajax_upload() { type: "POST", url: '?action=do_upload', success: function (response) { - alert('Заказы и клиенты выгружены'); + alert(''); console.log('AJAX response : ',response); } }); @@ -342,7 +343,7 @@ function ajax_generate_icml() { type: "POST", url: '?action=generate_icml', success: function (response) { - alert('Каталог товаров сформирован'); + alert(''); console.log('AJAX response : ',response); } }); @@ -360,11 +361,91 @@ function update_order($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') { + ?> + + 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']; + ?> + +