false, 'messages' => array( __( 'Please enter a default collection slug (e.g. wines).', '7labs-debug-branding-for-commerce7' ) ), ); } if ( C7DBT_Helpers::is_c7wp_active() ) { if ( ! empty( $settings['update_continue_shopping'] ) ) { $continue = 'collection/' . $slug; C7DBT_Helpers::update_c7wp_setting( 'c7wp_continue_shopping', $continue ); C7DBT_Helpers::update_c7wp_setting( 'continue_shopping', $continue ); $messages[] = __( 'Continue Shopping path updated in Commerce7 settings (when supported).', '7labs-debug-branding-for-commerce7' ); } if ( ! empty( $settings['enable_c7_custom_routes'] ) ) { C7DBT_Helpers::update_c7wp_setting( 'c7wp_enable_custom_routes', 'yes' ); $routes = array( 'profile' => 'profile', 'collection' => 'collection', 'product' => 'product', 'club' => 'club', 'checkout' => 'checkout', 'cart' => 'cart', 'reservation' => 'reservation', ); $existing = C7DBT_Helpers::get_c7wp_settings(); if ( ! empty( $existing['c7wp_frontend_routes'] ) && is_array( $existing['c7wp_frontend_routes'] ) ) { $routes = array_merge( $routes, $existing['c7wp_frontend_routes'] ); } C7DBT_Helpers::update_c7wp_setting( 'c7wp_frontend_routes', $routes ); $messages[] = __( 'Enabled custom Commerce7 front-end routes.', '7labs-debug-branding-for-commerce7' ); } } $shop_url = C7DBT_Helpers::home_path_url( 'collection/' . $slug ); $messages[] = sprintf( /* translators: %s: shop URL */ __( 'Shop URL ready: %s', '7labs-debug-branding-for-commerce7' ), $shop_url ); $messages[] = __( 'Tip: Resave Permalinks (Settings → Permalinks → Save) if routes still 404.', '7labs-debug-branding-for-commerce7' ); return array( 'success' => true, 'messages' => $messages, 'shop_url' => $shop_url, ); } /** * Shop URL status for dashboard. * * @return array{status:string,label:string,url:string,detail:string} */ public function status() { $settings = C7DBT_Settings::get(); $slug = $settings['default_collection_slug']; $url = $slug ? C7DBT_Helpers::home_path_url( 'collection/' . $slug ) : ''; if ( ! $slug ) { return array( 'status' => 'error', 'label' => __( 'No default collection', '7labs-debug-branding-for-commerce7' ), 'url' => '', 'detail' => __( 'Set a collection slug like “wines” so /collection/wines becomes your shop.', '7labs-debug-branding-for-commerce7' ), ); } if ( empty( $settings['redirect_collection_root'] ) ) { return array( 'status' => 'warn', 'label' => __( 'Redirect not enabled', '7labs-debug-branding-for-commerce7' ), 'url' => $url, 'detail' => __( 'Base /collection is empty by default. Enable redirect to your collection.', '7labs-debug-branding-for-commerce7' ), ); } return array( 'status' => 'ok', 'label' => __( 'Shop route configured', '7labs-debug-branding-for-commerce7' ), 'url' => $url, 'detail' => sprintf( /* translators: %s: path */ __( '/collection redirects to /collection/%s', '7labs-debug-branding-for-commerce7' ), $slug ), ); } }