Add Products to Cart from WordPress

Hi! I have all of my page content within WordPress, but on the home page I would like to list out my products. My cart only contains 4 products, so I have no problem hard coding them, but I am wondering if there is a way to hook into the AJAX in the system so that I can have a Quantity and Add to Cart button on the home page of my WordPress install?

Thanks in advance!

Generally you would POST an array like:

Assuming the product_id of the product is 123, use:


To have a quantity other than ‘1’ you need to POST

product_data[123][amount] =

This isn’t really AJAX since I’m guessing you want the user to be able to actually purchase what they’ve put in the cart, select options, use coupons, etc…

If you just want to add to the cart and require a checkout then do this as an http_request and simply ignore the response. Then, to checkout use:


when you want to take them to checkout.

Thanks for the tips. I will post back if I have any other issues!

Thanks again!!

Hey tbirnseth, I did run into an issue, hopefully you can help me out.


The first two and the last product work just fine, you can change the Qty and it will add it to the cart just like normal.

The issue I am having is that on the third product (Gel) it is not recognizing the Qty field. It will recognize the Size drop down though… any hints as to what would cause this or how I can fix this behavior?


Your link wants to redirect elsewhere. I don’t chase links from unknown sources.

I don’t know exactly what you mean by “it will recognize the Size drop down though”.

If you want to add option selction to the item added to the cart then there’s different format for options. You’ll have to do your own search for that. Options are generally done with JS and have a specific IDand naming structure.

It ended up being a silly issue of me not having enough quantity in stock.

Everything is working fine now.

Thanks for the help.