AI Verified
merge Woocommerce cart with woocommerce checkout
Merging the Woocommerce cart with the woocommerce checkout page in 4 steps. Much more userfriendly! Credit goes to @wpsimplehacks on youtube. Brilliant channel
PHP
Voted: 1 by 1 user(s)
## Step 1: Merge Woocommerce cart and checkout page In this step we’re going to add a Woocommerce cart table above the checkout table Thus, grab this code here below and add it inside your child theme’s functions.php file or better yet, use [Code Snippets](https://wordpress.org/plugins/code-snippets/) plugin for it. There is nothing to configure, just paste it as it is. // 1. Add Woocommerce cart page on the checkout page add_action( 'woocommerce_before_checkout_form', 'add_cart_on_checkout', 5 ); function add_cart_on_checkout() { if ( is_wc_endpoint_url( 'order-received' ) ) return; echo do_shortcode('[woocommerce_cart]'); // Woocommerce cart page shortcode } ## Step 2: Redirect Woocommerce cart page to checkout page This part is optional and use it if you don’t want the “View cart” buttons to direct your users to cart page. Also, use it if you don’t want your users to access Woocommerce cart page directly. So, grab this code and add it to you functions.php file or Code Snippets code box. Pay attention that “cart” and “/checkout/” parts are your cart and checkout pages slugs. If you have any other slugs (karte or kassa for example) then change them accordingly. // 2. Redirect cart page to checkout add_action( 'template_redirect', function() { // Replace "cart" and "checkout" with cart and checkout page slug if needed if ( is_page( 'cart' ) ) { wp_redirect( '/checkout/' ); die(); } } ); ``` ## Step 3: Redirect empty Woocommerce checkout page to shop page Now, this part is needed only if you added a redirection from Woocommerce cart page to checkout page in the step 2. If you didn’t do it then you can skip this part. BUT if you are redirecting your cart page then this part is crucial because otherwise you will end up with “Too many redirects” error on your checkout page after deleting the products from cart. Take a look at the “shop” slug inside the code. Replace it with your own shop page slug. you could also redirect to another page use wp_safe_redirect( slug ); // Redirect to home url from empty Woocommerce checkout page add_action( 'template_redirect', 'redirect_empty_checkout' ); function redirect_empty_checkout() { if ( is_checkout() && 0 == WC()->cart->get_cart_contents_count() && ! is_wc_endpoint_url( 'order-pay' ) && ! is_wc_endpoint_url( 'order-received' ) ) { wp_safe_redirect( get_permalink( wc_get_page_id( 'shop' ) ) ); exit; } } // or alternative step 3 :**Show “Return to shop” button in empty checkout page** add_filter( 'woocommerce_checkout_redirect_empty_cart', '__return_false' ); add_filter( 'woocommerce_checkout_update_order_review_expired', '__return_false' );
The author has provided the following URL that may be helpful to setting up or using this snippet:
https://youtu.be/bWYW_QmBA6sScroll down to see more snippets from this codevault.
The author has indicated that this snippet is compatable up to wordpress version: 6.1
Our AI bot has checked this snippet is compatable up to wordpress version: 6.1
Free & Pro
Download this snippet by clicking the download button, then head over to the Code Snippet Plugin settings in your wordpress admin dashboard, select the import menu then upload this file to import into your wordpress site.
Pro Only (Coming Soon)
You will be able to click a button and sync this snippet to your wordpress site automatically and from your dashboard manage all code snippets across all your wordpress sites that have the Code Snippets Pro plugin installed.
Last modified:
15/06/2023
This snippet has the following status:
AI Verified
This snippet has been tested by our AI bot, see any comments below.
AI Bot Comments:
Found 0 vulnerabilities
1
Please see some snippets below related to this snippet..
WooCommerce
AI Verified
Added: 7 months ago
Last Updated: 7 months ago
This will clear the Woo Cart after 5 mins of inactivity
WooCommerce
AI Verified
Added: 1 year ago
Last Updated: 1 year ago
Yes you read that correctly, colour with a U. Here in the UK, we spell things a little differently. Anyway, to the guide. Adding a colour picker to the single product template is really easy. When a u...
WooCommerce
AI Verified
Added: 2 months ago
Last Updated: 2 months ago
Adds plus and minus buttons to quantity input woocommerce
These are some popular snippets from this users codevault..
WooCommerce
AI Verified
Added: 1 year ago
Last Updated: 1 year ago
Merging the Woocommerce cart with the woocommerce checkout page in 4 steps. Much more userfriendly! Credit goes to @wpsimplehacks on youtube. Brilliant channel
WooCommerce
AI Verified
Added: 1 year ago
Last Updated: 1 year ago
Add a short cut to the customers courses from his Woocommerce my acount dashboard.
Category
Snippet Status