← All changes
|
app/Modules/PaymentMethods/PromoGateways/Addons/AddonGatewaySettings.php
+17
-5
1.3.21
→
1.6.5
View file →
| @@ -1,8 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace FluentCart\App\Modules\PaymentMethods\PromoGateways\Addons; |
| 4 | 4 | |
| 5 | +use FluentCart\App\Helpers\Helper; | |
| 5 | 6 | use FluentCart\App\Modules\PaymentMethods\Core\BaseGatewaySettings; |
| 6 | 7 | use FluentCart\App\Services\PluginInstaller\PaymentAddonManager; |
| 7 | 8 | use FluentCart\Framework\Support\Arr; |
| 8 | 9 | |
| @@ -10,12 +11,12 @@ | ||
| 10 | 11 | { |
| 11 | 12 | protected $gatewaySlug; |
| 12 | 13 | protected $customStyles = []; |
| 13 | 14 | |
| 14 | - public function __construct($gatewaySlug) | |
| 15 | + public function __construct($gatewaySlug, $methodHandler = 'fluent_cart_payment_settings_addon_gateway') | |
| 15 | 16 | { |
| 16 | - $this->gatewaySlug = $gatewaySlug; | |
| 17 | - $this->methodHandler = 'fluent_cart_payment_settings_addon_gateway'; | |
| 17 | + $this->gatewaySlug = $gatewaySlug; | |
| 18 | + $this->methodHandler = $methodHandler; | |
| 18 | 19 | parent::__construct(); |
| 19 | 20 | } |
| 20 | 21 | |
| 21 | 22 | |
| @@ -160,8 +161,9 @@ | ||
| 160 | 161 | protected function renderInstallButton($addonSlug, $addonFile, $addonSource, $repoLink, $mode = 'light') |
| 161 | 162 | { |
| 162 | 163 | $styles = $this->getAddonNoticeStyles()[$mode]; |
| 163 | 164 | $downloadIcon = 'M13 10H18L12 16L6 10H11V3H13V10M4 19H20V12H22V20C22 20.5304 21.7893 21.0391 21.4142 21.4142C21.0391 21.7893 20.5304 22 20 22H4C3.46957 22 2.96086 21.7893 2.58579 21.4142C2.21071 21.0391 2 20.5304 2 20V12H4V19Z'; |
| 165 | + $buttonLabel = defined('FLUENTCART_PRO_PLUGIN_VERSION') ? __('Install & Activate', 'fluent-cart') : __('Download', 'fluent-cart'); | |
| 164 | 166 | |
| 165 | 167 | return '<button type="button" class="fct-btn fct-btn-primary fct-install-addon-btn" |
| 166 | 168 | style="display: inline-flex; align-items: center; background: ' . $styles['button_primary_bg'] . '; color: ' . $styles['button_primary_text'] . '; padding: 10px 24px; border-radius: 6px; border: none; font-weight: 500; font-size: 14px; cursor: pointer; transition: all 0.2s; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);" |
| 167 | 169 | data-addon-slug="' . esc_attr($addonSlug) . '" |
| @@ -169,9 +171,9 @@ | ||
| 169 | 171 | data-repo-link="' . esc_attr($repoLink) . '" |
| 170 | 172 | data-source-type="' . esc_attr(Arr::get($addonSource, 'type', 'github')) . '" |
| 171 | 173 | data-source-link="' . esc_attr($addonSource['link'] ?? '') . '">' |
| 172 | 174 | . $this->renderIcon($downloadIcon, 'width: 16px; height: 16px; margin-right: 6px; fill: ' . $styles['button_primary_text'] . ';') |
| 173 | - . __('Install & Activate', 'fluent-cart') | |
| 175 | + . $buttonLabel | |
| 174 | 176 | . '</button>'; |
| 175 | 177 | } |
| 176 | 178 | |
| 177 | 179 | |
| @@ -242,9 +244,19 @@ | ||
| 242 | 244 | foreach (['light', 'dark'] as $mode) { |
| 243 | 245 | $styles = $allStyles[$mode]; |
| 244 | 246 | |
| 245 | 247 | // Determine status and action button for this mode |
| 246 | - if (!$isInstalled) { | |
| 248 | + $proRequired = !empty($config['pro_required']) && !defined('FLUENTCART_PRO_PLUGIN_VERSION'); | |
| 249 | + if ($proRequired) { | |
| 250 | + $statusMessage = __('Requires Pro', 'fluent-cart'); | |
| 251 | + $statusColor = $styles['status_warning']; | |
| 252 | + $upgradeUrl = esc_url($config['repo_link'] ?? Helper::getUpgradeUrl('feature_lock_gateway_' . $this->gatewaySlug)); | |
| 253 | + $actionButton = '<a href="' . $upgradeUrl . '" target="_blank" rel="noopener noreferrer" ' | |
| 254 | + . 'style="display: inline-flex; align-items: center; background: ' . $styles['button_primary_bg'] . '; color: ' . $styles['button_primary_text'] . '; padding: 10px 24px; border-radius: 6px; font-weight: 500; font-size: 14px; text-decoration: none; box-shadow: 0 1px 3px rgba(0,0,0,0.1);">' | |
| 255 | + . $this->renderIcon('M12 1L3 5v6c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V5l-9-4zm0 4l5 2.18V11c0 3.5-2.33 6.79-5 7.93-2.67-1.14-5-4.43-5-7.93V7.18L12 5z', 'width: 16px; height: 16px; margin-right: 6px; fill: ' . $styles['button_primary_text'] . ';') | |
| 256 | + . __('Upgrade to Pro', 'fluent-cart') | |
| 257 | + . '</a>'; | |
| 258 | + } elseif (!$isInstalled) { | |
| 247 | 259 | $statusMessage = __('Not Installed', 'fluent-cart'); |
| 248 | 260 | $statusColor = $styles['status_warning']; |
| 249 | 261 | $actionButton = $this->renderInstallButton( |
| 250 | 262 | $config['addon_slug'], |