I got it by using wc_create_order
here is the full code
`if ( isset( $_POST[‘submitted’] ) ) {
$address = array(
'first_name' => $_POST['fullname'],
'email' => $_POST['email'],
'phone' => $_POST['phone'],
'address_1' => $_POST['address'],
'city' => $_POST['city'],
);
$order = wc_create_order();
$order->add_product( get_product( get_the_id() ), $_POST['quantity'] );
$order->set_address( $address, 'billing' );
$order->set_address( $address, 'shipping' );
$order->set_payment_method( 'cod' );
$order->calculate_totals();
}`
Related Posts:
- WooCommerce create new product and add to cart on form submit
- How to set value/term of a Woocommerce attribute text field in admin panel?
- How to add product images using script?
- Can’t create term for product attribute
- Manually add order item with fixed product_id in WooCommerce
- custom payment gateway in woocommerce failed to connect to remote api server
- Save custom attributes of product in woocommerce
- creating a custom shop page display on archive woocommerce
- Redirect to another page using contact form 7? [closed]
- I am trying to make a field show and save from quickedit screen
- .php file for woocommerce edit category? [closed]
- I want to filter my products with attributes [closed]
- Automatic recurring payment using YITH subscription and Dokan Stripe
- woocommerce remove coupon link does not work
- Hide fields in woocommerce settings
- Adding discount functionality to the cart
- How to assign a specific service to a specific provider based on location
- Woocommerce list variations that are added already to cart in Single Product
- Automatically check “Enable stock management at product level” to the existing products?
- Need help saving input fields for Security Deposit plugin in WC Vendors page
- Create Custom Coupon Type
- Product customizing quiz – quiz adding products to the cart
- Delete tables from database when deleting plugin
- WooCommerce ‘all’ orders no longer being displayed – how may I debug/fix [closed]
- Custom comment type maybe?
- Posts wont expire
- WooCommerce Dynamic Cart Pricing
- plugin for wp_list_categories with posts
- How to get last_updated and newest_blogs in WP 3.0
- Add multiple attributes to product from php
- Will Flutter work with WordPress 3.0?
- Only Homepage not loading properly
- woocommerce 3.2.1 not sending order notification emails
- Override Javascript in a Plugin?
- Anonymous Postings
- WordPress automatically removes line break
- Add woocommerce variation images in gallery?
- Fetch Children of Grouped Products Inside WooCommerce Product Loop
- Run plugins only on certain pages
- WooCommerce: Building a page with user input which is used to query order status and external API and return a result
- Post category with counts been display like a menu
- Post custom Data value in The Events Calendar plugin [closed]
- Best way to maintain and update 3rd-party WP plugin when developer is unresponsive?
- Why am I getting ( WooCommerce Services could not be installed (Could not create directory.). ) error and how to solve it ?
- how to do login using woocommerce rest api From android
- Custom wordpress Theme and Plugin repository
- Woocommerce Shop page variation product button replace with add to cart button
- woocommerce with custom post type
- WordPress as template engine
- WooCommerce – set session with new cart item meta when updating cart item quantity [closed]
- Conditional Shipping Options if Certain Products are in Cart WooCommerce
- Woocommerce Backend Search by Title and SKU
- WooCommerce Shopping Cart Not Initially Showing Products [closed]
- Woocommerce singe product custom gallery output works just on the first slide
- How to include a custom field in the woocommerce email?
- WordPress – source link plugin – how to modify it?
- add seperate suffix for low price and high price in woocommerce
- Get products list by url key in WordPress Woocommerce [closed]
- Minimize and Uglify WordPress Plugin Files
- Override a Plugin Function
- Comment “like” problem – “users who like this” avatar linking to current user profile instead of “liker’s” profile
- Add key and value to an array in another file
- How display specific category post to specific users?
- Download counter for skydrive shared files in wordpress
- How to return a specific attribute
- How to keep plugin (media-sync) running even the tab is closed?
- Elementor: How to design Dropdown Select Box Navigation page like Chegg
- Visual composer custom element error
- How to access a wordpress plugin page or add posts without doing it from the WordPress dashboard?
- Plugin which unlock free gift when you reach some amount in cart
- Woocommerce redirection if no previous orders
- Creating custom “player-objects”
- Checkbox field that add a subscription product and change prices of other products in checkout and cart page
- Installation failed, trying to install ANY plugin
- Object of class WP_Error could not be converted to string in /formatting.php
- WordPress delete cookie
- multiple string replace of post’s content for large data
- wordpress plugin translation not working
- Many to many relationship for variable products
- Multi-site error wordpress after migration
- change product image url in widgets & shop page
- Update Plugin Without Overwriting Custom Settings
- woocommerce blank page after clicking add to cart [closed]
- Where to insert customize_register in wordpress plugin
- Problems with installing and deleting plugins
- wp_query for more fields plugin
- Issues with Post 2 Post Plugin
- Woocommerce Bookings – Resource needs to be allocated for part of the booking duration, not the whole booking
- Move related products after product summary? [closed]
- How ACF Advanced Custom Field works with Woocommerce Single Product [closed]
- How to generate a responsive output from plugin?
- The plugin generated xxx characters of unexpected output during activation
- WP Customer Reviews call short code on another page [closed]
- Populate Woocommerce order notes with custom field value
- Woocommerce Product Add-ons – Auto-select first option
- Display out of stock products in WooCommerce [closed]
- how to add meta for order in woocommerce
- WooCommerce REST API aborts connection [closed]
- How to make a Template page to show the information of different things Shop and Product page?
- How to create different woocommerce single_product.php pages for each product? [closed]