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; });
Ziaur Rahman
November 27, 2020Hello, I am using the OceanWP theme. I put your code to my function.php. It breaks my page design.
Screenshot: https://ibb.co/5hrHm3P