PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 2.10.0
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v2.10.0
2.10.0 2.10.01 2.9.1 2.9.0 2.8.1 2.8.0 2.7.7 2.7.5 2.7.0 2.6.01 2.6.0 2.5.0 2.4.01 trunk 1.0.90 1.0.91 1.0.92 1.0.93 1.0.94 1.0.95 1.0.96 1.0.97 1.0.98 1.0.99 1.1.0 All 77 releases
fluent-community / Modules / Integrations / FluentCart / CartCheckout.php

CartCheckout.php in FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses 2.10.0, at Modules/Integrations/FluentCart/CartCheckout.php

170 lines 7.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCommunity\Modules\Integrations\FluentCart;
4
5 use FluentCart\App\Modules\Templating\AssetLoader;
6 use FluentCommunity\App\Models\BaseSpace;
7 use FluentCommunity\Framework\Support\Arr;
8 use FluentCommunity\Modules\Theming\TemplateLoader;
9
10 class CartCheckout
11 {
12 public function register()
13 {
14 add_filter('fluent_community/app_route_paths', function ($paths) {
15 $paths[] = 'checkout';
16 return $paths;
17 });
18
19 add_action('fluent_community/rendering_path_ssr_checkout', [$this, 'renderNativeCheckout'], 10);
20
21 add_action('fluent_cart/checkout/prepare_other_data', function ($event) {
22 $order = Arr::get($event, 'order');
23 $requestData = Arr::get($event, 'request_data', []);
24 if (!$order || empty($requestData['_fcom_space_id'])) {
25 return;
26 }
27
28 $prevConfig = $order->config;
29 $prevConfig['_fcom_space_id'] = intval($requestData['_fcom_space_id']);
30 $order->config = $prevConfig;
31 $order->save();
32 });
33
34 add_action('fluent_cart/receipt/thank_you/after_header_title', function ($event) {
35 $order = Arr::get($event, 'order');
36 if (!$order || empty($order->config['_fcom_space_id']) || $order->payment_status !== 'paid') {
37 return;
38 }
39
40 $spaceId = intval($order->config['_fcom_space_id']);
41 $space = BaseSpace::query()->onlyMain()->find($spaceId);
42
43 if (!$space) {
44 return;
45 }
46
47 ?>
48 <style>
49 .fcom_checkout_thank_you_box {
50 text-align: center;
51 }
52
53 .fcom_checkout_thank_you_box p {
54 margin: 0;
55 color: #000;
56 font-size: 1em;
57 }
58 </style>
59 <div class="fcom_checkout_thank_you_box">
60 <p>
61 <?php
62 if ($space->type === 'course') {
63 printf(
64 /* translators: 1: space name, 2: call to action */
65 esc_html__('You have successfully joined the %1$s. %2$s', 'fluent-community'),
66 esc_html($space->title),
67 '<br /><a href="' . esc_url($space->getPermalink()) . '">' . esc_html__('Go to the course', 'fluent-community') . '</a>'
68 );
69 } else {
70 printf(
71 /* translators: 1: space name, 2: call to action */
72 esc_html__('You have successfully joined the %1$s. %2$s', 'fluent-community'),
73 esc_html($space->title),
74 '<br /><a href="' . esc_url($space->getPermalink()) . '">' . esc_html__('Go to the space', 'fluent-community') . '</a>'
75 );
76 }
77 ?>
78 </p>
79 </div>
80 <?php
81 });
82
83 }
84
85 public function renderNativeCheckout($parts = [])
86 {
87 add_filter('pre_get_document_title', function ($title) {
88 return __('Checkout', 'fluent-community');
89 });
90
91 if (isset($_REQUEST['space_id'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
92 add_action('fluent_cart/checkout_form_opening', function () {
93 $spaceId = intval($_REQUEST['space_id'] ?? ''); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
94 ?>
95 <input type="hidden" name="_fcom_space_id" value="<?php echo esc_attr((string) $spaceId); ?>"/>
96 <?php
97 });
98 }
99
100
101 AssetLoader::loadCartAssets();
102 remove_all_actions('fluent_community/theme_content', 10);
103 add_action('fluent_community/theme_content', function () {
104 $cart = \FluentCart\App\Helpers\CartHelper::getCart();
105 ?>
106 <div class="fcom_single_layout fcom_max_layout feeds">
107 <div class="no_bg_layout fhr_content_layout">
108 <div style="max-width: 1080px;padding: 0 2rem 2rem; margin: 2rem auto;"
109 class="fhr_content_layout_body">
110 <h2 class="fcom_checkout_title"><?php echo esc_html__('Checkout', 'fluent-community'); ?></h2>
111 <div class="fcom_checkout_body">
112 <?php echo do_shortcode('[fluent_cart_checkout]'); ?>
113 </div>
114 </div>
115 </div>
116 </div>
117 <?php
118 });
119
120 add_action('wp_head', function () {
121 if (!did_action('pre_get_document_title')) {
122 echo '<title>' . esc_html__('Checkout', 'fluent-community') . ' - ' . esc_html(get_bloginfo('name')) . '</title>';
123 }
124
125 ?>
126 <style>
127 .fcom_checkout_body, .fct_address_modal {
128 --fct-checkout-primary-text-color: var(--fcom-primary-text, #606266);
129 --fct-checkout-summary-bg-color: var(--fcom-primary-bg, #FFFFFF);
130 --fct-checkout-secondary-text-color: var(--fcom-secondary-text, #959595);
131 --fct-checkout-border-color: var(--fcom-primary-border, #e3e8ee);
132 --fct-checkout-active-border-color: var(--fcom-secondary-border, #2B2E33);
133 --fct-checkout-primary-bg-color: var(--fcom-primary-button);
134 --fct-checkout-secondary-bg-color: var(--fcom-secondary-bg, #f0f0f1);
135 --fct-checkout-btn-bg-color: var(--fcom-primary-button, #2B2E33);
136 --fct-checkout-btn-text-color: var(--fcom-primary-button-text, #FFFFFF);
137 --fct-btn-border-color: var(--fcom-primary-button, #2B2E33);
138 --fct-checkout-input-bg-color: var(--fcom-primary-bg, #FFFFFF);
139 --fct-checkout-input-border-color: var(--fcom-primary-border, #e3e8ee);
140 --fct-checkout-input-text-color: var(--fcom-primary-text, #606266);
141 --fct-checkout-input-disabled-bg-color: var(--fcom-active-bg, #f0f0f1);
142 --fct-input-bg-color: var(--fcom-primary-bg, #FFFFFF);
143 --fct-input-text-color: var(--fcom-primary-text, #606266);
144 --fct-input-placeholder-text-color: var(--fcom-secondary-text, #959595);
145 --fct-input-disabled-bg-color: var(--fcom-secondary-bg, #f0f0f1);
146 --fct-secondary-text-color: var(--fcom-secondary-text, #959595);
147 --fct-select-dropdown-bg: var(--fcom-primary-bg, #FFFFFF);
148 --fct-select-option-hover-bg: var(--fcom-secondary-bg, #f0f0f1);
149 --fct-checkout-input-placeholder-text-color: var(--fcom-secondary-text, #959595);
150 --fct-checkout-payment-method-bg-color: var(--fcom-primary-bg, #FFFFFF);
151 --fct-checkout-checkbox-bg: var(--fcom-primary-bg, #FFFFFF);
152 --fct-checkout-address-wrapper-bg: var(--fcom-primary-bg, #FFFFFF);
153 --fct-checkout-shipping-methods-bg: var(--fcom-primary-bg, #FFFFFF);
154 --fct-checkout-address-modal-bg: var(--fcom-primary-bg, #FFFFFF);
155 --fct-checkout-address-active-border-color: var(--fcom-secondary-border, #2B2E33);
156 }
157
158 </style>
159 <?php
160
161 }, 999);
162
163 (new TemplateLoader())->loadScriptsAndStyles();
164
165 status_header(200);
166 require_once FLUENT_COMMUNITY_PLUGIN_DIR . 'Modules/Theming/templates/fluent-community-frame-full.php';
167 exit();
168 }
169 }
170