fix: PHP errors and clean up error_log statements
- Fixed redirect_wc_pages_to_spa: added spa_mode check (only redirect when 'full') - Fixed PHP fatal error: use get_queried_object() instead of global $product - Removed all error_log debug statements from codebase - Fixed broken syntax in PaymentGatewaysProvider.php after error_log removal
This commit is contained in:
@@ -159,11 +159,17 @@ class TemplateOverride
|
||||
*/
|
||||
public static function redirect_wc_pages_to_spa()
|
||||
{
|
||||
// Get SPA page URL
|
||||
// Get SPA settings
|
||||
$appearance_settings = get_option('woonoow_appearance_settings', []);
|
||||
$spa_page_id = $appearance_settings['general']['spa_page'] ?? 0;
|
||||
$spa_mode = $appearance_settings['general']['spa_mode'] ?? 'full';
|
||||
$use_browser_router = $appearance_settings['general']['use_browser_router'] ?? true;
|
||||
|
||||
// Only redirect when SPA mode is 'full'
|
||||
if ($spa_mode !== 'full') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$spa_page_id) {
|
||||
return; // No SPA page configured
|
||||
}
|
||||
@@ -193,9 +199,10 @@ class TemplateOverride
|
||||
}
|
||||
|
||||
if (is_product()) {
|
||||
global $product;
|
||||
if ($product) {
|
||||
$slug = $product->get_slug();
|
||||
// Use get_queried_object() which returns the WP_Post, then get slug
|
||||
$product_post = get_queried_object();
|
||||
if ($product_post && isset($product_post->post_name)) {
|
||||
$slug = $product_post->post_name;
|
||||
wp_redirect($build_route('product/' . $slug), 302);
|
||||
exit;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user