gatewaySlug = $gatewaySlug; $this->methodHandler = 'fluent_cart_payment_settings_promo_gateway'; parent::__construct(); } public static function getDefaults() { return [ 'is_active' => 'no' ]; } public function get($key = null) { if ($key === 'is_active') { return 'no'; } if ($key) { return isset($this->settings[$key]) ? $this->settings[$key] : null; } return $this->settings; } public function getMode() { return 'test'; } public function isActive(): bool { return false; } public function setCustomStyles($styles) { $this->customStyles = $styles; } protected function getPromoNoticeStyles() { $defaults = [ 'light' => [ 'primary_gradient' => 'linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%)', 'text_primary' => '#1e293b', 'text_secondary' => '#475569', 'text_muted' => '#64748b', 'icon_bg' => '#e0e7ff', 'icon_color' => '#6366f1', 'feature_icon' => '#10b981', 'button_bg' => '#6366f1', 'button_text' => '#ffffff', 'border_color' => '#e2e8f0', 'feature_bg' => '#ffffff' ], 'dark' => [ 'primary_gradient' => 'linear-gradient(135deg, #1e293b 0%, #0f172a 100%)', 'text_primary' => '#f1f5f9', 'text_secondary' => '#cbd5e1', 'text_muted' => '#94a3b8', 'icon_bg' => 'rgba(99, 102, 241, 0.15)', 'icon_color' => '#818cf8', 'feature_icon' => '#34d399', 'button_bg' => '#6366f1', 'button_text' => '#ffffff', 'border_color' => '#334155', 'feature_bg' => 'rgba(15, 23, 42, 0.5)' ] ]; if (!empty($this->customStyles)) { $defaults['light'] = array_merge($defaults['light'], $this->customStyles['light'] ?? []); $defaults['dark'] = array_merge($defaults['dark'], $this->customStyles['dark'] ?? []); } return $defaults; } /** * Render SVG icon */ protected function renderIcon($svgPath, $styles = '') { return ''; } /** * Render a feature list item with checkmark */ protected function renderFeatureItem($text, $mode = 'light') { $styles = $this->getPromoNoticeStyles()[$mode]; $checkIcon = $this->renderIcon( 'M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z', 'width: 18px; height: 18px; fill: ' . $styles['feature_icon'] . '; margin-right: 10px; flex-shrink: 0;' ); return '
' . $checkIcon . '' . esc_html($text) . '' . '
'; } /** * Check if FluentCart Pro is installed */ protected function isProInstalled() { if (!function_exists('get_plugins')) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $all_plugins = get_plugins(); return isset($all_plugins['fluent-cart-pro/fluent-cart-pro.php']); } /** * Check if FluentCart Pro is active */ protected function isProActive() { if (!function_exists('is_plugin_active')) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } return is_plugin_active('fluent-cart-pro/fluent-cart-pro.php'); } /** * Render upgrade or activate button */ protected function renderActionButton($mode = 'light') { $styles = $this->getPromoNoticeStyles()[$mode]; // If Pro is installed but not active, show activate button if ($this->isProInstalled() && !$this->isProActive()) { return ''; } // Otherwise show upgrade button return '' . __('Upgrade to FluentCart Pro', 'fluent-cart') . ' →' . ''; } /** * Generate upgrade to pro notice HTML * * @param array $config Configuration array with: * - title: Gateway title * - description: Gateway description * - features: Array of feature strings * - icon_path: SVG path for the gateway icon * - footer_text: Optional footer text * @return string HTML for the upgrade notice */ public function generateUpgradeNotice($config) { $allStyles = $this->getPromoNoticeStyles(); // Determine footer text based on Pro status $defaultFooterText = __('Unlock all premium payment gateways and features', 'fluent-cart'); if ($this->isProInstalled() && !$this->isProActive()) { $defaultFooterText = __('FluentCart Pro is installed - Activate to unlock all premium features', 'fluent-cart'); } $footerText = Arr::get($config, 'footer_text') ? Arr::get($config, 'footer_text') : $defaultFooterText; $html = ''; foreach (['light', 'dark'] as $mode) { $styles = $allStyles[$mode]; $modeClass = $mode === 'dark' ? 'fct-promo-notice-dark' : 'fct-promo-notice-light'; $displayStyle = $mode === 'dark' ? 'display: none;' : ''; $html .= '
'; // Icon $html .= '
'; $html .= $this->renderIcon($config['icon_path'], 'width: 32px; height: 32px; fill: ' . $styles['icon_color'] . ';'); $html .= '
'; // Title $html .= '

' . esc_html($config['title']) . '

'; // Description $html .= '

' . esc_html($config['description']) . '

'; // Features if (!empty($config['features'])) { $html .= '
'; foreach ($config['features'] as $feature) { $html .= $this->renderFeatureItem($feature, $mode); } $html .= '
'; } // Action Button (Upgrade or Activate) $html .= '
' . $this->renderActionButton($mode) . '
'; // Footer $html .= '

' . esc_html($footerText) . '

'; $html .= '
'; } // Add CSS to toggle between light/dark modes $html .= ''; return $html; } }