PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.5.1
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.5.1
1.6.6 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 All 49 releases
fluent-cart / app / Hooks / Handlers / ShortCodes / CustomerRegistrationHandler.php

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

85 lines 2.1 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 CustomerRegistrationHandler extends ShortCode
13 {
14 const SHORT_CODE = 'fluent_cart_registration_form';
15 protected static string $shortCodeName = 'fluent_cart_registration_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 = (new StoreSettings())->getRegistrationPageId();
30 if ($page_id == $storePageId) {
31 (new static())->enqueueStyles();
32 }
33 return;
34 }
35 if (has_shortcode(get_the_content(), static::SHORT_CODE) || has_block('fluent-cart/registration-form')) {
36 (new static())->enqueueStyles();
37 }
38 }, 10);
39 }
40
41 public function getScripts(): array
42 {
43 return [
44 [
45 'source' => 'public/checkout/registration.js',
46 'dependencies' => [],
47 'inFooter' => true
48 ]
49 ];
50 }
51
52 public function getStyles(): array
53 {
54 return [
55 [
56 'source' => 'public/checkout/style/registration.scss',
57 ]
58 ];
59 }
60
61 public function localizeData(): array
62 {
63 return [
64 'fluentcart_checkout_info' => [
65 'rest' => Helper::getRestInfo(),
66 ]
67 ];
68 }
69
70 public function viewData(): ?array
71 {
72 return [
73 'checkout' => CartCheckoutHelper::make()
74 ];
75 }
76
77 public function render(?array $viewData = null)
78 {
79 ob_start();
80 do_action('fluent_cart/views/checkout_page_registration_form', $viewData);
81 return ob_get_clean();
82 }
83
84 }
85