1
0
Fork 0
mirror of synced 2025-04-03 22:03:34 +03:00
Changing the coupon output
Edit text translations
Creating separate methods with checks
Fix check corporate person
This commit is contained in:
Ivan Chaplygin 2024-05-17 14:23:40 +03:00
parent d03d218b18
commit fad8a2539c
11 changed files with 29 additions and 27 deletions

View file

@ -586,5 +586,5 @@ msgstr "Es posible debitar"
msgid "bonuses"
msgstr "bonos"
msgid "Your coupon:"
msgstr "Tu cupón:"
msgid "Use coupon:"
msgstr "Utiliza el cupón:"

View file

@ -595,5 +595,5 @@ msgstr "Возможно списать"
msgid "bonuses"
msgstr "бонусов"
msgid "Your coupon:"
msgstr "Ваш купон:"
msgid "Use coupon:"
msgstr "Используйте купон:"

View file

@ -37,7 +37,7 @@ if (!class_exists('WC_Retailcrm_Loyalty')) :
$this->loyaltyForm = new WC_Retailcrm_Loyalty_Form();
$this->validator = new WC_Retailcrm_Loyalty_Validator(
$this->apiClient,
$this->settings['corporate_enabled'] ?? WC_Retailcrm_Base::NO
isCorporateUserActivate($this->settings)
);
}
@ -272,9 +272,8 @@ if (!class_exists('WC_Retailcrm_Loyalty')) :
return $resultString;
}
$resultString .= '<div style="background: #05ff13;">' . __('It is possible to write off', 'retailcrm') . ' ' . $lpDiscountSum . ' ' . __('bonuses', 'retailcrm') . '</div>';
return $resultString . '<div style="background: #05ff13;">' . __('Your coupon:', 'retailcrm') . ' ' . $coupon->get_code() . '</div>';
$resultString .= ' <div style="text-align: left; line-height: 2"><b>' . __('It is possible to write off', 'retailcrm') . ' ' . $lpDiscountSum . ' ' . __('bonuses', 'retailcrm') . '</b></div>';
return $resultString. '<div style="text-align: left;"><b>' . __('Use coupon:', 'retailcrm') . ' <u><i>' . $coupon->get_code() . '</i></u></i></b></div>';
}
public function clearLoyaltyCoupon()
@ -349,16 +348,7 @@ if (!class_exists('WC_Retailcrm_Loyalty')) :
public function isValidOrder($wcUser, $wcOrder)
{
return !(!$wcUser
|| (
isset($this->settings['corporate_enabled'])
&& $this->settings['corporate_enabled'] === WC_Retailcrm_Base::YES
&& (
!empty($wcUser->get_billing_company())
|| !empty($wcOrder->get_billing_company())
)
))
;
return !(!$wcUser || (isCorporateUserActivate($this->settings) && isCorporateOrder($wcUser, $wcOrder)));
}
public function applyLoyaltyDiscount($wcOrder, $discountLp, $createdOrder)

View file

@ -100,8 +100,10 @@ if (!class_exists('WC_Retailcrm_Orders')) :
$discountLp = $this->loyalty->deleteLoyaltyCouponInOrder($wcOrder);
$wcUser = $wcOrder->get_user();
if (!$this->loyalty->isValidOrder($wcUser, $wcOrder) && $discountLp > 0) {
writeBaseLogs('The user does not meet the requirements for working with the loyalty program. Order Id: ' . $orderId);
if (!$this->loyalty->isValidOrder($wcUser, $wcOrder)) {
if ($discountLp > 0) {
writeBaseLogs('The user does not meet the requirements for working with the loyalty program. Order Id: ' . $orderId);
}
$discountLp = 0;
} else {

View file

@ -207,3 +207,13 @@ function isLoyaltyActivate($settings)
{
return isset($settings['loyalty']) && $settings['loyalty'] === WC_Retailcrm_Base::YES;
}
function isCorporateUserActivate($settings)
{
return isset($settings['corporate_enabled']) && $settings['corporate_enabled'] === WC_Retailcrm_Base::YES;
}
function isCorporateOrder($wcUser, $wcOrder)
{
return !empty($wcUser->get_billing_company()) || !empty($wcOrder->get_billing_company());
}

View file

@ -59,7 +59,7 @@ if (!class_exists('WC_Retailcrm_Loyalty_Validator')) :
$customer = new WC_Customer($userId);
if ($this->isActiveCorp === WC_Retailcrm_Base::YES && !empty($customer->get_billing_company())) {
if ($this->isActiveCorp && !empty($customer->get_billing_company())) {
throw new ValidatorException($this->isCorporateUser, 400);
}

View file

@ -246,7 +246,7 @@ return [
"This user is a corporate person" => "Este usuario es una persona jurídica",
"It is possible to write off" => "Es posible debitar",
"bonuses" => "bonificaciones",
"Your coupon:" => "Tu cupón:",
"Use coupon:" => "Utiliza el cupón:",
],
"language" => "es",
"x-generator" => "GlotPress/2.4.0-alpha",

Binary file not shown.

View file

@ -245,7 +245,7 @@ return [
"This user is a corporate person" => "Этот пользователь является корпоративным лицом",
"It is possible to write off" => "Возможно списать",
"bonuses" => "бонусов",
"Your coupon:" => "Ваш купон:",
"Use coupon:" => "Используйте купон:",
],
"language" => "ru",
"x-generator" => "GlotPress/2.4.0-alpha",

Binary file not shown.

View file

@ -78,25 +78,25 @@ class DataLoyaltyRetailCrm
'responseApiMethod' => [],
'wcUserType' => 'individual',
'throwMessage' => 'User not found in the system',
'isCorpActive' => 'no'
'isCorpActive' => false
],
[
'responseApiMethod' => ['customer' => ['id' => 1]],
'wcUserType' => 'corp',
'throwMessage' => 'This user is a corporate person',
'isCorpActive' => 'yes',
'isCorpActive' => true
],
[
'responseApiMethod' => ['customer' => ['id' => 1]],
'wcUserType' => 'corp',
'throwMessage' => null,
'isCorpActive' => 'no',
'isCorpActive' => false
],
[
'responseApiMethod' => ['customer' => ['id' => 1]],
'wcUserType' => 'individual',
'throwMessage' => null,
'isCorpActive' => 'yes',
'isCorpActive' => true
],
];
}