diff --git a/resources/bin/pot_compile.sh b/resources/bin/pot_compile.sh new file mode 100755 index 0000000..db6e82f --- /dev/null +++ b/resources/bin/pot_compile.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +DIRECTORY=$(cd `dirname $0` && pwd) + +msgfmt $DIRECTORY/../pot/retailcrm-ru_RU.pot -o $DIRECTORY/../../src/languages/retailcrm-ru_RU.mo +msgfmt $DIRECTORY/../pot/retailcrm-es_ES.pot -o $DIRECTORY/../../src/languages/retailcrm-es_ES.mo \ No newline at end of file diff --git a/resources/pot/retailcrm-es_ES.pot b/resources/pot/retailcrm-es_ES.pot new file mode 100644 index 0000000..c99cb16 --- /dev/null +++ b/resources/pot/retailcrm-es_ES.pot @@ -0,0 +1,203 @@ +# Translation of Plugins - Woocommerce RetailCRM - Development (trunk) in Spanish +# This file is distributed under the same license as the Plugins - Woocommerce RetailCRM - Development (trunk) package. +msgid "" +msgstr "" +"PO-Revision-Date: 2018-06-06 08:53:26+0000\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" +"X-Generator: GlotPress/2.4.0-alpha\n" +"Language: es\n" +"Project-Id-Version: Plugins - Woocommerce RetailCRM - Development (trunk)\n" + +#. Author URI of the plugin/theme +msgid "https://retailcrm.pro/" +msgstr "https://retailcrm.pro/" + +#. Author of the plugin/theme +msgid "RetailDriver LLC" +msgstr "RetailDriver LLC" + +#. Description of the plugin/theme +msgid "Integration plugin for WooCommerce & retailCRM" +msgstr "El plugin de integración para WooCommerce & retailCRM" + +#. Plugin URI of the plugin/theme +msgid "https://wordpress.org/plugins/woo-retailcrm/" +msgstr "https://wordpress.org/plugins/woo-retailcrm/" + +#. Plugin Name of the plugin/theme +msgid "WooCommerce retailCRM" +msgstr "WooCommerce retailCRM" + +msgid "This functionality allows to upload orders to CRM differentially." +msgstr "Esta función permite la subida selectiva de los pedidos al retailCRM." + +msgid "Uploading orders by identifiers." +msgstr "Subida de los pedidos por identificadores." + +msgid "Enter orders identifiers separated by a comma." +msgstr "Introduce los identificadores de pedidos separados por coma." + +msgid "Orders identifiers" +msgstr "Los identificadores de pedidos" + +msgid "Order identifier" +msgstr "Los identif de pedido" + +msgid "Upload the order by ID" +msgstr "Subir el pedido por ID" + +msgid "Orders were uploaded" +msgstr "Los pedidos están subidos" + +msgid "The field cannot be empty, enter the order ID" +msgstr "El campo no puede estar vacío, introduce el identificador de pedido" + +msgid "Catalog was generated" +msgstr "El catálogo está generado" + +msgid "Customers and orders were uploaded" +msgstr "Los clientes y pedidos están subidos" + +msgid "Enter the correct API key" +msgstr "Introduce la llave API correcta" + +msgid "Enter the correct URL of CRM" +msgstr "Introduce el enlace del retailCRM correcto" + +msgid "The selected API version is unavailable" +msgstr "La versión de API elegida no está disponible" + +msgid "This functionality allows to generate ICML products catalog for uploading to retailCRM." +msgstr "Esta función permite generar los catálogos de pedidos ICML para subida al retailCRM." + +msgid "Generating ICML" +msgstr "Generando ICML" + +msgid "Generate now" +msgstr "Generar ahora" + +msgid "Generating ICML catalog" +msgstr "Generar catálogo ICML" + +msgid "Settings" +msgstr "Ajustes" + +msgid "Uploading the existing customers and orders to retailCRM" +msgstr "Subida de los clientes existentes y pedidos al retailCRM." + +msgid "Uploading all customers and orders" +msgstr "Subir todos los clientes y pedidos" + +msgid "Upload" +msgstr "Subir" + +msgid "Settings of uploading" +msgstr "Ajustes de subida" + +msgid "User parameter" +msgstr "El parámetro personalizado" + +msgid "UA tracking code" +msgstr "El código de seguimiento UA" + +msgid "Enable this setting for uploading data to UA" +msgstr "Activa esta opción para subir los datos al UA." + +msgid "UA" +msgstr "UA" + +msgid "Activate UA" +msgstr "Activar UA" + +msgid "UA settings" +msgstr "Ajustes de UA" + +msgid "Enable this setting if you would like to get information on leftover stocks from retailCRM to the website." +msgstr "Active esta opción si quiere recibir la información del stock de los productos desde retailCRM a la página web." + +msgid "Stock balance" +msgstr "El stock" + +msgid "Synchronization of the stock balance" +msgstr "Sincronizar el stock" + +msgid "Setting of the stock balance" +msgstr "Ajustes del stock" + +msgid "Statuses" +msgstr "Los estados" + +msgid "Payment types" +msgstr "Métodos de pago" + +msgid "Delivery types" +msgstr "Métodos de envío" + +msgid "Select order methods which will be uploaded from retailCRM to the website" +msgstr "Elige el método de formalización de los pedidos que se van a subir desde retailCRM a la página web" + +msgid "Order methods available for uploading from retailCRM" +msgstr "Los métodos de la formalización de los pedidos disponibles para subida desde retailCRM" + +msgid "Order methods" +msgstr "Los métodos de la formalización del pedido" + +msgid "Catalog settings" +msgstr "Ajustes del catálogo" + +msgid "Select API version" +msgstr "Selecciona la versión de API" + +msgid "API version" +msgstr "Versión de API" + +msgid "API settings" +msgstr "Ajustes de API" + +msgid "Enter your API key. You can find it in the administration section of retailCRM" +msgstr "Introduce la llave API. Puede encontrarla en apartado administrativo del retailCRM" + +msgid "Enter with your API URL (https://yourdomain.retailcrm.pro)." +msgstr "Introduce enlace de API (https://yourdomain.retailcrm.pro)." + +msgid "Integration with retailCRM management system." +msgstr "La integración con el sistema de gestión del retailCRM ." + +msgid "Every 15 minutes" +msgstr "Cada 15 minutos" + +msgid "Every 3 hours" +msgstr "Cada 3 horas" + +msgid "Every 5 minutes" +msgstr "Cada 5 minutos" + +msgid "API Key" +msgstr "La llave API" + +msgid "API of URL" +msgstr "El enlace API" + +msgid "Main settings" +msgstr "Los ajustes generales" + +msgid "retailCRM" +msgstr "retailCRM" + +msgid "Daemon Collector settings" +msgstr "Ajustes de Daemon Collector" + +msgid "Activate Daemon Collector" +msgstr "Activar Daemon Collector" + +msgid "Daemon Collector" +msgstr "Daemon Collector" + +msgid "Enable this setting for activate Daemon Collector on site" +msgstr "Active esta configuración para activar Daemon Collector en la página web" + +msgid "Site key" +msgstr "Clave de la página web" \ No newline at end of file diff --git a/resources/pot/retailcrm-ru_RU.pot b/resources/pot/retailcrm-ru_RU.pot new file mode 100644 index 0000000..3690109 --- /dev/null +++ b/resources/pot/retailcrm-ru_RU.pot @@ -0,0 +1,212 @@ +# Translation of Plugins - Woocommerce RetailCRM - Development (trunk) in Russian +# This file is distributed under the same license as the Plugins - Woocommerce RetailCRM - Development (trunk) package. +msgid "" +msgstr "" +"PO-Revision-Date: 2018-06-06 08:53:26+0000\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" +"X-Generator: GlotPress/2.4.0-alpha\n" +"Language: ru\n" +"Project-Id-Version: Plugins - Woocommerce RetailCRM - Development (trunk)\n" + +#. Author URI of the plugin/theme +msgid "https://retailcrm.pro/" +msgstr "https://retailcrm.ru/" + +#. Author of the plugin/theme +msgid "RetailDriver LLC" +msgstr "RetailDriver LLC" + +#. Description of the plugin/theme +msgid "Integration plugin for WooCommerce & retailCRM" +msgstr "Интеграционный плагин для WooCommerce & retailCRM" + +#. Plugin URI of the plugin/theme +msgid "https://wordpress.org/plugins/woo-retailcrm/" +msgstr "https://wordpress.org/plugins/woo-retailcrm/" + +#. Plugin Name of the plugin/theme +msgid "WooCommerce retailCRM" +msgstr "WooCommerce retailCRM" + +msgid "Activate history uploads" +msgstr "Активировать загрузку истории изменений" + +msgid "Upload data from retailCRM" +msgstr "Загрузка данных из retailCRM" + +msgid "Generating ICML catalog by wp-cron" +msgstr "Генерация ICML каталога товаров с помощью wp-cron" + +msgid "This functionality allows to upload orders to CRM differentially." +msgstr "Эта функция позволяет производить выборочную выгрузку заказов в retailCRM" + +msgid "Uploading orders by identifiers." +msgstr "Выгрузка заказов по идентификаторам" + +msgid "Enter orders identifiers separated by a comma." +msgstr "Введите идентификаторы заказов через запятую" + +msgid "Orders identifiers" +msgstr "Идентификаторы заказов" + +msgid "Order identifier" +msgstr "Идентификатор заказа" + +msgid "Upload the order by ID" +msgstr "Выгрузить заказ по идентификатору" + +msgid "Orders were uploaded" +msgstr "Заказы были выгружены" + +msgid "The field cannot be empty, enter the order ID" +msgstr "Поле не может быть пустым, введите идентификатор заказа" + +msgid "Catalog was generated" +msgstr "Каталог был сгенерирован" + +msgid "Customers and orders were uploaded" +msgstr "Клиенты и заказы были выгружены" + +msgid "Enter the correct API key" +msgstr "Введите корректный API ключ" + +msgid "Enter the correct URL of CRM" +msgstr "Введите корректный адрес retailCRM" + +msgid "The selected API version is unavailable" +msgstr "Выбранная версия API недоступна" + +msgid "This functionality allows to generate ICML products catalog for uploading to retailCRM." +msgstr "Эта функция позволяет сгенерировать ICML каталог товаров для выгрузки в retailCRM" + +msgid "Generating ICML" +msgstr "Генерация ICML" + +msgid "Generate now" +msgstr "Сгенерировать сейчас" + +msgid "Generating ICML catalog" +msgstr "Генерация ICML каталога" + +msgid "Settings" +msgstr "Настройки" + +msgid "Uploading the existing customers and orders to retailCRM" +msgstr "Выгрузка существующих клиентов и заказов в retailCRM" + +msgid "Uploading all customers and orders" +msgstr "Выгрузка всех клиентов и заказов" + +msgid "Upload" +msgstr "Выгрузить" + +msgid "Settings of uploading" +msgstr "Настройки выгрузки" + +msgid "User parameter" +msgstr "Пользовательский параметр" + +msgid "UA tracking code" +msgstr "Код отслеживания UA" + +msgid "Enable this setting for uploading data to UA" +msgstr "Активируйте эту настройку для выгрузки данных в UA" + +msgid "UA" +msgstr "UA" + +msgid "Activate UA" +msgstr "Активировать UA" + +msgid "UA settings" +msgstr "Настройки UA" + +msgid "Enable this setting if you would like to get information on leftover stocks from retailCRM to the website." +msgstr "Активируйте данную настройку, если хотите получать остатки по товарам из retailCRM на сайт." + +msgid "Stock balance" +msgstr "Остатки" + +msgid "Synchronization of the stock balance" +msgstr "Синхронизация остатков" + +msgid "Setting of the stock balance" +msgstr "Настройка управления остатками" + +msgid "Statuses" +msgstr "Статусы" + +msgid "Payment types" +msgstr "Способы оплаты" + +msgid "Delivery types" +msgstr "Способы доставки" + +msgid "Select order methods which will be uploaded from retailCRM to the website" +msgstr "Выберите способы оформления заказов, которые будут выгружаться из retailCRM на сайт" + +msgid "Order methods available for uploading from retailCRM" +msgstr "Способы оформления заказа, доступные для выгрузки из retailCRM" + +msgid "Order methods" +msgstr "Способы оформления заказа" + +msgid "Catalog settings" +msgstr "Настройки каталога" + +msgid "Select API version" +msgstr "Выберите версию API" + +msgid "API version" +msgstr "Версия API" + +msgid "API settings" +msgstr "Настройки API" + +msgid "Enter your API key. You can find it in the administration section of retailCRM" +msgstr "Введите API ключ. Вы можете найти его в административном разделе retailCRM." + +msgid "Enter API of URL (https://yourdomain.retailcrm.pro)." +msgstr "Введите API URL (https://yourdomain.retailcrm.ru)." + +msgid "Integration with retailCRM management system." +msgstr "Интеграция с системой управления retailCRM" + +msgid "Every 15 minutes" +msgstr "Каждые 15 минут" + +msgid "Every 3 hours" +msgstr "Каждые 3 часа" + +msgid "Every 5 minutes" +msgstr "Каждые 5 минут" + +msgid "API key" +msgstr "API ключ" + +msgid "API of URL" +msgstr "API URL" + +msgid "Main settings" +msgstr "Главные настройки" + +msgid "retailCRM" +msgstr "retailCRM" + +msgid "Daemon Collector settings" +msgstr "Настройка Daemon Collector" + +msgid "Activate Daemon Collector" +msgstr "Активировать Daemon Collector" + +msgid "Daemon Collector" +msgstr "Daemon Collector" + +msgid "Enable this setting for activate Daemon Collector on site" +msgstr "Активируйте эту настройку для активации Daemon Collector на сайте" + +msgid "Site key" +msgstr "Ключ сайта" \ No newline at end of file diff --git a/src/include/class-wc-retailcrm-base.php b/src/include/class-wc-retailcrm-base.php index a67c532..b02c1ae 100644 --- a/src/include/class-wc-retailcrm-base.php +++ b/src/include/class-wc-retailcrm-base.php @@ -65,6 +65,7 @@ if (!class_exists('WC_Retailcrm_Base')) { add_action('woocommerce_update_customer', array($this, 'update_customer'), 10, 1); add_action('woocommerce_update_order', array($this, 'update_order'), 11, 1); add_action('wp_print_scripts', array($this, 'initialize_analytics'), 98); + add_action('wp_print_scripts', array($this, 'initialize_daemon_collector'), 99); add_action('wp_print_footer_scripts', array($this, 'send_analytics'), 99); // Deactivate hook @@ -351,7 +352,7 @@ if (!class_exists('WC_Retailcrm_Base')) { include_once(self::checkCustomFile('ga')); } - if ($this->get_option('ua') && $this->get_option('ua_code') && is_checkout()) { + if ($this->get_option('ua') == 'yes' && $this->get_option('ua_code') && is_checkout()) { $retailcrm_analytics = WC_Retailcrm_Google_Analytics::getInstance($this->settings); echo $retailcrm_analytics->send_analytics(); } else { @@ -359,6 +360,23 @@ if (!class_exists('WC_Retailcrm_Base')) { } } + /** + * Daemon collector + */ + public function initialize_daemon_collector() + { + if (!class_exists('WC_Retailcrm_Daemon_Collector')) { + include_once(self::checkCustomFile('daemon-collector')); + } + + if ($this->get_option('daemon_collector') == 'yes' && $this->get_option('daemon_collector_key')) { + $retailcrm_daemon_collector = WC_Retailcrm_Daemon_Collector::getInstance($this->settings); + echo $retailcrm_daemon_collector->initialize_daemon_collector(); + } else { + echo ''; + } + } + /** * Initialize integration settings form fields. */ @@ -591,7 +609,7 @@ if (!class_exists('WC_Retailcrm_Base')) { 'title' => __('UA settings', 'retailcrm'), 'type' => 'heading', 'description' => '', - 'id' => 'invent_options' + 'id' => 'ua_options' ); $this->form_fields['ua'] = array( @@ -614,6 +632,30 @@ if (!class_exists('WC_Retailcrm_Base')) { 'type' => 'input' ); + /** + * Daemon collector settings + */ + $this->form_fields[] = array( + 'title' => __('Daemon Collector settings', 'retailcrm'), + 'type' => 'heading', + 'description' => '', + 'id' => 'invent_options' + ); + + $this->form_fields['daemon_collector'] = array( + 'label' => __('Activate Daemon Collector', 'retailcrm'), + 'title' => __('Daemon Collector', 'retailcrm'), + 'class' => 'checkbox', + 'type' => 'checkbox', + 'description' => __('Enable this setting for activate Daemon Collector on site', 'retailcrm') + ); + + $this->form_fields['daemon_collector_key'] = array( + 'title' => __('Site key', 'retailcrm'), + 'class' => 'input', + 'type' => 'input' + ); + /** * Uploads options */ diff --git a/src/include/class-wc-retailcrm-daemon-collector.php b/src/include/class-wc-retailcrm-daemon-collector.php new file mode 100644 index 0000000..f21db44 --- /dev/null +++ b/src/include/class-wc-retailcrm-daemon-collector.php @@ -0,0 +1,106 @@ +options = $options; + } + + /** + * @return string + */ + public function initialize_daemon_collector() { + if (!$this->code) { + $this->buildHeader() + ->buildParams() + ->buildFooter(); + } + + return $this->code; + } + + /** + * @return $this + */ + private function buildHeader() { + $header = << + (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'); + +EOF; + + $this->code .= $header; + + return $this; + } + + /** + * @return $this + */ + private function buildParams() { + $params = array(); + + if ( + function_exists('WC') + && WC()->customer !== null + && WC()->customer->get_id() > 0 + ) { + $params['customerId'] = WC()->customer->get_id(); + } + + $this->code .= apply_filters('retailcrm_daemon_collector', '') . sprintf( + "\t_rc('create', '%s', %s);\n", + $this->options['daemon_collector_key'], + json_encode((object) $params) + ); + + return $this; + } + + /** + * @return $this + */ + private function buildFooter() { + $footer = << + +EOF; + + $this->code .= $footer; + + return $this; + } +} diff --git a/src/include/class-wc-retailcrm-ga.php b/src/include/class-wc-retailcrm-ga.php index aef2030..fe2be39 100644 --- a/src/include/class-wc-retailcrm-ga.php +++ b/src/include/class-wc-retailcrm-ga.php @@ -7,6 +7,8 @@ if (!class_exists('WC_Retailcrm_Google_Analytics')) { private $options; /** + * @param array $options + * * @return WC_Retailcrm_Google_Analytics */ public static function getInstance($options = array()) diff --git a/src/languages/retailcrm-es_ES.mo b/src/languages/retailcrm-es_ES.mo index 19b8e11..fa24d27 100644 Binary files a/src/languages/retailcrm-es_ES.mo and b/src/languages/retailcrm-es_ES.mo differ diff --git a/src/languages/retailcrm-ru_RU.mo b/src/languages/retailcrm-ru_RU.mo index e443e55..f844390 100644 Binary files a/src/languages/retailcrm-ru_RU.mo and b/src/languages/retailcrm-ru_RU.mo differ diff --git a/tests/phpunit/bootstrap.php b/tests/phpunit/bootstrap.php index 0cc1105..f531b62 100644 --- a/tests/phpunit/bootstrap.php +++ b/tests/phpunit/bootstrap.php @@ -15,6 +15,7 @@ function _manually_load_plugin() { require $plugin_dir . 'src/include/class-wc-retailcrm-customers.php'; require $plugin_dir . 'src/include/class-wc-retailcrm-inventories.php'; require $plugin_dir . 'src/include/class-wc-retailcrm-ga.php'; + require $plugin_dir . 'src/include/class-wc-retailcrm-daemon-collector.php'; require $plugin_dir . 'src/include/class-wc-retailcrm-history.php'; require $plugin_dir . 'src/retailcrm.php'; } diff --git a/tests/phpunit/test-wc-retailcrm-daemon-collector.php b/tests/phpunit/test-wc-retailcrm-daemon-collector.php new file mode 100644 index 0000000..ce33567 --- /dev/null +++ b/tests/phpunit/test-wc-retailcrm-daemon-collector.php @@ -0,0 +1,30 @@ +options = array( + 'daemon_collector_key' => 'RC-XXXXXXXXXX-X' + ); + + $this->daemonCollector = WC_Retailcrm_Daemon_Collector::getInstance($this->options); + } + + public function test_initialize_daemon_collector() + { + $customerObject = WC_Helper_Customer::create_customer(); + WC()->customer = $customerObject; + + $js = $this->daemonCollector->initialize_daemon_collector(); + + $this->assertContains('customerId', $js); + $this->assertContains($this->options['daemon_collector_key'], $js); + $this->assertContains('assertContains('', $js); + $this->assertContains('_rc(\'create\',', $js); + } +}