Changeset 3308199
- Timestamp:
- 06/08/2025 11:44:16 PM (10 months ago)
- Location:
- mlm-soft-integration/trunk
- Files:
-
- 5 edited
-
CHANGELOG.md (modified) (1 diff)
-
integrations/woocommerce/modules/WCPaymentModule.php (modified) (2 diffs)
-
integrations/woocommerce/paymentGateways/eWallet/coupons/EWalletCouponFrontend.php (modified) (4 diffs)
-
mlm-soft-integration.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
mlm-soft-integration/trunk/CHANGELOG.md
r3260839 r3308199 2 2 3 3 ## Changelog ## 4 5 ## 2025-06-04 - version 3.9.3 6 * Fixed an issue [MLM-3029] with cancel of coupon for completed orders. [EWalletCouponFrontend.php] 7 * Added localization for the payment module. [WCPaymentModule.php] 4 8 5 9 ## 2025-03-24 - version 3.9.2 -
mlm-soft-integration/trunk/integrations/woocommerce/modules/WCPaymentModule.php
r3038254 r3308199 3 3 namespace MLMSoft\integrations\woocommerce\modules; 4 4 5 use MLMSoft\core\MLMSoftPlugin; 5 6 use MLMSoft\integrations\woocommerce\paymentGateways\eWallet\MLMSoftEWalletGateway; 6 7 … … 11 12 $this->initGateways(); 12 13 add_filter('woocommerce_payment_gateways', [$this, 'registerPaymentGateways']); 14 15 /** 16 * @since 3.9.3 17 */ 18 add_action('wp_print_footer_scripts', [$this, 'moduleLocalization'] ); 19 } 20 21 /** 22 * @since 3.9.3 23 */ 24 public function moduleLocalization() 25 { 26 if (!is_cart() && !is_checkout() && !isset($_GET['pay_for_order'])) { 27 /** 28 * @see mlm-soft-integration\integrations\woocommerce\paymentGateways\eWallet\MLMSoftEWalletGateway.php 29 */ 30 return; 31 } 32 33 $l10n = [ 34 'pageNotFound' => MLMSoftPlugin::translate('Page not found'), 35 'walletBalance' => MLMSoftPlugin::translate('Balance'), 36 'paymentFromBonusWallet' => MLMSoftPlugin::translate('Payment from bonus wallet'), // 37 'selectWallet' => MLMSoftPlugin::translate('Please select the wallet'), // Выберите кошелек 38 'maxAmountToPayFromWallet' => MLMSoftPlugin::translate('Maximum amount to be paid from the wallet'), // Максимальная сумма для оплаты с кошелька 39 'enterAmount' => MLMSoftPlugin::translate('Enter the amount'), // Введите сумму 40 'payButton' => MLMSoftPlugin::translate('Pay'), // Оплатить 41 'fieldRequired' => MLMSoftPlugin::translate('Field required'), // Поле является обязательным 42 'amountMustBeGreaterThan' => MLMSoftPlugin::translate('The amount must be greater than'), // Сумма должна быть больше 43 'amountMustBeLessThan' => MLMSoftPlugin::translate('The amount must be less than'), // Сумма должна быть меньше 44 'walletBalanceExceeded' => MLMSoftPlugin::translate('Wallet balance exceeded'), // Баланс кошелька превышен 45 'noWalletsAvailable' => MLMSoftPlugin::translate('No wallets available for payment'), // Нет кошельков доступных для оплаты 46 'required' => MLMSoftPlugin::translate('required'), // обязательно 47 'optional' => MLMSoftPlugin::translate('optional'), // необязательно 48 ]; 49 50 /** 51 * Filters the localization payment module. 52 * 53 * @since 3.9.3 54 * 55 * @param array $l10n Localization array. 56 * @param string $locale Current locale. 57 */ 58 $l10n = apply_filters('mlmsoft_integration_payment_module_l10n', $l10n, get_locale()); 59 60 $content = '<script type="text/javascript" id="'.MLMSoftPlugin::PLUGIN_PREFIX.'payment_module_l10n">'."\n"; 61 $content .= '/* <![CDATA[ */'."\n"; 62 $content .= 'var MLMSIPaymentModuleL10n = '.json_encode($l10n).';'."\n"; 63 $content .= '/* ]]> */'."\n"; 64 $content .= '</script>'."\n"; 65 echo $content; 13 66 } 14 67 -
mlm-soft-integration/trunk/integrations/woocommerce/paymentGateways/eWallet/coupons/EWalletCouponFrontend.php
r3014550 r3308199 22 22 private $adminComponentLoader; 23 23 24 /** 25 * @since 3.9.3 26 * @var string 27 */ 28 private $couponPostType = 'shop_coupon'; 29 30 /** 31 * @since 3.9.3 32 * @var string 33 */ 34 private $manageCouponRole = 'administrator'; 35 36 /** 37 * @since 3.9.3 38 * @var array 39 */ 40 private $currentUserRoles; 41 24 42 public function __construct() 25 43 { … … 27 45 add_action('woocommerce_coupon_data_panels', [$this, 'addCouponDataPanel'], 1, 2); 28 46 47 /** 48 * @since 3.9.3 49 * 50 * @see wp-admin\includes\class-wp-posts-list-table.php 51 */ 52 add_action('post_row_actions', [$this, 'manageCouponActions'], 10, 2); 53 29 54 $this->adminComponentLoader = new AdminComponentLoader(); 30 55 } 31 56 57 /** 58 * @since 3.9.3 59 */ 60 public function hasUserManageCouponRole(): bool 61 { 62 if ( is_null($this->currentUserRoles) ) { 63 $user = wp_get_current_user(); 64 $this->currentUserRoles = (array) $user->roles; 65 } 66 67 if ( in_array($this->manageCouponRole, $this->currentUserRoles) ) { 68 return true; 69 } 70 71 return false; 72 } 73 74 /** 75 * @since 3.9.3 76 */ 77 public function manageCouponActions($actions, $post) 78 { 79 if ( $this->couponPostType !== $post->post_type ) { 80 return $actions; 81 } 82 83 if ( ! EWalletCoupon::isEWalletCoupon($post->post_name) ) { 84 /** 85 * Coupon is not connected to the e-wallet. 86 */ 87 return $actions; 88 } 89 90 if ( ! $this->hasUserManageCouponRole() ) { 91 /** 92 * @todo 93 */ 94 unset($actions['trash']); 95 return $actions; 96 } 97 98 $coupon = new EWalletCoupon($post->post_name); 99 100 if ( $coupon->get_usage_count() >= $coupon->get_usage_limit() ) { 101 unset($actions['trash']); 102 return $actions; 103 } 104 105 return $actions; 106 } 107 32 108 public function addDataTab($data) 33 109 { 110 /** 111 * @since 3.9.3 112 */ 113 if ( ! $this->hasUserManageCouponRole() ) { 114 unset($data['usage_restriction']); 115 unset($data['usage_limit']); 116 } 117 34 118 $data[self::E_WALLET_COUPON_DATA_KEY] = [ 35 119 'label' => MLMSoftPlugin::translate('EWallet info'), … … 37 121 'class' => '', 38 122 ]; 123 39 124 return $data; 40 125 } … … 52 137 } else { 53 138 $coupon = new EWalletCoupon($coupon->get_code()); 54 if (!$coupon->getAccountId()) { 139 140 if ( ! $coupon->getAccountId() ) { 55 141 echo '<div style="margin: 10px">' . MLMSoftPlugin::translate('Account ID not found in the coupon (old version)') . '</div>'; 56 142 } else { 57 $this->showInfo($coupon); 143 144 /** 145 * @since 3.9.3 146 */ 147 if ( $this->hasUserManageCouponRole() && $coupon->get_usage_count() < $coupon->get_usage_limit() ) { 148 $this->showInfo($coupon); 149 } else { 150 $this->showShortInfo($coupon); 151 } 58 152 } 59 153 } 60 154 echo '</div>'; 155 } 156 157 /** 158 * @since 3.9.3 159 * 160 * @param EWalletCoupon $coupon 161 */ 162 public function showShortInfo($coupon) 163 { 164 $mlmSoftPlugin = MLMSoftPlugin::getInstance(); 165 $accountId = $coupon->getAccountId(); 166 167 try { 168 $remoteUser = MLMSoftRemoteUser::loadByAccountId($accountId); 169 } catch (Exception $exception) { 170 $remoteUser = false; 171 } 172 173 try { 174 $wallets = $mlmSoftPlugin->api3->get("account/$accountId/wallet"); 175 } catch (Exception $exception) { 176 $wallets = []; 177 } 178 $walletId = $coupon->getWalletId(); 179 $couponWallet = []; 180 foreach ($wallets as $wallet) { 181 if ($wallet['id'] == $walletId) { 182 $couponWallet = $wallet; 183 break; 184 } 185 } 186 187 $payAmount = $coupon->getPayAmount(); 188 189 $walletContent = ''; 190 $currencyId = ''; 191 if ( empty($couponWallet) ) { 192 $walletContent = ' - '; 193 } else { 194 $walletContent = $couponWallet['title'].'('.$couponWallet['currency_id'].')'; 195 $currencyId = ' '.$couponWallet['currency_id']; 196 } 197 198 $accountContent = ''; 199 if ( $remoteUser ) { 200 $account = $remoteUser->getAccount(); 201 $accountContent = $account['title'].' ('.$account['idValue']['presentable'].')'; 202 } else { 203 $accountContent = 'Remote account not found.'; 204 } 205 206 $content = ''; 207 $content .= '<div class="" style="margin: 1rem 0 20px 1rem;font-size: 1rem;display:grid;gap:.5rem;">'; 208 $content .= '<div class="" style="display:grid;width: 99%;border-bottom: 1px #000 solid;">'; 209 $content .= '<div class="">Wallet:</div>'; 210 $content .= '<div class="" style="font-weight:700;">'.$walletContent.'</div>'; 211 $content .= '</div>'; 212 $content .= '<div class="" style="display:grid;width: 99%;border-bottom: 1px #000 solid;">'; 213 $content .= '<div class="">Account:</div>'; 214 $content .= '<div class="" style="font-weight:700;">'.$accountContent.'</div>'; 215 $content .= '</div>'; 216 $content .= '<div class="" style="display:grid;width: 99%;border-bottom: 1px #000 solid;">'; 217 $content .= '<div class="">Payment:</div>'; 218 $content .= '<div class="" style="font-weight:700;">Paid ('.$payAmount.$currencyId.')</div>'; 219 $content .= '</div>'; 220 $content .= '</div>'; 221 222 echo $content; 61 223 } 62 224 -
mlm-soft-integration/trunk/mlm-soft-integration.php
r3260839 r3308199 4 4 Plugin Name: MLM Soft Integration 5 5 Description: WP integration with mlm-soft.com cloud platform 6 Version: 3.9. 26 Version: 3.9.3 7 7 Author: MLM Soft Ltd. 8 8 Author URI: https://mlm-soft.com -
mlm-soft-integration/trunk/readme.txt
r3197899 r3308199 3 3 Tags: network marketing, MLM, direct sales, multi level marketing, mlm-soft.com 4 4 Requires at least: 4.7 5 Tested up to: 6. 75 Tested up to: 6.8 6 6 Requires PHP: 5.6 7 7 License: GPLv2 or later
Note: See TracChangeset
for help on using the changeset viewer.