← All changes
|
app/Hooks/Handlers/ShortCodes/CustomerProfileHandler.php
+27
-3
1.6.5
→
1.7.0
View file →
| @@ -14,8 +14,9 @@ | ||
| 14 | 14 | use FluentCart\App\Helpers\CurrenciesHelper; |
| 15 | 15 | use FluentCart\App\Helpers\Helper; |
| 16 | 16 | use FluentCart\App\Models\Subscription; |
| 17 | 17 | use FluentCart\App\Modules\Templating\AssetLoader; |
| 18 | +use FluentCart\App\Services\ProductReviewService; | |
| 18 | 19 | use FluentCart\App\Services\Renderer\CheckoutFieldsSchema; |
| 19 | 20 | use FluentCart\App\Services\TemplateService; |
| 20 | 21 | use FluentCart\App\Services\DateTime\DayjsFormatter; |
| 21 | 22 | use FluentCart\App\Services\Translations\TransStrings; |
| @@ -95,14 +96,20 @@ | ||
| 95 | 96 | $attributeUrl = str_replace(['[', ']', '"'], ['%5B', '%5D', '%22'], $redirectUrl); |
| 96 | 97 | echo do_shortcode('[fluent_auth redirect_to="' . $attributeUrl . '"]'); |
| 97 | 98 | echo '</div>'; |
| 98 | 99 | } else { |
| 100 | + // The Login link wears the portal's button pair (see | |
| 101 | + // customer-profile-global.scss), not the theme's `.button`. | |
| 102 | + Vite::enqueueStyle( | |
| 103 | + 'fluent-cart-customer-profile-global', | |
| 104 | + 'public/customer-profile/style/customer-profile-global.scss' | |
| 105 | + ); | |
| 99 | 106 | ?> |
| 100 | 107 | <div class="fct_auth_wrap"> |
| 101 | 108 | <div class="fct_auth_message"> |
| 102 | 109 | <h2><?php echo esc_html__('Login', 'fluent-cart'); ?></h2> |
| 103 | 110 | <p><?php echo esc_html__('Please log in to access your customer portal.', 'fluent-cart'); ?></p> |
| 104 | - <a href="<?php echo esc_url(wp_login_url($redirectUrl ?? '')); ?>" class="button"> | |
| 111 | + <a href="<?php echo esc_url(wp_login_url($redirectUrl ?? '')); ?>" class="button fct-customer-login-btn"> | |
| 105 | 112 | <?php echo esc_html__('Login', 'fluent-cart'); ?> |
| 106 | 113 | </a> |
| 107 | 114 | </div> |
| 108 | 115 | </div> |
| @@ -154,8 +161,12 @@ | ||
| 154 | 161 | echo $verificationNotice; // @phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped in the view |
| 155 | 162 | return; |
| 156 | 163 | } |
| 157 | 164 | |
| 165 | + if (!EmailVerificationService::isEnabled()) { | |
| 166 | + CustomerResource::getCurrentCustomer(true); | |
| 167 | + } | |
| 168 | + | |
| 158 | 169 | $customEndpointContent = $this->maybeCustomEndpointContent(); |
| 159 | 170 | |
| 160 | 171 | if(!$customEndpointContent) { |
| 161 | 172 | (new static())->enqueueStyles(); |
| @@ -298,8 +309,16 @@ | ||
| 298 | 309 | 'icon_svg' => '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none"> |
| 299 | 310 | <path d="M10.75 8.5H14.5L10 13L5.5 8.5H9.25V3.25H10.75V8.5ZM4 15.25H16V10H17.5V16C17.5 16.1989 17.421 16.3897 17.2803 16.5303C17.1397 16.671 16.9489 16.75 16.75 16.75H3.25C3.05109 16.75 2.86032 16.671 2.71967 16.5303C2.57902 16.3897 2.5 16.1989 2.5 16V10H4V15.25Z" fill="currentColor"/> |
| 300 | 311 | </svg>' |
| 301 | 312 | ], |
| 313 | + 'reviews' => [ | |
| 314 | + 'label' => __('My Reviews', 'fluent-cart'), | |
| 315 | + 'css_class' => 'fct_route', | |
| 316 | + 'link' => $baseUrl . 'reviews', | |
| 317 | + 'icon_svg' => '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none"> | |
| 318 | + <path d="M10 1.875L12.4635 6.86713L17.9727 7.66771L13.9863 11.5533L14.9271 17.0398L10 14.4488L5.07295 17.0398L6.01368 11.5533L2.02734 7.66771L7.53647 6.86713L10 1.875ZM10 5.26443L8.53252 8.23787L5.25123 8.71472L7.62536 11.0289L7.06498 14.2963L10 12.7534L12.935 14.2963L12.3746 11.0289L14.7488 8.71472L11.4675 8.23787L10 5.26443Z" fill="currentColor"/> | |
| 319 | + </svg>' | |
| 320 | + ], | |
| 302 | 321 | 'profile' => [ |
| 303 | 322 | 'label' => __('Profile', 'fluent-cart'), |
| 304 | 323 | 'css_class' => 'fct_route', |
| 305 | 324 | 'link' => $baseUrl . 'profile', |
| @@ -314,9 +333,13 @@ | ||
| 314 | 333 | if (!ModuleSettings::isActive('license') || !App::isProActive()) { |
| 315 | 334 | unset($menuItems['licenses']); |
| 316 | 335 | } |
| 317 | 336 | |
| 337 | + if (ProductReviewService::getReviewSettings()['reviews_enabled'] !== 'yes') { | |
| 338 | + unset($menuItems['reviews']); | |
| 339 | + } | |
| 318 | 340 | |
| 341 | + | |
| 319 | 342 | if($currentCustomer) { |
| 320 | 343 | $hasSubscriptions = Subscription::query()->where('customer_id', $currentCustomer->id)->exists(); |
| 321 | 344 | if(!$hasSubscriptions) { |
| 322 | 345 | unset($menuItems['subscriptions']); |
| @@ -340,9 +363,9 @@ | ||
| 340 | 363 | $user = wp_get_current_user(); |
| 341 | 364 | $profileData = [ |
| 342 | 365 | 'email' => $user->user_email, |
| 343 | 366 | 'full_name' => $user->display_name, |
| 344 | - 'photo' => get_avatar_url($user->ID) | |
| 367 | + 'photo' => Helper::getUserAvatarUrl($user->ID, $user->user_email) | |
| 345 | 368 | ]; |
| 346 | 369 | } |
| 347 | 370 | |
| 348 | 371 | add_filter('fct_allowed_svg_tags', function ($tags) { |
| @@ -416,9 +439,10 @@ | ||
| 416 | 439 | return html_entity_decode($sign, ENT_QUOTES, 'UTF-8'); |
| 417 | 440 | }, CurrenciesHelper::getCurrencySigns()), |
| 418 | 441 | 'trans' => TransStrings::getCustomerProfileString(), |
| 419 | 442 | 'download_url_base' => site_url('fluent-cart/download-file/?fluent_cart_download=true'), |
| 420 | - 'placeholder_image' => Vite::getAssetUrl('images/placeholder.svg'), | |
| 443 | + 'placeholder_image' => Helper::getProductPlaceholderUrl(), | |
| 444 | + 'reviews_enabled' => ProductReviewService::getReviewSettings()['reviews_enabled'] === 'yes', | |
| 421 | 445 | 'stripe_pub_key' => apply_filters('fluent_cart/payment_methods/stripe_pub_key', ''), |
| 422 | 446 | 'paypal_client_id' => apply_filters('fluent_cart/payment_methods/paypal_client_id', '', []), |
| 423 | 447 | 'assets_path' => Vite::getAssetUrl(), |
| 424 | 448 | 'rest' => Helper::getRestInfo(), |