Task 6899 | Добавил редирект с /cart/ на /checkout (если корзина пуста - на главную)

pull/36/head
parent 3f5eebe9e7
commit 963bc398c0
  1. 15
      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;
}
}
}

Loading…
Cancel
Save