PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.3
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.3
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 / actions.php

actions.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.6.3, at app/Hooks/actions.php

237 lines 10.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if (!defined('ABSPATH')) exit; ?>
2 <?php
3
4 /**
5 * All registered action's handlers should be in app\Hooks\Handlers,
6 * addAction is similar to add_action and addCustomAction is just a
7 * wrapper over add_action which will add a prefix to the hook name
8 * using the plugin slug to make it unique in all WordPress plugins,
9 * ex: $app->addCustomAction('foo', ['FooHandler', 'handleFoo']) is
10 * equivalent to add_action('slug-foo', ['FooHandler', 'handleFoo']).
11 */
12
13 /**
14 * @var $app FluentCart\Framework\Foundation\Application
15 */
16
17 use FluentCart\App\Http\Routes\WebRoutes;
18
19 (new \FluentCart\App\CPT\FluentProducts)->register();
20 (new \FluentCart\App\Services\Email\EmailNotificationMailer)->register();
21 (new \FluentCart\App\Hooks\Handlers\CPTHandler)->register();
22 (new \FluentCart\App\Hooks\Handlers\MenuHandler)->register();
23 (new \FluentCart\App\Hooks\Handlers\AdminMenuBarHandler)->register();
24 (new \FluentCart\App\Hooks\Handlers\FluentCartHandler)->register();
25 (new \FluentCart\App\Hooks\Handlers\RetentionSnapshotHandler)->register();
26 (new \FluentCart\App\Hooks\Handlers\ReminderHandler)->register();
27
28 (new \FluentCart\App\Hooks\Handlers\ShortCodes\ShopAppHandler)->register();
29
30 (new FluentCart\App\Hooks\Handlers\CustomCheckout\CustomCheckout())->register();
31
32 // Tax Module Init
33 add_action('init', function () {
34 (new \FluentCart\App\Modules\Tax\TaxModule())->register();
35 }, 1);
36
37 // Turnstile Module Init
38 (new \FluentCart\App\Modules\Turnstile\TurnstileInit())->register(\FluentCart\App\App::getInstance());
39
40 // Register Pro Gateways Promo
41 (new \FluentCart\App\Hooks\Handlers\PromoGatewaysHandler())->register();
42
43 // Register Addon Gateways
44 (new \FluentCart\App\Hooks\Handlers\AddonGatewaysHandler())->register();
45
46 // Web Checkout
47 (new \FluentCart\App\Hooks\Cart\WebCheckoutHandler())->register();
48
49
50 \FluentCart\App\Hooks\Handlers\BlockEditors\ShopApp\ShopAppBlockEditor::register();
51 \FluentCart\App\Hooks\Handlers\BlockEditors\ProductCarousel\ProductCarouselBlockEditor::register();
52 \FluentCart\App\Hooks\Handlers\BlockEditors\MediaCarousel\MediaCarouselBlockEditor::register();
53
54 \FluentCart\App\Hooks\Handlers\ShortCodes\SearchBarShortCode::register();
55 \FluentCart\App\Hooks\Handlers\BlockEditors\SearchBarBlockEditor::register();
56 \FluentCart\App\Hooks\Handlers\BlockEditors\PricingTableBlockEditor::register();
57 \FluentCart\App\Hooks\Handlers\BlockEditors\CustomerProfileBlockEditor::register();
58 \FluentCart\App\Hooks\Handlers\ShortCodes\CustomerProfileHandler::register();
59 \FluentCart\App\Hooks\Handlers\BlockEditors\Checkout\CheckoutBlockEditor::register();
60 \FluentCart\App\Hooks\Handlers\ShortCodes\CartShortcode::register();
61 \FluentCart\App\Hooks\Handlers\ShortCodes\PricingTableShortCode::register();
62 \FluentCart\App\Hooks\Handlers\ShortCodes\Checkout\CheckoutPageHandler::register();
63 \FluentCart\App\Hooks\Handlers\BlockEditors\ProductCardBlockEditor::register();
64 \FluentCart\App\Hooks\Handlers\BlockEditors\ProductGalleryBlockEditor::register();
65 \FluentCart\App\Hooks\Handlers\BlockEditors\ProductInfoBlockEditor::register();
66 \FluentCart\App\Hooks\Handlers\BlockEditors\BuySectionBlockEditor::register();
67 \FluentCart\App\Hooks\Handlers\BlockEditors\ProductTitleBlockEditor::register();
68 \FluentCart\App\Hooks\Handlers\BlockEditors\ProductImageBlockEditor::register();
69 \FluentCart\App\Hooks\Handlers\BlockEditors\PriceRangeBlockEditor::register();
70 \FluentCart\App\Hooks\Handlers\BlockEditors\SaleBadgeBlockEditor::register();
71 \FluentCart\App\Hooks\Handlers\BlockEditors\ExcerptBlockEditor::register();
72 \FluentCart\App\Hooks\Handlers\BlockEditors\ProductDescriptionBlockEditor::register();
73 \FluentCart\App\Hooks\Handlers\ShortCodes\ProductCardShortCode::register();
74 \FluentCart\App\Hooks\Handlers\BlockEditors\Buttons\BuyNowButtonBlockEditor::register();
75 \FluentCart\App\Hooks\Handlers\BlockEditors\Buttons\AddToCartButtonBlockEditor::register();
76
77 \FluentCart\App\Hooks\Handlers\BlockEditors\MiniCartBlockEditor::register();
78 \FluentCart\App\Hooks\Handlers\BlockEditors\ProductCategoriesListBlockEditor::register();
79 \FluentCart\App\Hooks\Handlers\BlockEditors\RelatedProduct\RelatedProductBlockEditor::register();
80 \FluentCart\App\Hooks\Handlers\ShortCodes\Buttons\DirectCheckoutShortcode::register();
81 \FluentCart\App\Hooks\Handlers\ShortCodes\Buttons\AddToCartShortcode::register();
82 \FluentCart\App\Hooks\Handlers\ShortCodes\MiniCartShortcode::register();
83 \FluentCart\App\Hooks\Handlers\ShortCodes\ProductCategoriesListShortcode::register();
84 \FluentCart\App\Hooks\Handlers\ShortCodes\ProductTitleShortCode::register();
85 \FluentCart\App\Hooks\Handlers\ShortCodes\ProductImageShortCode::register();
86 \FluentCart\App\Hooks\Handlers\ShortCodes\SingleProductShortCode::register();
87
88
89 \FluentCart\App\Hooks\Handlers\BlockEditors\ProductSkuBlockEditor::register();
90 \FluentCart\App\Hooks\Handlers\BlockEditors\ProductPackageDescriptionBlockEditor::register();
91 \FluentCart\App\Hooks\Handlers\BlockEditors\StoreLogoBlockEditor::register();
92 \FluentCart\App\Hooks\Handlers\ShortCodes\StoreLogoShortCode::register();
93 \FluentCart\App\Hooks\Handlers\BlockEditors\CustomerDashboardButtonBlockEditor::register();
94 \FluentCart\App\Hooks\Handlers\ShortCodes\CustomerDashboardButtonShortcode::register();
95
96
97 (new \FluentCart\App\Modules\StockManagement\StockManagement())->register(fluentCart());
98
99 if (\FluentCart\Api\ModuleSettings::isActive('stock_management')) {
100 \FluentCart\App\Hooks\Handlers\BlockEditors\StockBlock::register();
101 \FluentCart\App\Hooks\Handlers\BlockEditors\SoldOutBadgeBlockEditor::register();
102 }
103
104 (new \FluentCart\App\Hooks\Cart\CartLoader)->register();
105 (new \FluentCart\App\Hooks\Handlers\GlobalPaymentHandler)->register();
106
107 \FluentCart\App\Http\Routes\WebRoutes::register();
108
109 (new \FluentCart\App\Modules\IntegrationActions\GlobalIntegrationActionHandler())->register();
110 (new \FluentCart\App\Hooks\Handlers\GlobalStorageHandler)->register();
111
112
113 //Register Page Handlers
114 (new \FluentCart\App\Hooks\Handlers\ShortCodes\ReceiptHandler)->register();
115
116 (new \FluentCart\App\Modules\Coupon\CouponHandler)->register();
117
118 \FluentCart\App\Services\Theme\AdminTheme::applyTheme();
119 \FluentCart\App\Services\Theme\FrontendTheme::applyTheme();
120
121 (new \FluentCart\App\CPT\Pages)->handlePageDelete();
122 (new \FluentCart\App\Services\FileSystem\DownloadService)->register();
123
124 (new \FluentCart\App\Hooks\Handlers\UserHandler())->register();
125
126 // Corrected hook name: fluent_cart/order_paid_async_private_handle
127 // Legacy (typo'd) listener kept for any pending Action Scheduler jobs
128 $orderPaidAsyncHandler = function ($data) {
129 $orderId = \FluentCart\Framework\Support\Arr::get($data, 'order_id');
130
131 if (!$orderId) {
132 return;
133 }
134
135 $order = \FluentCart\App\Models\Order::find($orderId);
136 if (!$order || $order->payment_status !== 'paid') {
137 return;
138 }
139
140 // Claim the run by deleting the meta and branching on the affected-row count.
141 // The Action Scheduler worker and the receipt-page AJAX nudge
142 // (IntegrationEventListener::runOrderActionsAjax) can arrive together, so a
143 // read-then-delete would let both pass the guard and fire order_paid_done
144 // twice. A single DELETE is atomic: MySQL hands the row to exactly one
145 // caller, and the loser sees 0 rows and returns.
146 if (!$order->deleteMeta('action_scheduler_id')) {
147 return;
148 }
149
150 $transaction = \FluentCart\App\Models\OrderTransaction::query()
151 ->where('order_id', $order->id)
152 ->where('status', \FluentCart\App\Helpers\Status::TRANSACTION_SUCCEEDED)
153 ->orderBy('id', 'DESC')
154 ->first();
155
156 $eventData = [
157 'order' => $order,
158 'transaction' => $transaction,
159 'customer' => $order->customer
160 ];
161
162 if ($order->type === 'subscription' || $order->type === 'renewal') {
163 $subscription = \FluentCart\App\Models\Subscription::query()->where('parent_order_id', $order->id)->first();
164 if ($subscription) {
165 $eventData['subscription'] = $subscription;
166 }
167 }
168
169 do_action('fluent_cart/order_paid_done', $eventData);
170
171 };
172 add_action('fluent_cart/order_paid_async_private_handle', $orderPaidAsyncHandler, 1, 1);
173
174
175 //
176 //$app->addAction('fluent_cart/orders_filter_customer', function ($query, $filters) {
177 // return (new \FluentCart\App\Models\Order)->buildCustomerFilterQuery($query, $filters);
178 //}, 10, 2);
179
180 // require the CLI
181 if (defined('WP_CLI') && WP_CLI) {
182 \WP_CLI::add_command('fluent_cart', '\FluentCart\App\Hooks\CLI\Commands');
183
184 }
185
186 \FluentCart\App\Modules\Subscriptions\SubscriptionModule::register();
187 \FluentCart\App\Modules\Shipping\ShippingModule::register();
188 \FluentCart\App\Modules\StoreManagedRenewal\RenewalModule::register();
189 (new \FluentCart\App\Hooks\Handlers\AttributesHandler())->register();
190 (new \FluentCart\App\Hooks\Handlers\AdvancedVariationHandler())->register();
191
192 // MCP (Model Context Protocol) — operator AI tools. Ships OFF; enabled in
193 // Settings → Features & addon → MCP. See MCPInit::boot() for the bootstrap.
194 \FluentCart\App\Modules\MCP\MCPInit::boot();
195
196 $app->ready(function () use ($app) {
197 \FluentCart\App\Models\Connection\ConnectionManager::connect($this->app);
198 });
199
200
201 // Add to your theme's functions.php or a custom plugin
202 // For Elementor preview URL
203
204
205 (new \FluentCart\App\Services\Integration)->register();
206
207 $app->addAction('fluent_cart/integration/schedule_feed', function ($queueId) use ($app) {
208 (new \FluentCart\App\Modules\Integrations\GlobalNotificationHandler())->processIntegrationAction($queueId);
209 });
210
211 // Schedulers
212 (new \FluentCart\App\Hooks\Scheduler\AutoSchedules\FiveMinuteScheduler())->register();
213 (new \FluentCart\App\Hooks\Scheduler\AutoSchedules\HourlyScheduler())->register();
214 (new \FluentCart\App\Hooks\Scheduler\AutoSchedules\DailyScheduler())->register();
215
216
217 /**
218 * Theme Hooks
219 */
220
221 add_action('init', [\FluentCart\App\Modules\Templating\TemplateLoader::class, 'init']);
222 add_action('after_setup_theme', function () {
223 \FluentCart\App\Modules\Templating\TemplateLoader::registerBlockParts();
224 (new \FluentCart\App\Modules\Templating\Bricks\BricksLoader())->register();
225 });
226
227
228 /**
229 * Development Hooks
230 */
231
232 add_action('init', function () {
233 if (!is_admin()) {
234 WebRoutes::renderModalCheckout();
235 }
236 });
237