With WooCommerce you have some shortcodes available to use anywhere in your site.
One of them is the shortcode [add_to_cart]
which allows printing the Add to Cart button for a specific product on your site.
It only shows the button though, you can’t choose the quantity of that product without going to the cart page before.
You can include the quantity field tweaking the default template.
Let’s see how.
Before you make any code changes, have a backup of your site. This will help you restore things in case of unforeseen errors. I recommend using Jetpack Backup for real-time backups and one-click restores.
Download “Loop Add to Cart”
add-to-cart-2.5.0.zip – Downloaded 7462 times – 1.27 KBDownload the zip above and extract it. Put the file add-to-cart.php in wp-content/themes/your-theme-name/woocommerce/loop/. This path may not exists, if it’s your case, create it and then paste the file in it.
Leave a Reply