diff --git a/resources/pot/retailcrm-ru_RU.pot b/resources/pot/retailcrm-ru_RU.pot index 8c451d5..b7db938 100644 --- a/resources/pot/retailcrm-ru_RU.pot +++ b/resources/pot/retailcrm-ru_RU.pot @@ -508,8 +508,8 @@ msgstr "Активировать участие в программе лояль msgid "Send" msgstr "Отправить" -msgid "To register in the Loyalty Program, fill in the form:" -msgstr "Для регистрации в Программе лояльности заполните форму:" +msgid "To register in the loyalty program, fill in the form:" +msgstr "Для регистрации в программе лояльности заполните форму:" msgid " I agree with " msgstr " Я согласен с " @@ -523,8 +523,8 @@ msgstr "условиями обработки персональных данн msgid "Phone" msgstr "Телефон" -msgid "Error while registering in the loyalty program. Try again later." -msgstr "Ошибка при регистрации в программе лояльности. Попробуйте позже." +msgid "Error while registering in the loyalty program. Try again later" +msgstr "Ошибка при регистрации в программе лояльности. Попробуйте позже" msgid "The card is not linked" msgstr "Карта не привязана" @@ -535,8 +535,8 @@ msgstr "Обычные товары" msgid "Promotional products" msgstr "Акционные товары" -msgid "bonus for every" -msgstr "бонус за каждые" +msgid "accrual of 1 bonus for each" +msgstr "начисление 1 бонуса за каждые" msgid "of the purchase amount" msgstr "от суммы покупки" @@ -547,8 +547,11 @@ msgstr "начисление бонусов в размере" msgid "discount" msgstr "скидка" -msgid "Error while retrieving data. Try again later." -msgstr "Ошибка при получении данных. Попробуйте позже." +msgid "Error while retrieving data. Try again later" +msgstr "Ошибка при получении данных. Попробуйте позже" -msgid "Error when activating the loyalty program. Try again later." -msgstr "Ошибка при активации программы лояльности. Попробуйте позже." +msgid "Error when activating the loyalty program. Try again later" +msgstr "Ошибка при активации программы лояльности. Попробуйте позже" + +msgid "Enter the correct phone number" +msgstr "Введите корректный номер телефона" diff --git a/src/assets/js/retailcrm-loyalty-actions.js b/src/assets/js/retailcrm-loyalty-actions.js index cee73ca..2c0fec9 100644 --- a/src/assets/js/retailcrm-loyalty-actions.js +++ b/src/assets/js/retailcrm-loyalty-actions.js @@ -20,7 +20,7 @@ jQuery(function() { let phone = jQuery('#phoneLoyalty'); if (!phone.val().match(/(?:\+|\d)[\d\-\(\) ]{7,}\d/)) { - phone.parent().append('test') + phone.parent().append('' + messagePhone + '') event.preventDefault(); return false; diff --git a/src/include/class-wc-retailcrm-base.php b/src/include/class-wc-retailcrm-base.php index fbbd701..0cc1fcf 100644 --- a/src/include/class-wc-retailcrm-base.php +++ b/src/include/class-wc-retailcrm-base.php @@ -640,18 +640,18 @@ if (!class_exists('WC_Retailcrm_Base')) { if (empty($site)) { writeBaseLogs('Error with CRM credentials: need an valid apiKey assigned to one certain site'); - echo json_encode(['error' => __('Error while registering in the loyalty program. Try again later.', 'retailcrm')]); + echo json_encode(['error' => __('Error while registering in the loyalty program. Try again later', 'retailcrm')]); } if (!$userId || !$phone) { writeBaseLogs('Errors when registering a loyalty program. Passed parameters: userId = ' . ($userId ?? 'NULL') . ' phone = ' . ($phone ?? 'NULL')); - echo json_encode(['error' => __('Error while registering in the loyalty program. Try again later.', 'retailcrm')]); + echo json_encode(['error' => __('Error while registering in the loyalty program. Try again later', 'retailcrm')]); } $isSuccessful = $this->loyalty->registerCustomer($userId, $phone, $site); if (!$isSuccessful) { - echo json_encode(['error' => __('Error while registering in the loyalty program. Try again later.', 'retailcrm')]); + echo json_encode(['error' => __('Error while registering in the loyalty program. Try again later', 'retailcrm')]); } else { echo json_encode(['isSuccessful' => true]); } @@ -665,13 +665,13 @@ if (!class_exists('WC_Retailcrm_Base')) { if (!$loyaltyId) { writeBaseLogs('Errors when activate loyalty program. loyaltyId is missing'); - echo json_encode(['error' => __('Error when activating the loyalty program. Try again later.', 'retailcrm')]); + echo json_encode(['error' => __('Error when activating the loyalty program. Try again later', 'retailcrm')]); } $isSuccessful = $this->loyalty->activateLoyaltyCustomer($loyaltyId); if (!$isSuccessful) { - echo json_encode(['error' => __('Error when activating the loyalty program. Try again later.', 'retailcrm')]); + echo json_encode(['error' => __('Error when activating the loyalty program. Try again later', 'retailcrm')]); } else { echo json_encode(['isSuccessful' => true]); } @@ -898,16 +898,18 @@ if (!class_exists('WC_Retailcrm_Base')) { $jsScript = 'retailcrm-loyalty-actions'; $loyaltyUrl = ['url' => get_admin_url()]; $jsScriptsPath = plugins_url() . '/woo-retailcrm/assets/js/'; + $messagePhone = __('Enter the correct phone number', 'retailcrm'); wp_register_script($jsScript, $jsScriptsPath . $jsScript . '.js', false, '0.1'); wp_enqueue_script($jsScript, $jsScriptsPath . $jsScript . '.js', '', '', true); wp_localize_script($jsScript, 'LoyaltyUrl', $loyaltyUrl); wp_localize_script($jsScript, 'customerId', $userId); + wp_localize_script($jsScript, 'messagePhone', $messagePhone); $result = $this->loyalty->getForm($userId); if ([] === $result) { - echo '

'. __('Error while retrieving data. Try again later.', 'retailcrm') . '

'; + echo '

'. __('Error while retrieving data. Try again later', 'retailcrm') . '

'; } else { wp_localize_script($jsScript, 'loyaltyId', $result['loyaltyId'] ?? null); echo $result['form']; diff --git a/src/include/class-wc-retailcrm-loyalty.php b/src/include/class-wc-retailcrm-loyalty.php index 599bead..56c1e5c 100644 --- a/src/include/class-wc-retailcrm-loyalty.php +++ b/src/include/class-wc-retailcrm-loyalty.php @@ -31,15 +31,15 @@ if (!class_exists('WC_Retailcrm_Loyalty')) : { $result = []; - $response = $this->apiClient->customersGet($userId); - - if (!isset($response['customer']['id'])) { - return $result; - } - - $filter['customerId'] = $response['customer']['id']; - try { + $response = $this->apiClient->customersGet($userId); + + if (!isset($response['customer']['id'])) { + return $result; + } + + $filter['customerId'] = $response['customer']['id']; + $response = $this->apiClient->getLoyaltyAccountList($filter); } catch (Throwable $exception) { writeBaseLogs('Exception get loyalty accounts: ' . $exception->getMessage()); @@ -79,7 +79,7 @@ if (!class_exists('WC_Retailcrm_Loyalty')) :

', - __('To register in the Loyalty Program, fill in the form:', 'retailcrm'), + __('To register in the loyalty program, fill in the form:', 'retailcrm'), __(' I agree with ', 'retailcrm'), __('loyalty program terms', 'retailcrm'), __(' I agree with ', 'retailcrm'), @@ -149,8 +149,8 @@ if (!class_exists('WC_Retailcrm_Loyalty')) : switch ($loyaltyAccount['level']['type']) { case 'bonus_converting': - $data[] = __('Ordinary goods', 'retailcrm') . ': 1 ' . __('bonus for every', 'retailcrm') . ' '. $loyaltyAccount['level']['privilegeSize']; - $data[] = __('Promotional products', 'retailcrm') . ': 1 ' . __('bonus for every', 'retailcrm') . ' '. $loyaltyAccount['level']['privilegeSizePromo']; + $data[] = __('Ordinary goods', 'retailcrm') . ': ' . __('accrual of 1 bonus for each', 'retailcrm') . ' '. $loyaltyAccount['level']['privilegeSize'] . ' ' . $loyaltyAccount['loyalty']['currency']; + $data[] = __('Promotional products', 'retailcrm') . ': ' . __('accrual of 1 bonus for each', 'retailcrm') . ' '. $loyaltyAccount['level']['privilegeSizePromo']. ' ' . $loyaltyAccount['loyalty']['currency']; break; case 'bonus_percent': $data[] = __('Ordinary goods', 'retailcrm') . ': ' . __('bonus accrual in the amount of', 'retailcrm'). ' ' . $loyaltyAccount['level']['privilegeSize'] . '% ' . __('of the purchase amount', 'retailcrm'); diff --git a/src/languages/retailcrm-ru_RU.mo b/src/languages/retailcrm-ru_RU.mo index 7ca912e..6f527a6 100644 Binary files a/src/languages/retailcrm-ru_RU.mo and b/src/languages/retailcrm-ru_RU.mo differ