Quick Summary
  • Add ?add-to-cart=1234&quantity=1 to your store URL, replacing 1234 with the item’s ID.
  • Use the product ID for a simple product and the variation ID for a specific variation.
  • Grouped products need the group ID plus a separate quantity[ID] for each child product.
  • Use your configured cart or checkout URL as the destination, and check the store’s redirect settings.

AI-generated summary based on the text of the article and checked by the author. Read about how BUT. Honestly uses AI.

To add one simple product to a WooCommerce cart from a link, start with this:

https://example.com/?add-to-cart=1234&quantity=1

Replace https://example.com/ with your store’s base URL, 1234 with your product ID, and 1 with the quantity to add. The numbers in every example below are placeholders, not IDs from your store.

These patterns follow WooCommerce’s add-to-cart URL documentation. The destination also depends on your store’s settings, as explained below.

Simple Products

Find the product ID under Products > All Products in your WordPress dashboard. Hover over the product title to see its ID.

The products list in Products > All Products, highlighting the product ID of a simple product.

Use that ID in add-to-cart, as in the opening example. To add three of the same product, change quantity=1 to quantity=3.

Variable Products

For a specific variation, use its variation ID instead of the parent product ID. Find it under Product data > Variations when editing the product. If you are not sure whether you need a variation at all, the difference between attributes and variations explains when they are useful.

The Variations tab of a variable product highlighting the variation ID.

If the variation ID is 5678, the link is:

https://example.com/?add-to-cart=5678&quantity=1

This selects that variation, rather than asking the customer to choose one on the product page.

Grouped Products

Use the grouped product’s ID in add-to-cart, then specify each child product’s quantity separately:

https://example.com/?add-to-cart=1234&quantity[5678]=5&quantity[7890]=2

Here, 1234 is the group ID. Replace 5678 and 7890 with the child product IDs. The example requests five of the first child product and two of the second.

Cart, Checkout, Or Another Page

Put the query string after the URL where you want the customer to land. For a simple product, these examples use cart and checkout paths:

https://example.com/cart/?add-to-cart=1234&quantity=1
https://example.com/checkout/?add-to-cart=1234&quantity=1

Replace /cart/ and /checkout/ with the actual paths of the pages configured for your store. For a variation, replace 1234 with its variation ID. The same approach works with another page on your store, using that page’s URL before the ?.

WooCommerce’s product settings include Redirect to cart page after successful addition, under WooCommerce > Settings > Products > General. That setting can take the customer to the cart instead of leaving them on the requested page. Check it when choosing a destination, and verify the final behavior on your own store before sharing the link.

  • Wrong item or no item: Recheck the ID under Products. A simple product needs its product ID; a specific variation needs its own variation ID.
  • Unavailable product: Check its published status and stock settings. WooCommerce’s product editor documentation explains these controls, including stock status and backorders. An out-of-stock item that cannot be backordered is not available to purchase through a link.
  • Unexpected quantity: Check stock availability and Sold individually in the product’s inventory settings. Sold individually limits purchases to one of that item per order; changing the URL quantity does not remove that restriction.
  • Wrong destination: Confirm the configured cart or checkout page URL and the redirect-to-cart setting described above.

Paste the finished URL into a text link in the content editor:

The WordPress content editor showing how to add the add-to-cart URL to a text link.

Or use it as the link for a Button block:

The WordPress content editor showing how to add the add to cart URL to the Button block.