diff --git a/src/include/class-wc-retailcrm-base.php b/src/include/class-wc-retailcrm-base.php index 5d05161..52b8e45 100644 --- a/src/include/class-wc-retailcrm-base.php +++ b/src/include/class-wc-retailcrm-base.php @@ -1167,17 +1167,20 @@ if (!class_exists('WC_Retailcrm_Base')) { $cssPath = plugins_url() . self::ASSETS_DIR . '/css/'; $messagePhone = __('Enter the correct phone number', 'retailcrm'); + $loyaltyTemrs = $this->settings['loyalty_terms'] ?? ''; + $loyaltyPersonal = $this->settings['loyalty_personal'] ?? ''; + 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); - wp_localize_script($jsScript, 'termsLoyalty', $this->settings['loyalty_terms']); - wp_localize_script($jsScript, 'privacyLoyalty', $this->settings['loyalty_personal']); + wp_localize_script($jsScript, 'termsLoyalty', $loyaltyTemrs); + wp_localize_script($jsScript, 'privacyLoyalty', $loyaltyPersonal); wp_register_style('retailcrm-loyalty-style', $cssPath . 'retailcrm-loyalty-style.css', false, '0.1'); wp_enqueue_style('retailcrm-loyalty-style'); - $result = $this->loyalty->getForm($userId); + $result = $this->loyalty->getForm($userId, $loyaltyTemrs, $loyaltyPersonal); if ([] === $result) { echo '

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

'; diff --git a/src/include/class-wc-retailcrm-loyalty.php b/src/include/class-wc-retailcrm-loyalty.php index c065e6a..30b22b2 100644 --- a/src/include/class-wc-retailcrm-loyalty.php +++ b/src/include/class-wc-retailcrm-loyalty.php @@ -41,7 +41,7 @@ if (!class_exists('WC_Retailcrm_Loyalty')) : ); } - public function getForm(int $userId) + public function getForm(int $userId, $loyaltyTerms = '', $loyaltyPersonal = '') { $result = []; $phone = ''; @@ -75,7 +75,7 @@ if (!class_exists('WC_Retailcrm_Loyalty')) : $result['loyaltyId'] = $loyaltyAccount['id']; } } else { - $result['form'] = $this->loyaltyForm->getRegistrationForm($phone); + $result['form'] = $this->loyaltyForm->getRegistrationForm($phone, $loyaltyTerms, $loyaltyPersonal); } return $result; diff --git a/src/include/components/class-wc-retailcrm-loyalty-form.php b/src/include/components/class-wc-retailcrm-loyalty-form.php index c398b8c..d919aa1 100644 --- a/src/include/components/class-wc-retailcrm-loyalty-form.php +++ b/src/include/components/class-wc-retailcrm-loyalty-form.php @@ -5,14 +5,33 @@ if (!class_exists('WC_Retailcrm_Loyalty')) : class WC_Retailcrm_Loyalty_Form { - public function getRegistrationForm($phone = '') + public function getRegistrationForm($phone = '', $loyaltyTerms = '', $loyaltyPersonal = '') { + $htmlLoyaltyTerms = $loyaltyTerms !== '' + ? sprintf( + '

%s%s.

', + __(' I agree with ', 'retailcrm'), + __('loyalty program terms', 'retailcrm') + ) + : '' + ; + + $htmlLoyaltyPersonal = $loyaltyPersonal !== '' + ? sprintf( + '

%s%s.

', + __(' I agree with ', 'retailcrm'), + __('terms of personal data processing', 'retailcrm') + ) + : '' + ; + + return sprintf( '

%s

-

%s%s.

-

%s%s.

+ %s + %s

@@ -25,10 +44,8 @@ if (!class_exists('WC_Retailcrm_Loyalty')) : ', __('To register in the loyalty program, fill in the form:', 'retailcrm'), - __(' I agree with ', 'retailcrm'), - __('loyalty program terms', 'retailcrm'), - __(' I agree with ', 'retailcrm'), - __('terms of personal data processing', 'retailcrm'), + $htmlLoyaltyTerms, + $htmlLoyaltyPersonal, __('Phone', 'retailcrm'), $phone, __('Send', 'retailcrm'),