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

222 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 \FluentCart\App\Hooks\Handlers\ShortCodes\SingleProductShortCode::register();
86
87
88 \FluentCart\App\Hooks\Handlers\BlockEditors\ProductSkuBlockEditor::register();
89 \FluentCart\App\Hooks\Handlers\BlockEditors\ProductPackageDescriptionBlockEditor::register();
90 \FluentCart\App\Hooks\Handlers\BlockEditors\StoreLogoBlockEditor::register();
91 \FluentCart\App\Hooks\Handlers\ShortCodes\StoreLogoShortCode::register();
92 \FluentCart\App\Hooks\Handlers\BlockEditors\CustomerDashboardButtonBlockEditor::register();
93 \FluentCart\App\Hooks\Handlers\ShortCodes\CustomerDashboardButtonShortcode::register();
94
95
96 (new \FluentCart\App\Modules\StockManagement\StockManagement())->register(fluentCart());
97
98 if (\FluentCart\Api\ModuleSettings::isActive('stock_management')) {
99 \FluentCart\App\Hooks\Handlers\BlockEditors\StockBlock::register();
100 \FluentCart\App\Hooks\Handlers\BlockEditors\SoldOutBadgeBlockEditor::register();
101 }
102
103 (new \FluentCart\App\Hooks\Cart\CartLoader)->register();
104 (new \FluentCart\App\Hooks\Handlers\GlobalPaymentHandler)->register();
105
106 \FluentCart\App\Http\Routes\WebRoutes::register();
107
108 (new \FluentCart\App\Modules\IntegrationActions\GlobalIntegrationActionHandler())->register();
109 (new \FluentCart\App\Hooks\Handlers\GlobalStorageHandler)->register();
110
111
112 //Register Page Handlers
113 (new \FluentCart\App\Hooks\Handlers\ShortCodes\ReceiptHandler)->register();
114
115 (new \FluentCart\App\Modules\Coupon\CouponHandler)->register();
116
117 \FluentCart\App\Services\Theme\AdminTheme::applyTheme();
118 \FluentCart\App\Services\Theme\FrontendTheme::applyTheme();
119
120 (new \FluentCart\App\CPT\Pages)->handlePageDelete();
121 (new \FluentCart\App\Services\FileSystem\DownloadService)->register();
122
123 (new \FluentCart\App\Hooks\Handlers\UserHandler())->register();
124
125 // Corrected hook name: fluent_cart/order_paid_async_private_handle
126 // Legacy (typo'd) listener kept for any pending Action Scheduler jobs
127 $orderPaidAsyncHandler = function ($data) {
128 $orderId = \FluentCart\Framework\Support\Arr::get($data, 'order_id');
129
130 if (!$orderId) {
131 return;
132 }
133
134 $order = \FluentCart\App\Models\Order::find($orderId);
135 if (!$order || $order->payment_status !== 'paid' || !$order->getMeta('action_scheduler_id')) {
136 return;
137 }
138
139 $order->deleteMeta('action_scheduler_id');
140
141 $transaction = \FluentCart\App\Models\OrderTransaction::query()
142 ->where('order_id', $order->id)
143 ->where('status', \FluentCart\App\Helpers\Status::TRANSACTION_SUCCEEDED)
144 ->orderBy('id', 'DESC')
145 ->first();
146
147 $eventData = [
148 'order' => $order,
149 'transaction' => $transaction,
150 'customer' => $order->customer
151 ];
152
153 if ($order->type === 'subscription' || $order->type === 'renewal') {
154 $subscription = \FluentCart\App\Models\Subscription::query()->where('parent_order_id', $order->id)->first();
155 if ($subscription) {
156 $eventData['subscription'] = $subscription;
157 }
158 }
159
160 do_action('fluent_cart/order_paid_done', $eventData);
161
162 };
163 add_action('fluent_cart/order_paid_async_private_handle', $orderPaidAsyncHandler, 1, 1);
164 add_action('fluent_cart/order_paid_ansyc_private_handle', $orderPaidAsyncHandler, 1, 1);
165
166
167 //
168 //$app->addAction('fluent_cart/orders_filter_customer', function ($query, $filters) {
169 // return (new \FluentCart\App\Models\Order)->buildCustomerFilterQuery($query, $filters);
170 //}, 10, 2);
171
172 // require the CLI
173 if (defined('WP_CLI') && WP_CLI) {
174 \WP_CLI::add_command('fluent_cart', '\FluentCart\App\Hooks\CLI\Commands');
175
176 }
177
178 \FluentCart\App\Modules\Subscriptions\SubscriptionModule::register();
179 \FluentCart\App\Modules\Shipping\ShippingModule::register();
180
181 $app->ready(function () use ($app) {
182 \FluentCart\App\Models\Connection\ConnectionManager::connect($this->app);
183 });
184
185
186 // Add to your theme's functions.php or a custom plugin
187 // For Elementor preview URL
188
189
190 (new \FluentCart\App\Services\Integration)->register();
191
192 $app->addAction('fluent_cart/integration/schedule_feed', function ($queueId) use ($app) {
193 (new \FluentCart\App\Modules\Integrations\GlobalNotificationHandler())->processIntegrationAction($queueId);
194 });
195
196 // Schedulers
197 (new \FluentCart\App\Hooks\Scheduler\AutoSchedules\FiveMinuteScheduler())->register();
198 (new \FluentCart\App\Hooks\Scheduler\AutoSchedules\HourlyScheduler())->register();
199 (new \FluentCart\App\Hooks\Scheduler\AutoSchedules\DailyScheduler())->register();
200
201
202 /**
203 * Theme Hooks
204 */
205
206 add_action('init', [\FluentCart\App\Modules\Templating\TemplateLoader::class, 'init']);
207 add_action('after_setup_theme', function () {
208 \FluentCart\App\Modules\Templating\TemplateLoader::registerBlockParts();
209 (new \FluentCart\App\Modules\Templating\Bricks\BricksLoader())->register();
210 });
211
212
213 /**
214 * Development Hooks
215 */
216
217 add_action('init', function () {
218 if (!is_admin()) {
219 WebRoutes::renderModalCheckout();
220 }
221 });
222