1
0
mirror of synced 2025-03-20 15:13:56 +03:00

Refactor code, finalized user interface and translations for the upload functionality

This commit is contained in:
Dima Uryvskiy 2021-12-28 13:35:36 +03:00 committed by GitHub
parent 6132172da5
commit c57cb099e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 136 additions and 130 deletions

View File

@ -31,24 +31,24 @@ msgstr "https://wordpress.org/plugins/woo-retailcrm/"
msgid "WooCommerce Simla.com"
msgstr "WooCommerce Simla.com"
msgid "This functionality allows to upload orders to Simla.com differentially."
msgstr "Esta función permite la subida selectiva de los pedidos al Simla.com."
msgid "Orders"
msgstr "Pedidos"
msgid "Uploading orders by identifiers."
msgstr "Subida de los pedidos por identificadores."
msgid "Customers"
msgstr "Clientes"
msgid "Enter orders identifiers separated by a comma."
msgstr "Introduce los identificadores de pedidos separados por coma."
msgid "This functionality allows to upload orders to Simla.com differentially"
msgstr "Esta función permite la subida selectiva de los pedidos al Simla.com"
msgid "Uploading orders by identifiers"
msgstr "Subida de los pedidos por identificadores"
msgid "Enter orders identifiers separated by a comma, but no more than 50"
msgstr "Introduce los identificadores de pedidos separados por coma, pero no más de 50"
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"
@ -70,8 +70,8 @@ msgstr "Introduce el enlace del Simla.com 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 Simla.com."
msgstr "Esta función permite generar los catálogos de pedidos ICML para subida al Simla.com."
msgid "This functionality allows to generate ICML products catalog for uploading to Simla.com"
msgstr "Esta función permite generar los catálogos de pedidos ICML para subida al Simla.com"
msgid "Generating ICML"
msgstr "Generando ICML"
@ -86,7 +86,7 @@ msgid "Settings"
msgstr "Ajustes"
msgid "Uploading the existing customers and orders to Simla.com"
msgstr "Subida de los clientes existentes y pedidos al Simla.com."
msgstr "Subida de los clientes existentes y pedidos al Simla.com"
msgid "Uploading all customers and orders"
msgstr "Subir todos los clientes y pedidos"
@ -104,7 +104,7 @@ 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."
msgstr "Activa esta opción para subir los datos al UA"
msgid "UA"
msgstr "UA"
@ -115,8 +115,8 @@ 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 Simla.com to the website."
msgstr "Active esta opción si quiere recibir la información del stock de los productos desde Simla.com a la página web."
msgid "Enable this setting if you would like to get information on leftover stocks from Simla.com to the website"
msgstr "Active esta opción si quiere recibir la información del stock de los productos desde Simla.com a la página web"
msgid "Stock balance"
msgstr "El stock"
@ -166,11 +166,11 @@ msgstr "Ajustes de API"
msgid "Enter your API key. You can find it in the administration section of Simla.com"
msgstr "Introduce la llave API. Puede encontrarla en apartado administrativo del Simla.com"
msgid "Enter with your API URL (https://yourdomain.simla.com)."
msgstr "Introduce enlace de API (https://yourdomain.simla.com)."
msgid "Enter API of URL (https://yourdomain.simla.com)"
msgstr "Introduce enlace de API (https://yourdomain.simla.com)"
msgid "Integration with Simla.com management system."
msgstr "La integración con el sistema de gestión del Simla.com ."
msgid "Integration with Simla.com management system"
msgstr "La integración con el sistema de gestión del Simla.com"
msgid "Every 15 minutes"
msgstr "Cada 15 minutos"
@ -259,8 +259,8 @@ msgstr "Se abrirá una ventana de chat con este contacto en WhatsApp"
msgid "Introduce the correct phone number"
msgstr "Introduce el número de teléfono correcto"
msgid "You can export all orders and customers from CMS to Simla.com by clicking the «Upload» button. This process can take much time and before it is completed, you need to keep the tab open."
msgstr "Presionando el botón «Exportar» puedes descargar a todos los pedidos y clientes de CMS a Simla.com. Este proceso puede llevar mucho tiempo y es necesario mantener abierta la pestaña hasta que termine el proceso."
msgid "You can export all orders and customers from CMS to Simla.com by clicking the «Upload» button. This process can take much time and before it is completed, you need to keep the tab open"
msgstr "Presionando el botón «Exportar» puedes descargar a todos los pedidos y clientes de CMS a Simla.com. Este proceso puede llevar mucho tiempo y es necesario mantener abierta la pestaña hasta que termine el proceso"
msgid "Debug information"
msgstr "Información Debug"

