Add to cart function not working for first product when cart is empty [closed]
Quantity is missing of the product try to use WC()->cart->add_to_cart( $new_post_id , $qty ); where $qty is a number of items you want to add in the cart for a particular product. hope this will help you. Thank you.