1. Documentation /
  2. Creating WooCommerce 'Add to Cart' URLs

Creating WooCommerce ‘Add to Cart’ URLs

Below, we’ll cover how you can create specific links to add products to your customers cart using custom URLs. You can add products to the cart, specify the quantity, and even redirect to another page all with a URL or link.

Finding Your Product ID

↑ Back to top

These ‘Add to Cart’ URLs all require knowing the product ID from WooCommerce to work. You can find a product ID by hovering over the product title under WooCommerce > Products in your dashboard. The product ID will then appear under the product title.

Custom ‘Add to Cart’ URL for Simple Products

↑ Back to top

To add a simple product to the cart, use this URL structure. Replace example.com with your site’s URL and PRODUCT_ID and QUANTITY with your specific product details:


Custom ‘Add to Cart’ URL for Variable Products

↑ Back to top

For setting a specific variable product, use the variation ID found when editing a variable product. For example, if you wanted to use this variation for the blue color with logo it would be ID number 39.


Custom ‘Add to Cart’ URL for Grouped Products

↑ Back to top

For grouped products, include the product ID and quantities for each sub-product.

For one sub-product:


Repeat for additional sub-products:


And so on.

Redirecting After Adding to Cart

↑ Back to top

After a product is added to the cart, you can choose where the customer is redirected to. By default, they will stay on the same page unless the WooCommerce settings are configured to redirect to the cart or checkout page.

To customize the redirect location, append the URL where you want the customer to land. For example, to redirect to the checkout page after adding a product to the cart, use:


As another example, to redirect to the cart page after adding a product to the cart, use:


Enable AJAX in WooCommerce > Settings > Products > General to prevent page reloading when items are added to the cart.

Questions and Support

↑ Back to top

Do you still have questions and need assistance? 

This documentation is about the free, core WooCommerce plugin for which support is provided in our community forums on WordPress.org. Searching there you’ll often find that your question has been asked and answered before.

If you haven’t created a WordPress.org account to use the forums, here’s how.

  • If you’re looking to extend the core functionality shown here, we recommend reviewing available extensions in the Woo Marketplace.
  • Need ongoing advanced support, or a customization built for WooCommerce? Hire a WooExpert agency.
  • Are you a developer building your own WooCommerce integration or extension? Check our Developer Resources.

If you weren’t able to find the information you need, please use the feedback thumbs below to let us know! 🙏