diff --git a/wp-content/themes/cosmopet/global-functions/redirect-functions.php b/wp-content/themes/cosmopet/global-functions/redirect-functions.php index 522709a..0f83aa9 100644 --- a/wp-content/themes/cosmopet/global-functions/redirect-functions.php +++ b/wp-content/themes/cosmopet/global-functions/redirect-functions.php @@ -14,3 +14,18 @@ function redirect_non_logged_in_users() { } +add_action('template_redirect', 'custom_redirect_cart_to_checkout'); + +function custom_redirect_cart_to_checkout() { + if (is_cart()) { + // Проверка, если корзина пуста + if (WC()->cart->is_empty()) { + wp_redirect(home_url()); + exit; + } else { + // Редирект на страницу чекаута + wp_redirect(wc_get_checkout_url()); + exit; + } + } +}