| @@ -1,8 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace FluentCart\App\CPT; |
| 4 | 4 | |
| 5 | +use FluentCart\Api\ModuleSettings; | |
| 5 | 6 | use FluentCart\Api\StoreSettings; |
| 6 | 7 | use FluentCart\App\Models\DynamicModel; |
| 7 | 8 | use FluentCart\Framework\Support\Arr; |
| 8 | 9 | use FluentCart\Framework\Support\Str; |
| @@ -13,8 +14,15 @@ | ||
| 13 | 14 | protected static array $cachedPages = []; |
| 14 | 15 | |
| 15 | 16 | public function pages(): array |
| 16 | 17 | { |
| 18 | + // Lets addons register their own generatable pages ('key' => title + content), | |
| 19 | + // so the Pages Setup "+" create button and onboarding can build them. | |
| 20 | + return apply_filters('fluent_cart/generatable_pages', $this->corePages()); | |
| 21 | + } | |
| 22 | + | |
| 23 | + public function corePages(): array | |
| 24 | + { | |
| 17 | 25 | $pages = [ |
| 18 | 26 | 'checkout' => [ |
| 19 | 27 | 'title' => 'Checkout', |
| 20 | 28 | 'content' => '[fluent_cart_checkout]' |
| @@ -26,8 +34,12 @@ | ||
| 26 | 34 | 'receipt' => [ |
| 27 | 35 | 'title' => 'Receipt', |
| 28 | 36 | 'content' => '[fluent_cart_receipt]' |
| 29 | 37 | ], |
| 38 | + 'order_review' => [ | |
| 39 | + 'title' => 'Review Your Order', | |
| 40 | + 'content' => '[fluent_cart_order_review]' | |
| 41 | + ], | |
| 30 | 42 | 'shop' => [ |
| 31 | 43 | 'title' => 'Shop', |
| 32 | 44 | 'content' => static::getShopPageContent() |
| 33 | 45 | ], |
| @@ -36,11 +48,18 @@ | ||
| 36 | 48 | 'content' => '<!-- wp:fluent-cart/customer-profile /-->' |
| 37 | 49 | ] |
| 38 | 50 | ]; |
| 39 | 51 | |
| 40 | - // Lets addons register their own generatable pages ('key' => title + content), | |
| 41 | - // so the Pages Setup "+" create button and onboarding can build them. | |
| 42 | - return apply_filters('fluent_cart/generatable_pages', $pages); | |
| 52 | + // The order review page serves the reviews module. While the module | |
| 53 | + // is off it is not a page the store is missing: the dashboard must | |
| 54 | + // not ask for it, onboarding must not create it, and Pages Setup | |
| 55 | + // does not offer it (StoreSettings::fields()). Read per call, so | |
| 56 | + // switching the module on makes it wanted again at once. | |
| 57 | + if (!ModuleSettings::isActive('reviews')) { | |
| 58 | + unset($pages['order_review']); | |
| 59 | + } | |
| 60 | + | |
| 61 | + return $pages; | |
| 43 | 62 | } |
| 44 | 63 | |
| 45 | 64 | |
| 46 | 65 | public function createPages(array $exclude = []): array |