WooCommerce - Skip cart page redirecting to checkout page

我与影子孤独终老i 提交于 2019-11-29 12:15:30

You can skip cart definitively, redirecting customers to checkout page when cart url is called.

To achieve this use this code snippet, that should do the trick:

// Function that skip cart redirecting to checkout
function skip_cart_page_redirection_to_checkout() {

    // If is cart page, redirect checkout.
    if( is_cart() )
        wp_redirect( WC()->cart->get_checkout_url() );
}
add_action('template_redirect', 'skip_cart_page_redirection_to_checkout');

This code goes in function.php file of your active child theme (or theme) or also in any plugin file.

The code is tested and fully functional.


Edit: Since WooCommerce 3 replace wp_redirect( WC()->cart->get_checkout_url() ); by:

 wp_redirect( wc_get_checkout_url() );
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!