From 963bc398c0c108b9debb34ed378bab83c4c49b7d Mon Sep 17 00:00:00 2001 From: maksim Date: Tue, 24 Jun 2025 13:19:01 +0300 Subject: [PATCH] =?UTF-8?q?Task=206899=20|=20=D0=94=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=B2=D0=B8=D0=BB=20=D1=80=D0=B5=D0=B4=D0=B8=D1=80=D0=B5=D0=BA?= =?UTF-8?q?=D1=82=20=D1=81=20/cart/=20=D0=BD=D0=B0=20/checkout=20(=D0=B5?= =?UTF-8?q?=D1=81=D0=BB=D0=B8=20=D0=BA=D0=BE=D1=80=D0=B7=D0=B8=D0=BD=D0=B0?= =?UTF-8?q?=20=D0=BF=D1=83=D1=81=D1=82=D0=B0=20-=20=D0=BD=D0=B0=20=D0=B3?= =?UTF-8?q?=D0=BB=D0=B0=D0=B2=D0=BD=D1=83=D1=8E)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global-functions/redirect-functions.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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; + } + } +}