简体   繁体   中英

Woocommerce add to cart URL

I am trying to work out whether it might be possible to put a straightforward HTML URL link on a button in order to add a product to a woocommerce cart. I am using a wordpress theme to show digital downloadable products but the theme itself has no cart and checkout facility so I am trying to use woocommerce for this.

I have a button for each of my products which can contain a URL to link directly to the downloadable file but when clicked I want it instead to add the product to the woocommerce cart.

There appears to be a way to do this using a shortcode but the theme is stripping out the square brackets to I need a full URL instead.

You cannot link directly to the downloadable file as it is stored in a protected directory, if you simply want to have a URL that adds a specific Product to your Cart and open the Cart/Checkout page then this will help.

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

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

Replace %ID% with the Post ID of the 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM