| @@ -20,8 +20,9 @@ | ||
| 20 | 20 | 'title' => __('Setup Pages', 'fluent-cart'), |
| 21 | 21 | 'text' => __("Customers to find what they're looking for by organising.", 'fluent-cart'), |
| 22 | 22 | 'icon' => 'Cart', |
| 23 | 23 | 'completed' => false, |
| 24 | + 'hash_id' => '', | |
| 24 | 25 | 'url' => $baseUrl . "settings/store-settings/pages_setup" |
| 25 | 26 | ], |
| 26 | 27 | 'store_info' => [ |
| 27 | 28 | 'title' => __('Add Details to Store', 'fluent-cart'), |
| @@ -27,9 +28,10 @@ | ||
| 27 | 28 | 'title' => __('Add Details to Store', 'fluent-cart'), |
| 28 | 29 | 'text' => __('Store details such as addresses, company info etc.', 'fluent-cart'), |
| 29 | 30 | 'icon' => 'StoreIcon', |
| 30 | 31 | 'completed' => false, |
| 31 | - 'url' => $baseUrl . "settings/store-settings/" | |
| 32 | + 'hash_id' => '', | |
| 33 | + 'url' => $baseUrl . "settings/store-settings" | |
| 32 | 34 | ], |
| 33 | 35 | 'product_info' => [ |
| 34 | 36 | 'title' => __('Add Your First Product', 'fluent-cart'), |
| 35 | 37 | 'text' => __('Share your brand story and build trust with customers.', 'fluent-cart'), |
| @@ -34,8 +36,9 @@ | ||
| 34 | 36 | 'title' => __('Add Your First Product', 'fluent-cart'), |
| 35 | 37 | 'text' => __('Share your brand story and build trust with customers.', 'fluent-cart'), |
| 36 | 38 | 'icon' => 'ShoppingCartIcon', |
| 37 | 39 | 'completed' => false, |
| 40 | + 'hash_id' => '', | |
| 38 | 41 | 'url' => $baseUrl . "products" |
| 39 | 42 | ], |
| 40 | 43 | |
| 41 | 44 | |
| @@ -43,8 +46,9 @@ | ||
| 43 | 46 | 'title' => __('Setup Payment Methods', 'fluent-cart'), |
| 44 | 47 | 'text' => __("Choose from fast & secure online and offline payment.", 'fluent-cart'), |
| 45 | 48 | 'icon' => 'PaymentIcon', |
| 46 | 49 | 'completed' => true, |
| 50 | + 'hash_id' => '', | |
| 47 | 51 | 'url' => $baseUrl . "settings/payments" |
| 48 | 52 | ], |
| 49 | 53 | ]; |
| 50 | 54 | |
| @@ -59,11 +63,25 @@ | ||
| 59 | 63 | $completed++; |
| 60 | 64 | $steps['product_info']['completed'] = true; |
| 61 | 65 | } |
| 62 | 66 | |
| 63 | - if ($this->isAllPageSetUpDone($settings)) { | |
| 67 | + $missingPage = $this->getMissingPageSetup($settings); | |
| 68 | + | |
| 69 | + if (!$missingPage) { | |
| 64 | 70 | $completed++; |
| 65 | 71 | $steps['page_setup']['completed'] = true; |
| 72 | + } else { | |
| 73 | + // Let whichever plugin registered the missing page (via | |
| 74 | + // fluent_cart/generatable_pages) decide where it should be | |
| 75 | + // resolved. Core stays agnostic of third-party settings screens. | |
| 76 | + $steps['page_setup']['url'] = apply_filters( | |
| 77 | + 'fluent_cart/dashboard/page_setup_redirect_url', | |
| 78 | + $steps['page_setup']['url'], | |
| 79 | + [ | |
| 80 | + 'missing_page' => $missingPage, | |
| 81 | + 'base_url' => $baseUrl, | |
| 82 | + ] | |
| 83 | + ); | |
| 66 | 84 | } |
| 67 | 85 | |
| 68 | 86 | if (!$this->isAnyPaymentModuleEnabled()) { |
| 69 | 87 | $steps['setup_payments']['completed'] = false; |
| @@ -76,8 +94,9 @@ | ||
| 76 | 94 | 'title' => __('Install Bricks Addon', 'fluent-cart'), |
| 77 | 95 | 'text' => __('Design your store pages with FluentCart elements in Bricks.', 'fluent-cart'), |
| 78 | 96 | 'icon' => 'AppsLine', |
| 79 | 97 | 'completed' => false, |
| 98 | + 'hash_id' => 'fluent-cart-bricks-blocks', | |
| 80 | 99 | 'url' => $baseUrl . "settings/addons" |
| 81 | 100 | ]; |
| 82 | 101 | |
| 83 | 102 | if (defined('FLUENT_CART_BRICKS_BLOCKS_VERSION')) { |
| @@ -91,8 +110,9 @@ | ||
| 91 | 110 | 'title' => __('Install Elementor Addon', 'fluent-cart'), |
| 92 | 111 | 'text' => __('Design your store pages with FluentCart widgets in Elementor.', 'fluent-cart'), |
| 93 | 112 | 'icon' => 'AppsLine', |
| 94 | 113 | 'completed' => false, |
| 114 | + 'hash_id' => 'fluent-cart-elementor-blocks', | |
| 95 | 115 | 'url' => $baseUrl . "settings/addons" |
| 96 | 116 | ]; |
| 97 | 117 | |
| 98 | 118 | if (defined('FLUENTCART_ELEMENTOR_BLOCKS_VERSION')) { |
| @@ -100,8 +120,25 @@ | ||
| 100 | 120 | $completed++; |
| 101 | 121 | } |
| 102 | 122 | } |
| 103 | 123 | |
| 124 | + if (strpos(get_template(), 'Divi') !== false) { | |
| 125 | + $steps['install_divi_addon'] = [ | |
| 126 | + 'title' => __('Install Divi Addon', 'fluent-cart'), | |
| 127 | + 'text' => __('Design your store pages with FluentCart modules in Divi.', 'fluent-cart'), | |
| 128 | + 'icon' => 'AppsLine', | |
| 129 | + 'completed' => false, | |
| 130 | + 'hash_id' => 'fluent-cart-divi-modules', | |
| 131 | + 'url' => $baseUrl . "settings/addons" | |
| 132 | + ]; | |
| 133 | + | |
| 134 | + // FLUENTCART_DIVI_BLOCKS_VERSION covers installs from before the slug rename | |
| 135 | + if (defined('FLUENTCART_DIVI_MODULES_VERSION') || defined('FLUENTCART_DIVI_BLOCKS_VERSION')) { | |
| 136 | + $steps['install_divi_addon']['completed'] = true; | |
| 137 | + $completed++; | |
| 138 | + } | |
| 139 | + } | |
| 140 | + | |
| 104 | 141 | return $this->response->json([ |
| 105 | 142 | 'data' => [ |
| 106 | 143 | 'steps' => $steps, |
| 107 | 144 | 'completed' => $completed |
| @@ -125,18 +162,36 @@ | ||
| 125 | 162 | return Product::query()->count() > 0; |
| 126 | 163 | } |
| 127 | 164 | |
| 128 | 165 | |
| 129 | - private function isAllPageSetUpDone(array $settings): bool | |
| 166 | + private function getMissingPageSetup(array $settings): ?array | |
| 130 | 167 | { |
| 131 | - $pages = (new Pages())->getGeneratablePage(); | |
| 132 | - foreach ($pages as $pageKey => $page) { | |
| 133 | - $pageKey = "{$pageKey}_page_id"; | |
| 134 | - if (empty(Arr::get($settings, $pageKey))) { | |
| 135 | - return false; | |
| 168 | + $pagesInstance = new Pages(); | |
| 169 | + $pages = $pagesInstance->getGeneratablePage(); | |
| 170 | + | |
| 171 | + // Core pages must be checked first regardless of the order a | |
| 172 | + // fluent_cart/generatable_pages listener leaves the filtered array | |
| 173 | + // in, so an add-on can never take priority over a missing core page. | |
| 174 | + $orderedKeys = array_unique(array_merge( | |
| 175 | + array_keys($pagesInstance->corePages()), | |
| 176 | + array_keys($pages) | |
| 177 | + )); | |
| 178 | + | |
| 179 | + foreach ($orderedKeys as $pageKey) { | |
| 180 | + if (!isset($pages[$pageKey])) { | |
| 181 | + continue; | |
| 136 | 182 | } |
| 183 | + | |
| 184 | + $settingKey = "{$pageKey}_page_id"; | |
| 185 | + if (empty(Arr::get($settings, $settingKey))) { | |
| 186 | + return array_merge($pages[$pageKey], [ | |
| 187 | + 'key' => $pageKey, | |
| 188 | + 'setting_key' => $settingKey, | |
| 189 | + ]); | |
| 190 | + } | |
| 137 | 191 | } |
| 138 | - return true; | |
| 192 | + | |
| 193 | + return null; | |
| 139 | 194 | } |
| 140 | 195 | |
| 141 | 196 | private function isAnyPaymentModuleEnabled(): bool |
| 142 | 197 | { |