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 / actions.php

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

231 lines 9.7 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 (new \FluentCart\App\Hooks\Handlers\ExportHandler)->register();
30
31 (new FluentCart\App\Hooks\Handlers\CustomCheckout\CustomCheckout())->register();
32
33 // Tax Module Init
34 add_action('init', function () {
35 (new \FluentCart\App\Modules\Tax\TaxModule())->register();
36 }, 1);
37
38 // Turnstile Module Init
39 (new \FluentCart\App\Modules\Turnstile\TurnstileInit())->register(\FluentCart\App\App::getInstance());
40
41 // Register Pro Gateways Promo
42 (new \FluentCart\App\Hooks\Handlers\PromoGatewaysHandler())->register();
43
44 // Register Addon Gateways
45 (new \FluentCart\App\Hooks\Handlers\AddonGatewaysHandler())->register();
46
47 // Web Checkout
48 (new \FluentCart\App\Hooks\Cart\WebCheckoutHandler())->register();
49
50
51 \FluentCart\App\Hooks\Handlers\BlockEditors\ShopApp\ShopAppBlockEditor::register();
52 \FluentCart\App\Hooks\Handlers\BlockEditors\ProductCarousel\ProductCarouselBlockEditor::register();
53 \FluentCart\App\Hooks\Handlers\BlockEditors\MediaCarousel\MediaCarouselBlockEditor::register();
54
55 \FluentCart\App\Hooks\Handlers\ShortCodes\SearchBarShortCode::register();
56 \FluentCart\App\Hooks\Handlers\BlockEditors\SearchBarBlockEditor::register();
57 \FluentCart\App\Hooks\Handlers\BlockEditors\PricingTableBlockEditor::register();
58 \FluentCart\App\Hooks\Handlers\BlockEditors\CustomerProfileBlockEditor::register();
59 \FluentCart\App\Hooks\Handlers\ShortCodes\CustomerProfileHandler::register();
60 \FluentCart\App\Hooks\Handlers\BlockEditors\Checkout\CheckoutBlockEditor::register();
61 \FluentCart\App\Hooks\Handlers\ShortCodes\CartShortcode::register();
62 \FluentCart\App\Hooks\Handlers\ShortCodes\PricingTableShortCode::register();
63 \FluentCart\App\Hooks\Handlers\ShortCodes\Checkout\CheckoutPageHandler::register();
64 \FluentCart\App\Hooks\Handlers\BlockEditors\ProductCardBlockEditor::register();
65 \FluentCart\App\Hooks\Handlers\BlockEditors\ProductGalleryBlockEditor::register();
66 \FluentCart\App\Hooks\Handlers\BlockEditors\ProductInfoBlockEditor::register();
67 \FluentCart\App\Hooks\Handlers\BlockEditors\BuySectionBlockEditor::register();
68 \FluentCart\App\Hooks\Handlers\BlockEditors\ProductTitleBlockEditor::register();
69 \FluentCart\App\Hooks\Handlers\BlockEditors\ProductImageBlockEditor::register();
70 \FluentCart\App\Hooks\Handlers\BlockEditors\PriceRangeBlockEditor::register();
71 \FluentCart\App\Hooks\Handlers\BlockEditors\SaleBadgeBlockEditor::register();
72 \FluentCart\App\Hooks\Handlers\BlockEditors\ExcerptBlockEditor::register();
73 \FluentCart\App\Hooks\Handlers\BlockEditors\ProductDescriptionBlockEditor::register();
74 \FluentCart\App\Hooks\Handlers\ShortCodes\ProductCardShortCode::register();
75 \FluentCart\App\Hooks\Handlers\BlockEditors\Buttons\BuyNowButtonBlockEditor::register();
76 \FluentCart\App\Hooks\Handlers\BlockEditors\Buttons\AddToCartButtonBlockEditor::register();
77
78 \FluentCart\App\Hooks\Handlers\BlockEditors\MiniCartBlockEditor::register();
79 \FluentCart\App\Hooks\Handlers\BlockEditors\ProductCategoriesListBlockEditor::register();
80 \FluentCart\App\Hooks\Handlers\BlockEditors\RelatedProduct\RelatedProductBlockEditor::register();
81 \FluentCart\App\Hooks\Handlers\ShortCodes\Buttons\DirectCheckoutShortcode::register();
82 \FluentCart\App\Hooks\Handlers\ShortCodes\Buttons\AddToCartShortcode::register();
83 \FluentCart\App\Hooks\Handlers\ShortCodes\MiniCartShortcode::register();
84 \FluentCart\App\Hooks\Handlers\ShortCodes\ProductCategoriesListShortcode::register();
85 \FluentCart\App\Hooks\Handlers\ShortCodes\ProductTitleShortCode::register();
86 \FluentCart\App\Hooks\Handlers\ShortCodes\ProductImageShortCode::register();
87 \FluentCart\App\Hooks\Handlers\ShortCodes\SingleProductShortCode::register();
88
89
90 \FluentCart\App\Hooks\Handlers\BlockEditors\ProductSkuBlockEditor::register();
91 \FluentCart\App\Hooks\Handlers\BlockEditors\ProductPackageDescriptionBlockEditor::register();
92 \FluentCart\App\Hooks\Handlers\BlockEditors\StoreLogoBlockEditor::register();
93 \FluentCart\App\Hooks\Handlers\ShortCodes\StoreLogoShortCode::register();
94 \FluentCart\App\Hooks\Handlers\BlockEditors\CustomerDashboardButtonBlockEditor::register();
95 \FluentCart\App\Hooks\Handlers\ShortCodes\CustomerDashboardButtonShortcode::register();
96
97
98 (new \FluentCart\App\Modules\StockManagement\StockManagement())->register(fluentCart());
99
100 if (\FluentCart\Api\ModuleSettings::isActive('stock_management')) {
101 \FluentCart\App\Hooks\Handlers\BlockEditors\StockBlock::register();
102 \FluentCart\App\Hooks\Handlers\BlockEditors\SoldOutBadgeBlockEditor::register();
103 }
104
105 (new \FluentCart\App\Hooks\Cart\CartLoader)->register();
106 (new \FluentCart\App\Hooks\Handlers\GlobalPaymentHandler)->register();
107
108 \FluentCart\App\Http\Routes\WebRoutes::register();
109
110 (new \FluentCart\App\Modules\IntegrationActions\GlobalIntegrationActionHandler())->register();
111 (new \FluentCart\App\Hooks\Handlers\GlobalStorageHandler)->register();
112
113
114 //Register Page Handlers
115 (new \FluentCart\App\Hooks\Handlers\ShortCodes\ReceiptHandler)->register();
116
117 (new \FluentCart\App\Modules\Coupon\CouponHandler)->register();
118
119 \FluentCart\App\Services\Theme\AdminTheme::applyTheme();
120 \FluentCart\App\Services\Theme\FrontendTheme::applyTheme();
121
122 (new \FluentCart\App\CPT\Pages)->handlePageDelete();
123 (new \FluentCart\App\Services\FileSystem\DownloadService)->register();
124
125 (new \FluentCart\App\Hooks\Handlers\UserHandler())->register();
126
127 // Corrected hook name: fluent_cart/order_paid_async_private_handle
128 // Legacy (typo'd) listener kept for any pending Action Scheduler jobs
129 $orderPaidAsyncHandler = function ($data) {
130 $orderId = \FluentCart\Framework\Support\Arr::get($data, 'order_id');
131
132 if (!$orderId) {
133 return;
134 }
135
136 $order = \FluentCart\App\Models\Order::find($orderId);
137 if (!$order || $order->payment_status !== 'paid' || !$order->getMeta('action_scheduler_id')) {
138 return;
139 }
140
141 $order->deleteMeta('action_scheduler_id');
142
143 $transaction = \FluentCart\App\Models\OrderTransaction::query()
144 ->where('order_id', $order->id)
145 ->where('status', \FluentCart\App\Helpers\Status::TRANSACTION_SUCCEEDED)
146 ->orderBy('id', 'DESC')
147 ->first();
148
149 $eventData = [
150 'order' => $order,
151 'transaction' => $transaction,
152 'customer' => $order->customer
153 ];
154
155 if ($order->type === 'subscription' || $order->type === 'renewal') {
156 $subscription = \FluentCart\App\Models\Subscription::query()->where('parent_order_id', $order->id)->first();
157 if ($subscription) {
158 $eventData['subscription'] = $subscription;
159 }
160 }
161
162 do_action('fluent_cart/order_paid_done', $eventData);
163
164 };
165 add_action('fluent_cart/order_paid_async_private_handle', $orderPaidAsyncHandler, 1, 1);
166 add_action('fluent_cart/order_paid_ansyc_private_handle', $orderPaidAsyncHandler, 1, 1);
167
168
169 //
170 //$app->addAction('fluent_cart/orders_filter_customer', function ($query, $filters) {
171 // return (new \FluentCart\App\Models\Order)->buildCustomerFilterQuery($query, $filters);
172 //}, 10, 2);
173
174 // require the CLI
175 if (defined('WP_CLI') && WP_CLI) {
176 \WP_CLI::add_command('fluent_cart', '\FluentCart\App\Hooks\CLI\Commands');
177
178 }
179
180 \FluentCart\App\Modules\Subscriptions\SubscriptionModule::register();
181 \FluentCart\App\Modules\Shipping\ShippingModule::register();
182 \FluentCart\App\Modules\StoreManagedRenewal\RenewalModule::register();
183 (new \FluentCart\App\Hooks\Handlers\AttributesHandler())->register();
184 (new \FluentCart\App\Hooks\Handlers\AdvancedVariationHandler())->register();
185
186 // MCP (Model Context Protocol) — operator AI tools. Ships OFF; enabled in
187 // Settings → Features & addon → MCP. See MCPInit::boot() for the bootstrap.
188 \FluentCart\App\Modules\MCP\MCPInit::boot();
189
190 $app->ready(function () use ($app) {
191 \FluentCart\App\Models\Connection\ConnectionManager::connect($this->app);
192 });
193
194
195 // Add to your theme's functions.php or a custom plugin
196 // For Elementor preview URL
197
198
199 (new \FluentCart\App\Services\Integration)->register();
200
201 $app->addAction('fluent_cart/integration/schedule_feed', function ($queueId) use ($app) {
202 (new \FluentCart\App\Modules\Integrations\GlobalNotificationHandler())->processIntegrationAction($queueId);
203 });
204
205 // Schedulers
206 (new \FluentCart\App\Hooks\Scheduler\AutoSchedules\FiveMinuteScheduler())->register();
207 (new \FluentCart\App\Hooks\Scheduler\AutoSchedules\HourlyScheduler())->register();
208 (new \FluentCart\App\Hooks\Scheduler\AutoSchedules\DailyScheduler())->register();
209
210
211 /**
212 * Theme Hooks
213 */
214
215 add_action('init', [\FluentCart\App\Modules\Templating\TemplateLoader::class, 'init']);
216 add_action('after_setup_theme', function () {
217 \FluentCart\App\Modules\Templating\TemplateLoader::registerBlockParts();
218 (new \FluentCart\App\Modules\Templating\Bricks\BricksLoader())->register();
219 });
220
221
222 /**
223 * Development Hooks
224 */
225
226 add_action('init', function () {
227 if (!is_admin()) {
228 WebRoutes::renderModalCheckout();
229 }
230 });
231