PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.3.25
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.3.25
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.3.25, at app/Hooks/actions.php

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