diff --git a/doc/1.Setup/Cron tasks.md b/doc/1.Setup/Cron tasks.md
index c468c05..5fc51f2 100644
--- a/doc/1.Setup/Cron tasks.md
+++ b/doc/1.Setup/Cron tasks.md
@@ -14,6 +14,7 @@
'icml' => 'three_hours',
'history' => 'five_minutes',
'inventories' => 'fiveteen_minutes',
+ 'loyalty_upload_price' => 'four_hours'
]
```
> Важно! При использовании фильтра **retailcrm_cron_schedules**, можно использовать ключи: 'icml', 'history', 'inventories'.
@@ -49,5 +50,3 @@ function change_cron_tasks($cronTasks)
return $cronTasks;
}
```
-
-
diff --git a/resources/pot/retailcrm-es_ES.pot b/resources/pot/retailcrm-es_ES.pot
index a09c4d5..e1bdfd9 100644
--- a/resources/pot/retailcrm-es_ES.pot
+++ b/resources/pot/retailcrm-es_ES.pot
@@ -591,3 +591,9 @@ msgstr "Utiliza el cupón:"
msgid "Points will be awarded upon completion of the order:"
msgstr "Los puntos se concederán al finalizar el pedido:"
+
+msgid "Upload of current prices of offers"
+msgstr "Carga de los precios actuales de las ofertas"
+
+msgid "Every 4 hours"
+msgstr "Cada 4 horas"
diff --git a/resources/pot/retailcrm-ru_RU.pot b/resources/pot/retailcrm-ru_RU.pot
index d6cf7c0..191bc1b 100644
--- a/resources/pot/retailcrm-ru_RU.pot
+++ b/resources/pot/retailcrm-ru_RU.pot
@@ -600,3 +600,9 @@ msgstr "Используйте купон:"
msgid "Points will be awarded upon completion of the order:"
msgstr "По завершению заказа будет начислено баллов:"
+
+msgid "Upload of current prices of offers"
+msgstr "Выгрузка текущих цен торговых предложений"
+
+msgid "Every 4 hours"
+msgstr "Каждые 4 часа"
diff --git a/src/assets/js/retailcrm-cron-info.js b/src/assets/js/retailcrm-cron-info.js
index 25083e3..14f4a9d 100644
--- a/src/assets/js/retailcrm-cron-info.js
+++ b/src/assets/js/retailcrm-cron-info.js
@@ -16,6 +16,7 @@ jQuery(function () {
this.history = 0;
this.inventories = 0;
this.messageSuccessful = '';
+ this.loyalty_upload_price = 0;
this.adminUrl = AdminUrl.url;
@@ -33,12 +34,14 @@ jQuery(function () {
_this.icml = response.icml;
_this.inventories = response.inventories;
_this.messageSuccessful = response.translate.tr_successful;
+ _this.loyalty_upload_price = response.loyalty_upload_price
_this.displayInfoAboutCron(
response.translate.tr_td_cron,
response.translate.tr_td_icml,
response.translate.tr_td_history,
response.translate.tr_td_inventories,
+ response.translate.tr_td_loyalty_upload_price
);
})
@@ -47,7 +50,7 @@ jQuery(function () {
jQuery(this.submitButton).click(this.clearCronTasks);
}
- RetailcrmCronInfo.prototype.displayInfoAboutCron = function (cron, icml, history, inventories) {
+ RetailcrmCronInfo.prototype.displayInfoAboutCron = function (cron, icml, history, inventories, loyalty_upload_price) {
this.table = jQuery(this.title).next();
this.table.append('
');
this.infoTable = jQuery('tbody[class="retail-debug-info"]').get(0);
@@ -56,6 +59,7 @@ jQuery(function () {
jQuery(this.infoTable).append("" + icml + " | " + this.icml + " |
");
jQuery(this.infoTable).append("" + history + " | " + this.history + " |
");
jQuery(this.infoTable).append("" + inventories + " | " + this.inventories + " |
");
+ jQuery(this.infoTable).append("" + loyalty_upload_price + " | " + this.loyalty_upload_price + " |
");
}
RetailcrmCronInfo.prototype.clearCronTasks = function () {
diff --git a/src/include/class-wc-retailcrm-base.php b/src/include/class-wc-retailcrm-base.php
index c2404d5..8e69a9e 100644
--- a/src/include/class-wc-retailcrm-base.php
+++ b/src/include/class-wc-retailcrm-base.php
@@ -127,6 +127,7 @@ if (!class_exists('WC_Retailcrm_Base')) {
add_action('woocommerce_applied_coupon', [$this, 'apply_coupon'], 11, 1);
add_action('woocommerce_review_order_before_payment', [$this, 'reviewCreditBonus'], 11, 1);
add_action('wp_trash_post', [$this, 'trash_order_action'], 10, 1);
+ add_action('retailcrm_loyalty_upload_price', [$this, 'upload_loyalty_price']);
if (
!$this->get_option('deactivate_update_order')
@@ -190,12 +191,23 @@ if (!class_exists('WC_Retailcrm_Base')) {
*/
public function api_sanitized($settings)
{
+ $isLoyaltyUploadPrice = false;
+
+ if (
+ isset($settings['icml'], $settings['loyalty'])
+ && $settings['icml'] === static::YES
+ && $settings['loyalty'] === static::YES
+ ) {
+ $isLoyaltyUploadPrice = true;
+ }
+
$timeInterval = apply_filters(
'retailcrm_cron_schedules',
[
'icml' => 'three_hours',
'history' => 'five_minutes',
'inventories' => 'fiveteen_minutes',
+ 'loyalty_upload_price' => 'four_hours'
]
);
@@ -223,6 +235,12 @@ if (!class_exists('WC_Retailcrm_Base')) {
wp_clear_scheduled_hook('retailcrm_icml');
}
+ if ($isLoyaltyUploadPrice && !wp_next_scheduled('retailcrm_loyalty_upload_price')) {
+ wp_schedule_event(time(), $timeInterval['loyalty_upload_price'], 'retailcrm_loyalty_upload_price');
+ } elseif (!$isLoyaltyUploadPrice) {
+ wp_clear_scheduled_hook('retailcrm_loyalty_upload_price');
+ }
+
if (!$this->get_errors() && !get_option('retailcrm_active_in_crm')) {
$this->activate_integration($settings);
}
@@ -268,6 +286,7 @@ if (!class_exists('WC_Retailcrm_Base')) {
wp_clear_scheduled_hook('retailcrm_icml');
wp_clear_scheduled_hook('retailcrm_history');
wp_clear_scheduled_hook('retailcrm_inventories');
+ wp_clear_scheduled_hook('retailcrm_loyalty_upload_price');
//Add new cron tasks
$this->api_sanitized($this->settings);
@@ -930,12 +949,15 @@ if (!class_exists('WC_Retailcrm_Base')) {
$icml = $defaultValue;
$history = $defaultValue;
$inventories = $defaultValue;
+ $loyaltyUploadPrice = $defaultValue;
+
$translate = [
'tr_td_cron' => __('Cron launches', 'retailcrm'),
'tr_td_icml' => __('Generation ICML', 'retailcrm'),
'tr_td_history' => __('Syncing history', 'retailcrm'),
'tr_successful' => __('Cron tasks cleared', 'retailcrm'),
'tr_td_inventories' => __('Syncing inventories', 'retailcrm'),
+ 'tr_td_loyalty_upload_price' => __('Upload of current prices of offers', 'retailcrm')
];
if (isset($this->settings['history']) && $this->settings['history'] == static::YES) {
@@ -944,6 +966,10 @@ if (!class_exists('WC_Retailcrm_Base')) {
if (isset($this->settings['icml']) && $this->settings['icml'] == static::YES) {
$icml = date('H:i:s d-m-Y', wp_next_scheduled('retailcrm_icml'));
+
+ if (isset($this->settings['loyalty']) && $this->settings['loyalty'] === static::YES) {
+ $loyaltyUploadPrice = date('H:i:s d-m-Y', wp_next_scheduled('retailcrm_loyalty_upload_price'));
+ }
}
if (isset($this->settings['sync']) && $this->settings['sync'] == static::YES) {
@@ -956,6 +982,7 @@ if (!class_exists('WC_Retailcrm_Base')) {
'icml' => $icml,
'inventories' => $inventories,
'translate' => $translate,
+ 'loyalty_upload_price' => $loyaltyUploadPrice
]
);
diff --git a/src/include/class-wc-retailcrm-plugin.php b/src/include/class-wc-retailcrm-plugin.php
index 1e9bdac..0d36453 100644
--- a/src/include/class-wc-retailcrm-plugin.php
+++ b/src/include/class-wc-retailcrm-plugin.php
@@ -58,6 +58,10 @@ class WC_Retailcrm_Plugin
'fiveteen_minutes' => [
'interval' => 900, // seconds
'display' => __('Every 15 minutes')
+ ],
+ 'four_hours' => [
+ 'interval' => 14400, //seconds
+ 'display' => __('Every 4 hours')
]
],
apply_filters('retailcrm_add_cron_interval', $schedules)
diff --git a/src/include/class-wc-retailcrm-upload-discount-price.php b/src/include/class-wc-retailcrm-upload-discount-price.php
index e80cac7..dca3213 100644
--- a/src/include/class-wc-retailcrm-upload-discount-price.php
+++ b/src/include/class-wc-retailcrm-upload-discount-price.php
@@ -27,6 +27,10 @@ if (!class_exists('WC_Retailcrm_Upload_Discount_Price')):
public function upload()
{
+ if (!$this->activeLoyalty) {
+ return;
+ }
+
$error = $this->uploadSettings();
if ($error !== '') {
@@ -85,7 +89,10 @@ if (!class_exists('WC_Retailcrm_Upload_Discount_Price')):
foreach ($chunks as $chunk) {
$this->apiClient->storePricesUpload($chunk, $this->site);
+ time_nanosleep(0, 200000000);
}
+
+ unset($chunks);
} catch (\Throwable $exception) {
writeBaseLogs($exception->getMessage() . PHP_EOL . $exception->getTraceAsString());
diff --git a/src/languages/retailcrm-es_ES.l10n.php b/src/languages/retailcrm-es_ES.l10n.php
index 5d58e8e..b33d9a0 100644
--- a/src/languages/retailcrm-es_ES.l10n.php
+++ b/src/languages/retailcrm-es_ES.l10n.php
@@ -248,6 +248,8 @@ return [
"bonuses" => "bonificaciones",
"Use coupon:" => "Utiliza el cupón:",
"Points will be awarded upon completion of the order:" => "Los puntos se concederán al finalizar el pedido:",
+ "Upload of current prices of offers" => "Upload of current prices of offers",
+ "Every 4 hours" => "Cada 4 horas"
],
"language" => "es",
"x-generator" => "GlotPress/2.4.0-alpha",
diff --git a/src/languages/retailcrm-es_ES.mo b/src/languages/retailcrm-es_ES.mo
index 051c9cf..c6b63f8 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.l10n.php b/src/languages/retailcrm-ru_RU.l10n.php
index 5afac2b..0c250ca 100644
--- a/src/languages/retailcrm-ru_RU.l10n.php
+++ b/src/languages/retailcrm-ru_RU.l10n.php
@@ -247,6 +247,8 @@ return [
"bonuses" => "бонусов",
"Use coupon:" => "Используйте купон:",
"Points will be awarded upon completion of the order:" => "По завершению заказа будет начислено баллов:",
+ "Upload of current prices of offers" => "Выгрузка текущих цен торговых предложений",
+ "Every 4 hours" => "Каждые 4 часа"
],
"language" => "ru",
"x-generator" => "GlotPress/2.4.0-alpha",
diff --git a/src/languages/retailcrm-ru_RU.mo b/src/languages/retailcrm-ru_RU.mo
index 5cb7b69..d499cfe 100644
Binary files a/src/languages/retailcrm-ru_RU.mo and b/src/languages/retailcrm-ru_RU.mo differ