An empty WooCommerce Cart page can be disappointing for customers, particularly if they’ve spent time browsing and adding items.

To enhance their shopping experience, consider redirecting them to a more engaging page such as the Shop page. This redirection can encourage customers to explore further and potentially make a purchase.

Utilize the redirect page to highlight ongoing sales, promotions, or new products that could capture their interest. This strategy can stimulate interest and prompt customers to complete a purchase.

Now, let’s explore how to redirect users from the empty Cart page to another page on your website. Enjoy the process!

function fixelar_redirect_if_empty_cart() {
   if ( is_cart() && WC()->cart->is_empty() ) {
      $redirect_to = wc_get_page_permalink( 'shop' );
      // OR $redirect_to = 'https://yoursite.com';
      
      wp_safe_redirect( $redirect_to );
      exit;
   }
}
add_action( 'template_redirect', 'fixelar_redirect_if_empty_cart', 9999 );