Skip the cart page and combine the cart and checkout pages

For a super sleek checkout experience, we can combine the cart and checkout pages together very easily.

This snippet will bypass the cart page when adding items to the cart and redirect to cart is checked in the WooCommerce settings, if that setting is not checked, the AJAX will still work and you’ll get redirected to the checkout page when clicking “View Cart”.

It will also add the cart to the top of the checkout page for a nicer, quicker, easier to convert checkout.

Add this to your functions.php

// COMBINE THE CART AND CHECKOUT PAGES
add_action( 'woocommerce_before_checkout_form', function () {
  if ( is_wc_endpoint_url( 'order-received' ) ) return;
      echo do_shortcode('[woocommerce_cart]');
}, 5 );


// SKIP THE CART PAGE WHEN ADDING TO CART
add_filter('woocommerce_add_to_cart_redirect', function () {
  global $woocommerce;
  $checkout_url = wc_get_checkout_url();
  return $checkout_url;
});

 


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.