Removal of loyalty program conditions from the form if there is no text
This commit is contained in:
parent
8e5cb10d57
commit
70f9a5e11d
3 changed files with 32 additions and 12 deletions
|
@ -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 '<p style="color: red">'. __('Error while retrieving data. Try again later', 'retailcrm') . '</p>';
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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(
|
||||
'<p><input type="checkbox" name="terms" id="termsLoyalty" required>%s<a id="terms-popup" class="popup-open-loyalty" href="#">%s</a>.</p>',
|
||||
__(' I agree with ', 'retailcrm'),
|
||||
__('loyalty program terms', 'retailcrm')
|
||||
)
|
||||
: ''
|
||||
;
|
||||
|
||||
$htmlLoyaltyPersonal = $loyaltyPersonal !== ''
|
||||
? sprintf(
|
||||
'<p><input type="checkbox" name="privacy" id="privacyLoyalty" required>%s<a id="privacy-popup" class="popup-open-loyalty" href="#">%s</a>.</p>',
|
||||
__(' I agree with ', 'retailcrm'),
|
||||
__('terms of personal data processing', 'retailcrm')
|
||||
)
|
||||
: ''
|
||||
;
|
||||
|
||||
|
||||
return sprintf(
|
||||
'
|
||||
<form id="loyaltyRegisterForm" method="post">
|
||||
<p>%s</p>
|
||||
<p><input type="checkbox" name="terms" id="termsLoyalty" required>%s<a id="terms-popup" class="popup-open-loyalty" href="#">%s</a>.</p>
|
||||
<p><input type="checkbox" name="privacy" id="privacyLoyalty" required>%s<a id="privacy-popup" class="popup-open-loyalty" href="#">%s</a>.</p>
|
||||
%s
|
||||
%s
|
||||
<p><input type="text" name="phone" id="phoneLoyalty" placeholder="%s" value="%s" required></p>
|
||||
<p><input type="submit" value="%s"></p>
|
||||
</form>
|
||||
|
@ -25,10 +44,8 @@ if (!class_exists('WC_Retailcrm_Loyalty')) :
|
|||
</div>
|
||||
',
|
||||
__('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'),
|
||||
|
|
Loading…
Add table
Reference in a new issue