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

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