View File

@ -31,6 +31,12 @@ msgstr "https://wordpress.org/plugins/woo-retailcrm/"
msgid "WooCommerce Simla.com"
msgstr "WooCommerce Simla.com"
msgid "Orders"
msgstr "Заказы"
msgid "Customers"
msgstr "Клиенты"
msgid "Activate history uploads"
msgstr "Активировать загрузку истории изменений"
@ -40,24 +46,18 @@ msgstr "Загрузка данных из Simla.com"
msgid "Generating ICML catalog by wp-cron"
msgstr "Генерация ICML каталога товаров с помощью wp-cron"
msgid "This functionality allows to upload orders to Simla.com differentially."
msgid "This functionality allows to upload orders to Simla.com differentially"
msgstr "Эта функция позволяет производить выборочную выгрузку заказов в Simla.com"
msgid "Uploading orders by identifiers."
msgid "Uploading orders by identifiers"
msgstr "Выгрузка заказов по идентификаторам"
msgid "Enter orders identifiers separated by a comma."
msgstr "Введите идентификаторы заказов через запятую"
msgid "Enter orders identifiers separated by a comma, but no more than 50"
msgstr "Введите идентификаторы заказов через запятую, но не более 50"
msgid "Orders identifiers"
msgstr "Идентификаторы заказов"
msgid "Order identifier"
msgstr "Идентификатор заказа"
msgid "Upload the order by ID"
msgstr "Выгрузить заказ по идентификатору"
msgid "Orders were uploaded"
msgstr "Заказы были выгружены"
@ -79,7 +79,7 @@ msgstr "Введите корректный адрес Simla.com"
msgid "The selected API version is unavailable"
msgstr "Выбранная версия API недоступна"
msgid "This functionality allows to generate ICML products catalog for uploading to Simla.com."
msgid "This functionality allows to generate ICML products catalog for uploading to Simla.com"
msgstr "Эта функция позволяет сгенерировать ICML каталог товаров для выгрузки в Simla.com"
msgid "Generating ICML"
@ -124,8 +124,8 @@ msgstr "Активировать UA"
msgid "UA settings"
msgstr "Настройки UA"
msgid "Enable this setting if you would like to get information on leftover stocks from Simla.com to the website."
msgstr "Активируйте данную настройку, если хотите получать остатки по товарам из Simla.com на сайт."
msgid "Enable this setting if you would like to get information on leftover stocks from Simla.com to the website"
msgstr "Активируйте данную настройку, если хотите получать остатки по товарам из Simla.com на сайт"
msgid "Stock balance"
msgstr "Остатки"
@ -173,12 +173,12 @@ msgid "API settings"
msgstr "Настройки API"
msgid "Enter your API key. You can find it in the administration section of Simla.com"
msgstr "Введите API ключ. Вы можете найти его в административном разделе Simla.com."
msgstr "Введите API ключ. Вы можете найти его в административном разделе Simla.com"
msgid "Enter API of URL (https://yourdomain.simla.com)."
msgstr "Введите API URL (https://yourdomain.simla.com)."
msgid "Enter API of URL (https://yourdomain.simla.com)"
msgstr "Введите API URL (https://yourdomain.simla.com)"
msgid "Integration with Simla.com management system."
msgid "Integration with Simla.com management system"
msgstr "Интеграция с системой управления Simla.com"
msgid "Every 15 minutes"
@ -268,8 +268,8 @@ msgstr "Будет открыт чат в WhatsApp с данным контак
msgid "Introduce the correct phone number"
msgstr "Введите корректный номер телефона"
msgid "You can export all orders and customers from CMS to Simla.com by clicking the «Upload» button. This process can take much time and before it is completed, you need to keep the tab open."
msgstr "Вы можете экспортировать все заказы и клиентов из CMS в Simla.com, нажав кнопку «Выгрузить». Этот процесс может занять много времени, и до его завершения необходимо держать вкладку открытой."
msgid "You can export all orders and customers from CMS to Simla.com by clicking the «Upload» button. This process can take much time and before it is completed, you need to keep the tab open"
msgstr "Вы можете экспортировать все заказы и клиентов из CMS в Simla.com, нажав кнопку «Выгрузить». Этот процесс может занять много времени, и до его завершения необходимо держать вкладку открытой"
msgid "Debug information"
msgstr "Отладочная информация"

