| @@ -25,8 +25,9 @@ | ||
| 25 | 25 | (new \FluentCart\App\Hooks\Handlers\RetentionSnapshotHandler)->register(); |
| 26 | 26 | (new \FluentCart\App\Hooks\Handlers\ReminderHandler)->register(); |
| 27 | 27 | |
| 28 | 28 | (new \FluentCart\App\Hooks\Handlers\ShortCodes\ShopAppHandler)->register(); |
| 29 | +(new \FluentCart\App\Hooks\Handlers\ShortCodes\OrderReviewShortCode)->register(); | |
| 29 | 30 | |
| 30 | 31 | (new FluentCart\App\Hooks\Handlers\CustomCheckout\CustomCheckout())->register(); |
| 31 | 32 | |
| 32 | 33 | // Tax Module Init |
| @@ -36,8 +37,13 @@ | ||
| 36 | 37 | |
| 37 | 38 | // Turnstile Module Init |
| 38 | 39 | (new \FluentCart\App\Modules\Turnstile\TurnstileInit())->register(\FluentCart\App\App::getInstance()); |
| 39 | 40 | |
| 41 | +// Reviews Module Init | |
| 42 | +(new \FluentCart\App\Modules\Reviews\ReviewModule())->register(); | |
| 43 | + | |
| 44 | +(new \FluentCart\App\Modules\FluentPlayer\FluentPlayerAdminAssets())->register(); | |
| 45 | + | |
| 40 | 46 | // Register Pro Gateways Promo |
| 41 | 47 | (new \FluentCart\App\Hooks\Handlers\PromoGatewaysHandler())->register(); |
| 42 | 48 | |
| 43 | 49 | // Register Addon Gateways |
| @@ -74,8 +80,9 @@ | ||
| 74 | 80 | \FluentCart\App\Hooks\Handlers\BlockEditors\Buttons\BuyNowButtonBlockEditor::register(); |
| 75 | 81 | \FluentCart\App\Hooks\Handlers\BlockEditors\Buttons\AddToCartButtonBlockEditor::register(); |
| 76 | 82 | |
| 77 | 83 | \FluentCart\App\Hooks\Handlers\BlockEditors\MiniCartBlockEditor::register(); |
| 84 | +\FluentCart\App\Hooks\Handlers\BlockEditors\Cart\CartBlockEditor::register(); | |
| 78 | 85 | \FluentCart\App\Hooks\Handlers\BlockEditors\ProductCategoriesListBlockEditor::register(); |
| 79 | 86 | \FluentCart\App\Hooks\Handlers\BlockEditors\RelatedProduct\RelatedProductBlockEditor::register(); |
| 80 | 87 | \FluentCart\App\Hooks\Handlers\ShortCodes\Buttons\DirectCheckoutShortcode::register(); |
| 81 | 88 | \FluentCart\App\Hooks\Handlers\ShortCodes\Buttons\AddToCartShortcode::register(); |
| @@ -100,8 +107,19 @@ | ||
| 100 | 107 | \FluentCart\App\Hooks\Handlers\BlockEditors\StockBlock::register(); |
| 101 | 108 | \FluentCart\App\Hooks\Handlers\BlockEditors\SoldOutBadgeBlockEditor::register(); |
| 102 | 109 | } |
| 103 | 110 | |
| 111 | +if (\FluentCart\Api\ModuleSettings::isActive('reviews') && class_exists(\FluentCart\App\Hooks\Handlers\BlockEditors\ProductReviewsBlockEditor::class)) { | |
| 112 | + \FluentCart\App\Hooks\Handlers\BlockEditors\ProductReviewsBlockEditor::register(); | |
| 113 | + \FluentCart\App\Hooks\Handlers\BlockEditors\ProductRatingBlockEditor::register(); | |
| 114 | + \FluentCart\App\Hooks\Handlers\BlockEditors\WriteAReviewButtonBlockEditor::register(); | |
| 115 | + \FluentCart\App\Hooks\Handlers\BlockEditors\ProductReviewFormBlockEditor::register(); | |
| 116 | + \FluentCart\App\Hooks\Handlers\BlockEditors\ProductReviewSummaryBlockEditor::register(); | |
| 117 | + \FluentCart\App\Hooks\Handlers\BlockEditors\ProductReviewList\ProductReviewListBlockEditor::register(); | |
| 118 | + \FluentCart\App\Hooks\Handlers\BlockEditors\ProductReviewSummaryGroupBlockEditor::register(); | |
| 119 | + \FluentCart\App\Hooks\Handlers\ShortCodes\ProductReviewsShortCode::register(); | |
| 120 | +} | |
| 121 | + | |
| 104 | 122 | (new \FluentCart\App\Hooks\Cart\CartLoader)->register(); |
| 105 | 123 | (new \FluentCart\App\Hooks\Handlers\GlobalPaymentHandler)->register(); |
| 106 | 124 | |
| 107 | 125 | \FluentCart\App\Http\Routes\WebRoutes::register(); |
| @@ -169,8 +187,63 @@ | ||
| 169 | 187 | do_action('fluent_cart/order_paid_done', $eventData); |
| 170 | 188 | |
| 171 | 189 | }; |
| 172 | 190 | add_action('fluent_cart/order_paid_async_private_handle', $orderPaidAsyncHandler, 1, 1); |
| 191 | + | |
| 192 | +// The settled half of a review approval — see ReviewApproved::afterDispatch(). | |
| 193 | +// Runs off the request, so it trusts nothing it was told: the review is | |
| 194 | +// re-read, and only one that is still an approved top-level review is | |
| 195 | +// announced. Deleted or held back since, nothing fires. | |
| 196 | +$reviewApprovedAsyncHandler = function ($data) { | |
| 197 | + $reviewId = (int) \FluentCart\Framework\Support\Arr::get($data, 'review_id'); | |
| 198 | + | |
| 199 | + if (!$reviewId) { | |
| 200 | + return; | |
| 201 | + } | |
| 202 | + | |
| 203 | + $review = \FluentCart\App\Models\ProductReview::query()->with('product')->find($reviewId); | |
| 204 | + | |
| 205 | + if (!$review || $review->parent_id || $review->status !== \FluentCart\App\Helpers\Status::REVIEW_APPROVED) { | |
| 206 | + return; | |
| 207 | + } | |
| 208 | + | |
| 209 | + do_action('fluent_cart/review_approved_done', [ | |
| 210 | + 'review' => $review, | |
| 211 | + 'product' => $review->product, | |
| 212 | + ]); | |
| 213 | +}; | |
| 214 | +add_action('fluent_cart/review_approved_async_private_handle', $reviewApprovedAsyncHandler, 1, 1); | |
| 215 | + | |
| 216 | +// The settled half of a store reply — see ReviewReplied::afterDispatch(). | |
| 217 | +// Announced only while both halves are published: the reply itself, and the | |
| 218 | +// review it answers. A reply to a review nobody can see is not a | |
| 219 | +// conversation the reviewer can be pointed at. | |
| 220 | +$reviewRepliedAsyncHandler = function ($data) { | |
| 221 | + $replyId = (int) \FluentCart\Framework\Support\Arr::get($data, 'reply_id'); | |
| 222 | + | |
| 223 | + if (!$replyId) { | |
| 224 | + return; | |
| 225 | + } | |
| 226 | + | |
| 227 | + $reply = \FluentCart\App\Models\ProductReview::query()->with('product')->find($replyId); | |
| 228 | + | |
| 229 | + if (!$reply || !$reply->parent_id || !$reply->is_admin_reply || $reply->status !== \FluentCart\App\Helpers\Status::REVIEW_APPROVED) { | |
| 230 | + return; | |
| 231 | + } | |
| 232 | + | |
| 233 | + $review = \FluentCart\App\Models\ProductReview::query()->find((int) $reply->parent_id); | |
| 234 | + | |
| 235 | + if (!$review || $review->parent_id || $review->status !== \FluentCart\App\Helpers\Status::REVIEW_APPROVED) { | |
| 236 | + return; | |
| 237 | + } | |
| 238 | + | |
| 239 | + do_action('fluent_cart/review_replied_done', [ | |
| 240 | + 'reply' => $reply, | |
| 241 | + 'review' => $review, | |
| 242 | + 'product' => $reply->product, | |
| 243 | + ]); | |
| 244 | +}; | |
| 245 | +add_action('fluent_cart/review_replied_async_private_handle', $reviewRepliedAsyncHandler, 1, 1); | |
| 173 | 246 | |
| 174 | 247 | |
| 175 | 248 | // |
| 176 | 249 | //$app->addAction('fluent_cart/orders_filter_customer', function ($query, $filters) { |