Force Item To Add To Cart On Page Load In WordPress WooCommerce Cart

This probably isn’t useful for anyone but I’m currently using WooCommerce with WordPress and I needed a solution where a product item would automatically be added to cart on page load. The code below is what I came up with, this code will also force the user to have only 1 quantity of the item. To use, fill in the $product_id variable with your product id and paste the code in your child themes functions.php file. add_action( 'wp_loaded', function() {

Continue Reading

Site Footer

Sliding Sidebar


Nice to meet you, my name is Ryan and I build stuff for the web. Welcome to my website where you can learn about me and my interests.