How To Skip WooCommerce Cart Page And Place Order Direct?

In this article, We learn how to skip the cart page and place order direct to the checkout page.

The benefit of skipping the cart page is that it’s an easy and fast process. Sometimes you can lose a customer due to a long order process.

Here I will show you 2 methods to skip the cart page in WooCommerce:

Method-1. Skip the Cart Page Via WooCommerce Settings.

Please follow the below steps to skip cart via WooCommerce Settings:

Step-1: Go to WordPress dashboard and navigate to WooCommerce > Settings.

Step-2: Select the General setting option under the Products tab.

Step-3: Check the “Redirect to the cart page after successful addition” option and save the setting.

Method-2. Using custom coding

The add_to_cart_redirect hook is used to skip the cart page and redirect to the checkout page.

Add below code in the functions.php file of your child theme.

add_filter('add_to_cart_redirect', 'skip_cart_and_redirect_checkout');
function skip_cart_and_redirect_checkout() {
 global $woocommerce;
 $redirect_to_checkout = $woocommerce->cart->get_checkout_url().'/?url=download';
 return $redirect_to_checkout ;
}

Create custom.js file in your child theme and put below code,

jQuery(document).ready(function () {
   if( getUrlParameter('url') == 'download' ){
     jQuery('#place_order').click();
 }
}

var getUrlParameter = function getUrlParameter(sParam) {
    var sPageURL = window.location.search.substring(1),
        sURLVariables = sPageURL.split('&'),
        sParameterName,
        i;

    for (i = 0; i < sURLVariables.length; i++) {
        sParameterName = sURLVariables[i].split('=');

        if (sParameterName[0] === sParam) {
            return typeof sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
        }
    }
    return false;
};
Jigna Mavani

I am a Senior WordPress developer at vision Infotech. I'm specialized in WordPress, WooCommerce, PHP, HTML, and jQuery.

Recent Posts

Testing hk

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Operation

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

TETS NEW

test

2 years ago