To add a product to the WooCommerce cart without going through its product page, all you need is a link: ?add-to-cart= followed by the product ID, or directly by the variation ID. You can put this link on any button or image, in a page designed freely with Elementor, and send the customer to the cart or the checkout.
In short
- Simple product:
/?add-to-cart=ID, with&quantity=if needed. - Variation:
/?add-to-cart=VARIATION_ID, the variation ID is enough. - Replace
/with the address of your cart or checkout page to send the customer there. - Hiding the product page from the catalog does not make it unreachable: redirect it to your page.
- No change to the WooCommerce code: your updates stay risk-free.
The background
For a client, we were selling a single product, a box, in several versions: three possible contents and seven variations in all. Instead of the standard WooCommerce product page, we wanted a real presentation page, designed freely, with an image and a button for each version.
All this without changing the WooCommerce code, so updates could carry on with peace of mind. The solution: add-to-cart links.
The link formats
WooCommerce documents these formats, to adapt with your site’s address:
- Simple product:
https://your-site.com/?add-to-cart=174&quantity=1 - Variation:
https://your-site.com/?add-to-cart=220&quantity=1, where 220 is the ID of the variation, not of the parent product. - Grouped product:
https://your-site.com/?add-to-cart=GROUP_ID&quantity[PRODUCT_ID]=2, repeatingquantity[…]for each product in the group.
To send the customer straight to the next step, put the address of the page you want before the ?:
- to the cart:
https://your-site.com/cart/?add-to-cart=220 - to the checkout:
https://your-site.com/checkout/?add-to-cart=220
Use the address of your own cart and checkout pages if they are not called /cart/ and /checkout/.
Finding the IDs
- The product: in Products, hover over the product name and its ID appears just below.
- Each variation: on the product screen, in the Variations tab, each variation shows its number (for example “#220”).
One special case: if a variation accepts “any” value for an attribute, WooCommerce cannot guess which one to put in the cart. Add the attribute to the link, for example &attribute_pa_colour=blue. The easiest way to find the right name: add this variation to the cart from the product page, then look at the product link in the cart, which contains these parameters.
Placing the links on your page
In Elementor, put the address in the Link field of a Button or Image widget, one per variation. For seven variations, count seven links: a little tedious the first time, quick after that.
Add the rel="nofollow" attribute to these links: search engine robots have no reason to follow them, and otherwise each robot visit would add a product to a cart.
Hiding the product page
The standard product page stays reachable: from the cart, the customer account or the order e-mail, the product name links to it. Two settings work together:
- Remove it from the catalog: on the product screen, in the Publish box, set “Catalog visibility” to Hidden. The product disappears from the shop and from the site search.
- Redirect it to your page: the product page can still be reached at its address. Redirect it with a redirection plugin or this code:
add_action( 'template_redirect', 'wycan_rediriger_fiche_produit' );
function wycan_rediriger_fiche_produit() {
if ( is_product() && 174 === get_the_ID() ) {
wp_safe_redirect( home_url( '/my-box/' ), 301 );
exit;
}
}Replace 174 with your product ID and /my-box/ with the address of your page.
Need a custom product page?
A sales page designed for your product, buttons that add the right variation, a short buying journey: this is the kind of detail we take care of in our shops.