View File

@ -10,7 +10,7 @@
.retail-progress__loader {
width: 0;
border-radius: 18px;
background: #6427D6;
background: #4169e1;
color: white;
text-align: center;
padding: 0 30px;
@ -28,6 +28,6 @@
.retail-count-data-upload {
margin-bottom: 20px;
size: 30px;
color: #6427D6;
color: #4169e1;
font-weight: bold;
}
}

View File

@ -1 +1 @@
.retail-progress{border-radius:18px;border:1px solid rgba(122,122,122,0.15);width:400px;height:18px;overflow:hidden;transition:height .25s ease}.retail-progress__loader{width:0;border-radius:18px;background:#6427D6;color:#fff;text-align:center;padding:0 30px;font-size:18px;font-weight:600;transition:width .4s ease-in;line-height:18px;box-sizing:border-box}.retail-hidden{display:none!important}.retail-count-data-upload{margin-bottom:20px;size:30px;color:#6427D6;font-weight:700}
.retail-progress{border-radius:18px;border:1px solid rgba(122,122,122,.15);width:400px;height:18px;overflow:hidden;transition:height .25s ease}.retail-progress__loader{width:0;border-radius:18px;background:#4169e1;color:#fff;text-align:center;padding:0 30px;font-size:18px;font-weight:600;transition:width .4s ease-in;line-height:18px;box-sizing:border-box}.retail-hidden{display:none!important}.retail-count-data-upload{margin-bottom:20px;size:30px;color:#4169e1;font-weight:700}

View File

@ -2,6 +2,7 @@ jQuery(function () {
function RetailcrmExportForm()
{
this.submitButton = jQuery('button[id="export-orders-submit"]').get(0);
this.selectedOrdersButton = jQuery('button[id="export_selected_orders_btn"]').get(0);
jQuery(this.submitButton).after('<div id="export-orders-progress" class="retail-progress retail-hidden"></div');
jQuery(this.submitButton).before('<div id="export-orders-count" class="retail-count-data-upload"></div');
@ -12,6 +13,10 @@ jQuery(function () {
return false;
}
if (typeof this.selectedOrdersButton === 'undefined') {
return false;
}
if (typeof this.progressBar === 'undefined') {
return false;
}
@ -34,7 +39,10 @@ jQuery(function () {
_this.customersCount = Number(response.count_users);
jQuery(_this.submitButton).removeClass('retail-hidden');
_this.displayCountUploadData();
_this.messageEmtyField = response.translate.tr_empty_field;
_this.messageSuccessful = response.translate.tr_successful;
_this.displayCountUploadData(response.translate.tr_order, response.translate.tr_customer);
})
this.isDone = false;
@ -44,17 +52,20 @@ jQuery(function () {
this.customersStep = 0;
this.displayCountUploadData = this.displayCountUploadData.bind(this);
this.submitAction = this.submitAction.bind(this);
this.actionExportSelectedOrders = this.actionExportSelectedOrders.bind(this);
this.exportAction = this.exportAction.bind(this);
this.exportDone = this.exportDone.bind(this);
this.initializeProgressBar = this.initializeProgressBar.bind(this);
this.updateProgressBar = this.updateProgressBar.bind(this);
jQuery(this.submitButton).click(this.submitAction);
jQuery(this.selectedOrdersButton).click(this.actionExportSelectedOrders);
}
RetailcrmExportForm.prototype.displayCountUploadData = function () {
RetailcrmExportForm.prototype.displayCountUploadData = function (order, customer) {
this.counter = jQuery('div[id="export-orders-count"]').get(0);
jQuery(this.counter).text('Customers: ' + this.customersCount + ' Orders: ' + this.ordersCount);
jQuery(this.counter).text(`${customer}: ${this.customersCount} ${order}: ${this.ordersCount}`);
}
RetailcrmExportForm.prototype.submitAction = function (event) {
@ -141,9 +152,27 @@ jQuery(function () {
RetailcrmExportForm.prototype.exportDone = function () {
window.removeEventListener('beforeunload', this.confirmLeave);
alert('Done');
alert(this.messageSuccessful);
}
RetailcrmExportForm.prototype.actionExportSelectedOrders = function () {
let ids = jQuery('#woocommerce_integration-retailcrm_export_selected_orders_ids').val();
if (ids === '') {
alert(this.messageEmtyField);
} else {
let _this = this;
jQuery.ajax({
type: "POST",
url: window.location.origin + '/wp-admin/admin-ajax.php?action=upload_selected_orders&order_ids_retailcrm=' + ids,
success: function (response) {
alert(_this.messageSuccessful);
}
});
}
};
window.RetailcrmExportForm = RetailcrmExportForm;
if (!(typeof RetailcrmExportForm === 'undefined')) {

View File

@ -1,6 +1,6 @@
<?php
/**
* PHP version 5.3
* PHP version 5.6
*
* @category Integration
* @author RetailCRM <integration@retailcrm.ru>
@ -27,7 +27,7 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
{
$this->id = 'integration-retailcrm';
$this->method_title = __('Simla.com', 'retailcrm');
$this->method_description = __('Integration with Simla.com management system.', 'retailcrm');
$this->method_description = __('Integration with Simla.com management system', 'retailcrm');
static::$option_key = $this->get_option_key();
@ -38,7 +38,6 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
}
}
/**
* @codeCoverageIgnore
*/
@ -61,34 +60,6 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
<?php
}
/**
* @codeCoverageIgnore
*/
public function ajax_selected_order()
{
$ajax_url = admin_url('admin-ajax.php');
$ids = $this->plugin_id . $this->id . '_single_order';
?>
<script type="text/javascript">
jQuery('#single_order_btn').bind('click', function() {
if (jQuery('#<?php echo $ids; ?>').val() == '') {
alert('<?php echo __('The field cannot be empty, enter the order ID', 'retailcrm'); ?>');
} else {
jQuery.ajax({
type: "POST",
url: '<?php echo $ajax_url; ?>?action=order_upload&order_ids_retailcrm=' + jQuery('#<?php echo $ids; ?>').val(),
success: function (response) {
alert('<?php echo __('Orders were uploaded', 'retailcrm'); ?>');
}
});
}
});
</script>
<?php
}
/**
* Initialize integration settings form fields.
*/
@ -100,7 +71,7 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
'api_url' => array(
'title' => __( 'API of URL', 'retailcrm' ),
'type' => 'text',
'description' => __( 'Enter API of URL (https://yourdomain.simla.com).', 'retailcrm' ),
'description' => __( 'Enter API of URL (https://yourdomain.simla.com)', 'retailcrm' ),
'desc_tip' => true,
'default' => ''
),
@ -326,7 +297,7 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
'title' => __('Stock balance', 'retailcrm'),
'class' => 'checkbox',
'type' => 'checkbox',
'description' => __('Enable this setting if you would like to get information on leftover stocks from Simla.com to the website.', 'retailcrm')
'description' => __('Enable this setting if you would like to get information on leftover stocks from Simla.com to the website', 'retailcrm')
);
/**
@ -397,11 +368,29 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
'label' => __('Upload', 'retailcrm'),
'title' => __('Uploading all customers and orders', 'retailcrm'),
'type' => 'button',
'description' => __('You can export all orders and customers from CMS to Simla.com by clicking the «Upload» button. This process can take much time and before it is completed, you need to keep the tab open.', 'retailcrm'),
'description' => __('You can export all orders and customers from CMS to Simla.com by clicking the «Upload» button. This process can take much time and before it is completed, you need to keep the tab open', 'retailcrm'),
'desc_tip' => true,
'id' => 'export-orders-submit'
);
$this->form_fields['export_selected_orders_ids'] = array(
'label' => __('Orders identifiers', 'retailcrm'),
'title' => __('Orders identifiers', 'retailcrm'),
'type' => 'text',
'description' => __('Enter orders identifiers separated by a comma, but no more than 50', 'retailcrm'),
'desc_tip' => true,
'id' => 'export_selected_orders_ids'
);
$this->form_fields['export_selected_orders_btn'] = array(
'label' => __('Upload', 'retailcrm'),
'title' => __('Uploading orders by identifiers', 'retailcrm'),
'type' => 'button',
'description' => __('This functionality allows to upload orders to Simla.com differentially', 'retailcrm'),
'desc_tip' => true,
'id' => 'export_selected_orders_btn'
);
/**
* WhatsApp options
*/
@ -449,7 +438,7 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
'label' => __('Generate now', 'retailcrm'),
'title' => __('Generating ICML', 'retailcrm'),
'type' => 'button',
'description' => __('This functionality allows to generate ICML products catalog for uploading to Simla.com.', 'retailcrm'),
'description' => __('This functionality allows to generate ICML products catalog for uploading to Simla.com', 'retailcrm'),
'desc_tip' => true,
'id' => 'icml-retailcrm'
);
@ -461,32 +450,6 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
'type' => 'checkbox'
);
/**
* Upload single order
*/
$this->form_field[] = array(
'title' => __('Upload the order by ID', 'retailcrm'),
'type' => 'title',
'description' => '',
'id' => 'order_options'
);
$this->form_fields['single_order'] = array(
'label' => __('Order identifier', 'retailcrm'),
'title' => __('Orders identifiers', 'retailcrm'),
'type' => 'input',
'description' => __('Enter orders identifiers separated by a comma.', 'retailcrm'),
'desc_tip' => true
);
$this->form_fields[] = array(
'label' => __('Upload', 'retailcrm'),
'title' => __('Uploading orders by identifiers.', 'retailcrm'),
'type' => 'button',
'description' => __('This functionality allows to upload orders to CRM differentially.', 'retailcrm'),
'desc_tip' => true,
'id' => 'single_order_btn'
);
$this->form_fields['history'] = array(
'label' => __('Activate history uploads', 'retailcrm'),

View File

@ -79,7 +79,7 @@ if (!class_exists('WC_Retailcrm_Base')) {
add_action('wp_ajax_cron_info', array($this, 'get_cron_info'), 99);
add_action('wp_ajax_content_upload', array($this, 'count_upload_data'), 99);
add_action('wp_ajax_generate_icml', array($this, 'generate_icml'));
add_action('wp_ajax_order_upload', array($this, 'order_upload'));
add_action('wp_ajax_upload_selected_orders', array($this, 'upload_selected_orders'));
add_action('admin_print_footer_scripts', array($this, 'ajax_generate_icml'), 99);
add_action('admin_print_footer_scripts', array($this, 'ajax_selected_order'), 99);
add_action('woocommerce_created_customer', array($this, 'create_customer'), 10, 1);
@ -241,7 +241,7 @@ if (!class_exists('WC_Retailcrm_Base')) {
*
* @return void
*/
public function order_upload()
public function upload_selected_orders()
{
$this->uploader->uploadSelectedOrders();
}
@ -523,10 +523,18 @@ if (!class_exists('WC_Retailcrm_Base')) {
*/
public function count_upload_data()
{
$translate = array(
'tr_order' => __('Orders', 'retailcrm'),
'tr_customer' => __('Customers', 'retailcrm'),
'tr_empty_field' => __('The field cannot be empty, enter the order ID', 'retailcrm'),
'tr_successful' => __('Orders were uploaded', 'retailcrm'),
);
echo json_encode(
array(
'count_orders' => $this->uploader->getCountOrders(),
'count_users' => $this->uploader->getCountUsers()
'count_users' => $this->uploader->getCountUsers(),
'translate' => $translate,
)
);

View File

@ -59,12 +59,10 @@ if (class_exists('WC_Retailcrm_Uploader') === false) {
*/
public function uploadSelectedOrders()
{
$response = filter_input(INPUT_GET, 'order_ids_retailcrm');
if (false === empty($response)) {
$ids = array_unique(explode(',', $response));
if (false === empty($ids)) {
if (!empty($_GET['order_ids_retailcrm'])) {
$ids = array_unique(explode(',', $_GET['order_ids_retailcrm']));
if (!empty($ids)) {
$this->uploadArchiveOrders(0, $ids);
}
}
@ -76,7 +74,7 @@ if (class_exists('WC_Retailcrm_Uploader') === false) {
* @param int $page Number page uploads.
* @param array $ids Ids orders upload.
*
* @return array|null
* @return void|null
* @throws Exception Invalid argument exception.
*/
public function uploadArchiveOrders($page, $ids = array())
@ -101,8 +99,6 @@ if (class_exists('WC_Retailcrm_Uploader') === false) {
}
$this->logOrdersUploadErrors($uploadErrors);
return array();
}
/**

Binary file not shown.

Binary file not shown.

View File

@ -80,7 +80,8 @@ class WC_Retailcrm_Base_Test extends WC_Retailcrm_Test_Case_Helper
$this->assertArrayHasKey('whatsapp_location_icon', $this->baseRetailcrm->form_fields);
$this->assertArrayHasKey('whatsapp_number', $this->baseRetailcrm->form_fields);
$this->assertArrayHasKey('icml', $this->baseRetailcrm->form_fields);
$this->assertArrayHasKey('single_order', $this->baseRetailcrm->form_fields);
$this->assertArrayHasKey('export_selected_orders_ids', $this->baseRetailcrm->form_fields);
$this->assertArrayHasKey('export_selected_orders_btn', $this->baseRetailcrm->form_fields);
$this->assertArrayHasKey('history', $this->baseRetailcrm->form_fields);
$this->assertArrayHasKey('deactivate_update_order', $this->baseRetailcrm->form_fields);
$this->assertArrayHasKey('bind_by_sku', $this->baseRetailcrm->form_fields);

View File

@ -78,11 +78,20 @@ class WC_Retailcrm_Uploader_Test extends WC_Retailcrm_Test_Case_Helper
$retailcrm_uploader = $this->getRetailcrmUploader($retailcrm);
$data = $retailcrm_uploader->uploadArchiveOrders(0);
if ($retailcrm) {
$this->assertInternalType('array', $data);
} else {
$this->assertEquals(null, $data);
}
$this->assertEquals(null, $data);
}
/**
* @param $retailcrm
* @dataProvider dataProviderApiClient
*/
public function test_upload_selected_orders()
{
$_GET['order_ids_retailcrm'] = '123, 345, 456';
$retailcrm_uploader = $this->getRetailcrmUploader($this->apiMock);
$uploadSelectedOrders = $retailcrm_uploader->uploadSelectedOrders();
$this->assertEquals(null, $uploadSelectedOrders);
}
public function test_get_count_orders_upload()