Woocommerce add to cart url

I am trying to figure out if I can put a direct HTML URL link on a button to add a product to my woocommerce basket. I use the wordpress theme to show digital downloadable products, but the theme itself does not have a cart and verification tools, so I'm trying to use woocommerce for this.

I have a button for each of my products that may contain a URL for a direct link to the download file, but when I click on it I want it to add the product to the woocommerce basket instead.

There seems to be a way to do this using short code, but the theme highlights the square brackets so I need the full URL.

+4
source share
1 answer

You cannot directly link to the downloaded file, since it is stored in a protected directory, if you just want the URL that adds a specific Product to the basket and opens the Cart / Checkout page, this will help.

http://yourproducturl.com/checkout/?add-to-cart=%ID%

http://yourproducturl.com/cart/?add-to-cart=%ID%

Replace %ID%the message identifier of a specific product so that when the link is clicked, the visitor will be redirected to the "Cart / Checkout" page with the above product added to their cart.

+7
source

Source: https://habr.com/ru/post/1524932/


All Articles