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.
Related Posts:
- How to add product in woocommerce with php code [closed]
- How to add date range in woocommerce with code
- Creating custom Woocommerce attribute taxonomies from a plugin
- WooCommerce: How to display item meta data in email confirmation using woocommerce_order_item_meta_end
- How to get the original price of the product in woocommerce?
- How to get Woocommerce Variation ID? [closed]
- How to Remove a Filter from the Admin List Table?
- Woocommerce, recognize the loop of related products
- Remove commas from WooCommerce checkout addresses fields
- WooCommerce Link to Product Category
- How to display product cropped thumbnail (150×150) for WooCommerce product categories
- Add to checkout total lines an additional line below shipping in WooCommerce
- Output a WooCommerce product custom field in WooCommerce using get_post_meta()
- Append a term to WooCommerce product existing product category terms
- using woocommerce_template_single_add_to_cart in shop-loop – javascript issues [closed]
- How To Change The Html of Products filtration sidebar in Woocommerce?
- How To add custom radio boxes to WooCommerce Billing page and change total price by this field?
- WooCommerce: update custom fields after checkout validation failure
- Trigger Woocommerce New User Email
- Writing scripts using WordPress / WooCommerce classes?
- How to make custom total price reactive in navigation
- Change description on specific WooCommerce product status change
- Woocommerce – Filter Variable Products by Variation Attributes and Variations Regular Price
- How to add a second ‘place order’ button in WooCommerce [closed]
- Woocommerce redirect thankyou page based on product ID doesn’t empty Cart
- tracking number field in Woocommerce order [closed]
- WooCommerce Related Products by Attribute
- Image as Sales Badge
- Modify HTML structure of fields in woocommerce checkout form
- WooCommerce Webhooks not firing because of error in wp-includes/meta.php
- Add a product to checkout via form
- Trying to place a custom field after the total section in the checkout page in woocommerce
- WordPress default Search function inconsistent in WooCommerce Product Titles
- Sum the total amount of a specific product purchased per user and display in table
- How can I get the values of my WordPress $wpdb query in Jquery?
- How to add specific meta tags to head of cart and checkout pages in woocommerce?
- Woocommerce change prices for a certain country [closed]
- Is there a way to hook or call a custom woocomerce template that is not part of the default templates of woocommerce?
- get taxonomy thumbnail and use it as a variable in code
- Extend Woocommerce Widget Class – WC_Widget_Product_Categories
- How to upload WP user avatar on woocommerce account page [closed]
- Remove item in Checkout
- How to relocate paypal button gateway on checkout page in woocommerce
- Woocommerce – get_items() returns empty array
- How do I run code every 24 hours?
- Include js script ONLY on woocommerce product category pages? [closed]
- WP_Query multiple post results
- Convert Featured products loop into Recent products loop?
- Woocommerce order status payment
- Dynamically added custom fields not displayed on WooCommerce email notifications
- Woocommerce. Get a list of products in the current category on the archive page and product page
- How can I enter on the Thank you page in woocommerce the discount code I assigned to the product category?
- Payment field disappears on custom Paypal plugin
- Creating a brand attribute as a variable
- How do I set a hidden field to a value?
- How to remove Login from in my account page
- I am having errors with checkout on wordpress
- How to access specific product id on other pages/posts?
- How do I check if a product is in two categories?
- php code for outputting a custom page in my account
- Programmatically add a product to the cart and set price to zero when buying from certain category
- I want to show cart items number if any or nothing, simple CART text
- How to retrieve quantity input field by id in woocommerce
- Remove span tags from WooCommerce Downloads page
- Get only relevant sub-category of category “Genre” that applies to current product only
- Using zip code to display custom data in Admin Order Details
- How can I update the price when someone enters postcode or zip code in woocommerce checkout page?
- Edit woocommerce_product_archive_description using hook
- Including user data in “new user notification email”
- How do I remove an action hook inside a class that is called by another class?
- How to create loop inside wordpress function?
- Add Shortcode to ::before class
- i want add conditional for add category in wordpress
- WooCommerce get products based on the taxonomy
- Woocommerce Add custom “Add to cart button” in single page with tags
- Woocommerce remove menu item on myaccount dashboard
- How to echo a PHP code into WooCommerce variation product?
- append data to mysql table via submit button coded in php – not working
- random woocommerce categories are not showing when count enabled?
- PHP – Woocommerce 3.2 Add variable shipping insurance with multiple “else if ” conditions
- how to display woocomerce description of each category in wordpress? [closed]
- WordPress 3.0 PHP Error – notice WordPress_product_Type was called incorrectly
- WooCommerce – Add product category below product price [closed]
- WooCommerce remove_action and add_action [closed]
- woocommerce plugin bugs
- Adding my own custom template page but got white page
- Woocommerce Price Text
- Ajax Load More or View More functionality for woocommerce category layout by template overriding
- wc_add_notice not working on cart page
- ACF | WooCommerce | Theme Development | How to include a /template-part/ that makes use of ACF’s on a custom WooCommerce homepage?
- Woocommerce – Shipping tax class based on cart items not using the highest tax available
- How to find the value of the user password in wordpress and send it to another server via rest api
- Change Checkout “Place Order” text if cart has a specific product
- How do I update product shipping using PHP in WooCommerce?
- How can I edit the WooCommerce Mini DropDown Cart to read as follows
- Remove Woocommerce product from cart with ajax/fetch
- Automatically change insurance quantity based on cart total [closed]
- Why does WordPress not send the user the email to add a password?
- WooCommerce Modal Fly cart on add to cart – With AJAX
- Hide ‘Downloadable’ and ‘Virtual’ checkbox options from Woocommerce Variations?