Add to cart from a product table

WooCommerce / Product Table

The buy column adds a product without leaving the table. AJAX add to cart is on by default. Quantity fields, checkboxes, and the cart summary are off until you turn them on.

Buy column

Include buy in columns. Out-of-stock and non-purchasable products do not get a button. A variation row that is out of stock shows “Out of stock” instead.

AttributeDefaultWhat it does
cart_buttonbuttonbutton is Add to cart. checkbox replaces the button with a checkbox for multi-add. button_checkbox also renders the checkbox, not a button plus a checkbox.
quantitiesfalseShow a quantity field in the buy column. This is not a column name.
ajax_carttrueAdd without a full page reload. false uses the normal WooCommerce add-to-cart link.
button_textShow detailsLabel for the separate button column, not the Add to cart label.

The quantity field starts at the product’s minimum purchase quantity, and it respects the maximum when WooCommerce has one.

Add several products at once

multi_add="true" prints Select all and Add selected to cart above the table. That only works when the buy column is a checkbox. The buy column also has to be visible.

[yh_wc_product_table columns="sku,name,stock,price,buy" cart_button="checkbox" quantities="true" multi_add="true" rows_per_page="100"]

Each checked row is added with its quantity. Name Your Price rows must have an amount filled in before they will add. See Variable products and Name Your Price.

Cart summary, checkout, and quick view

AttributeDefaultWhat it does
footer_cartfalseA bar under the table with the item count, subtotal, View cart, and Checkout.
floating_cartfalseA floating cart button with the same links.
direct_checkoutfalseAfter a successful add, send the customer to checkout instead of staying on the table.
quick_viewfalseAdd an eye icon in the buy column. It opens a modal with the image, price, and short description.
[yh_wc_product_table columns="image,name,price,buy" quick_view="true" footer_cart="true" ajax_cart="true"]

Common mistakes

Add to cart does nothing on a variable product

The parent row needs a variation selected. With variations="dropdown" (the default), the customer picks each attribute in the buy cell first.

Fix: Leave the default, or use variations="rows" so each variation has its own Add to cart. variations="false" replaces Add to cart with a link to the product page.

Select all is there, but nothing is added

Select all only ticks checkboxes. cart_button="button" never prints checkboxes, and a missing buy column removes them too.

Fix: Use cart_button="checkbox" and include buy in columns.

The row flashes, then the cart is unchanged

WooCommerce rejected the add. Sold individually, a minimum quantity, or a Name Your Price amount outside the min and max will do that. The notice is the reason.

Fix: Read the notice above the table. Match the quantity to the product’s min and max. For Name Your Price, enter an allowed amount before adding.