How to add Custom “Add to Cart” URLs in WordPress

Here’s how to create custom WooCommerce Add to Cart links / buttons and make them add products to cart, redirect to specific pages. This tutorial includes also variable and grouped products, as well as quantities >1.

1) Simple Products: Add to Cart URL

Add One Simple Product to Cart

( https://yourdomain.com/?add-to-cart=282 )

Just copy this link and replace your domain and your product id and paste it into your Button Link or any text link.

Add One Simple Product to Cart with Quantity = 3

( https://exampledomain.com/?add-to-cart=282&quantity=3 )

Just copy this link and replace your domain and your product id and &quantity=3/2 paste it into your Button Link or any text link.

Add One Simple Product to Cart & Redirect to Cart Afterwards

”https://yourdomain.com/cart/?add-to-cart=282″

Add One Simple Product to Cart & Redirect to Checkout Afterwards

(https://yourdomain.com/checkout/?add-to-cart=25)

Remember, for this to work you must tick the “Enable AJAX add to cart buttons on archives” option under WooCommerce –> Settings –> Products -> General and also disable “Redirect to the cart page after successful addition”

Leave a Reply

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