PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.4
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.4
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 1.2.0 All 47 releases
fluent-cart / app / Hooks / actions.php

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

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