PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.0
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.0
1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 trunk All 48 releases
fluent-cart / app / Hooks / Handlers / ShortCodes / CustomerLoginHandler.php

CustomerLoginHandler.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.6.0, at app/Hooks/Handlers/ShortCodes/CustomerLoginHandler.php

86 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\App\Hooks\Handlers\ShortCodes;
4
5
6 use FluentCart\Api\StoreSettings;
7 use FluentCart\App\App;
8 use FluentCart\App\Helpers\CartCheckoutHelper;
9 use FluentCart\App\Helpers\Helper;
10
11
12 class CustomerLoginHandler extends ShortCode
13 {
14 const SHORT_CODE = 'fluent_cart_login_form';
15 protected static string $shortCodeName = 'fluent_cart_login_form';
16
17
18 public static function register()
19 {
20 parent::register();
21
22 add_action('wp_enqueue_scripts', function () {
23 if (App::request()->get('action') === 'elementor') {
24 return;
25 }
26
27 if (is_page() && is_main_query()) {
28 $page_id = get_queried_object_id();
29 $storePageId = null;
30 if ($page_id == $storePageId) {
31 (new static())->enqueueStyles();
32 }
33 return;
34 }
35
36 if (has_shortcode(get_the_content(), static::SHORT_CODE) || has_block('fluent-cart/login-form')) {
37 (new static())->enqueueStyles();
38 }
39 }, 10);
40 }
41
42
43 public function getScripts(): array
44 {
45 return [
46 [
47 'source' => 'public/checkout/login.js',
48 'dependencies' => [],
49 'inFooter' => true
50 ]
51 ];
52 }
53
54 public function getStyles(): array
55 {
56 return [
57 [
58 'source' => 'public/checkout/style/login.scss',
59 ]
60 ];
61 }
62
63 public function localizeData(): array
64 {
65 return [
66 'fluentcart_checkout_info' => [
67 'rest' => Helper::getRestInfo(),
68 ]
69 ];
70 }
71
72 public function viewData(): ?array
73 {
74 return [
75 'checkout' => CartCheckoutHelper::make()
76 ];
77 }
78
79 public function render(?array $viewData = null)
80 {
81 ob_start();
82 do_action('fluent_cart/views/checkout_page_login_form', $viewData);
83 return ob_get_clean();
84 }
85 }
86