WooCommerce - Skip cart page redirecting to checkout page

前端 未结 1 1005
没有蜡笔的小新
没有蜡笔的小新 2020-12-11 10:55

Our website is kohsamuitour.net. I have added custom code to skip the cart page on checkout, which works for all sales. This code:

function wc_empty_cart_red         


        
相关标签:
1条回答
  • 2020-12-11 11:11

    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() );
    
    0 讨论(0)
提交回复
热议问题