WooCommerce add to cart URL

I am using WooCommerce for downloadable products. I have a button that has the URL to the downloadable file. My goal is to replace that link with another one that would add the product to the shopping cart instead.

Add Comment
1 Answer(s)
Best answer

All you need to do is to alter the downloadalbe product URL to:
http://yourproducturl.com/cart/?add-to-cart=%ID%

This is where “%ID%” is the Post ID of the product. When clicked, it will add the product to the shopping cart and redirect to the Cart/Check-Out.

Additionally, you can add specific properties, quantities etc. to the URL itself:

http://yourproducturl.com/cart/?add-to-cart=%id_product%&variation_id=%id_varia‌tion%&attribute_pa_%name_attribute%=%attribute_slug_value%

Russel Thomas Answered on November 26, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.