One of the most powerful features you can implement in your WooCommerce store is the ability to create a direct checkout link — a special URL that sends users straight to the checkout page with a product already added to the cart. This method eliminates friction, speeds up the buying process, and improves conversions. But what happens when your checkout link doesn’t work or shows a warning like “You cannot add another product to your cart”?

In this article, we’ll show you how to:

Create a direct checkout link in WooCommerce

Solve issues with empty carts

Fix or hide the “cannot add another product” warning

Customize the checkout experience

✅ Why Use a Direct Checkout Link?

Instead of sending your users to a product page, then a cart, and finally checkout, you can skip all steps and send them directly to checkout with the product already added. This is great for:

🔗 The Correct URL Format

https://yourwebsite.com/?add-to-cart=PRODUCT_ID&quantity=1

🛠️ Step-by-Step: Set Up Direct Checkout Link

#Step-01

Log in to your website cPanel, and open the file manager 

#Step-02

Find your targeted domain and open it- If you have one website then click public_html

#Step-03

Open “wp-content” 

#Step-04

Open the theme file

#Step-05

Open your activated WordPress theme

#Step-06

Edit the functions.php file

#Step-07

Add this code in the field, make sure to save the code

add_action(‘template_redirect’, ‘auto_redirect_to_checkout’); function auto_redirect_to_checkout() { if (isset($_GET[‘add-to-cart’]) && isset($_GET[‘redirect_to’]) && $_GET[‘redirect_to’] === ‘checkout’) { wc_add_to_cart_message(wc()->cart->add_to_cart((int) $_GET[‘add-to-cart’])); wp_safe_redirect(wc_get_checkout_url()); exit; } } add_filter(‘wc_add_to_cart_message_html’, ‘suppress_duplicate_cart_notice’, 10, 2); function suppress_duplicate_cart_notice($message, $products) { if (strpos($message, ‘You cannot add another’) !== false) { return ”; // Remove message } return $message; }

Code Added success

Now we need to generate the target URL

URL format is: https://yourdomain.com/?add-to-cart=PRODUCT_ID&quantity=1&redirect_to=checkout

Now, just changed the product ID

#Step-1

Log in to your WordPress website and go to the product page

#Step-2


Now find the product ID –  Simple hover-over the product link in product page and you see the product ID here.

4092 this product ID

Now replace the ID

https://yourdomain.com/?add-to-cart=4092&quantity=1&redirect_to=checkout

If user visit this link then this product added to the cart and redirect to checkout page by one single click. You can create different line by changing the product ID only.

Leave a Reply

Your email address will not be published. Required fields are marked *