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
- How to get selected variation from URL?
- Need to add custom cart item data
- 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?
- how to do login using woocommerce rest api From android
- Custom wordpress Theme and Plugin repository
- Customize The Events Calendar to Include an Option to Expand for More Events Listings
- changing posts layout in ultimate member profile plugin
- Is there a way to get plugins and themes not built for multisite to work on a network subsite?
- Add filter on html tags,attributes on specific function in wordpress
- Add item to the woocommerce dashboard menu from a plugin
- wc_get_template new template does not showing up
- Overriding an Array in a Plugin’s Class/Function from functions.php
- Woocommerce – WordPress Roles & Capabilities
- Change Header (Logo) Based on Login
- How can i summerize posts or news automatically in word press site?
- wp_mail – using a custom field value
- Edit page header on a custom plugin
- How to get custom minimum price in Woocommerce
- Edit all $wp_scripts at once to $in_footer = false
- Restrict posts to customers with complete WooCommerce orders only
- How to hide featured images of all posts falling under the same category in wordpress?
- woocommerce – adding wrapper around custom made woocommerce form fields
- How can i solve php upgrade problem
- How to Upload images to a custom folder in upload folder using media uploader
- Making a list that can be filtered by category/tags
- how to change a static testimonials into dynamic
- Rename a folder via HTML POST request
- I have English words in Kurdish pages
- How can I add a custom Javascript snippet to display my feedback in footer?
- working code, not working – Plugin Dev
- category page multiple products add to cart any plugin available for woocommerce
- Cannot view Custom Post Type no matter what I try
- Custom shortcode being shown in WPBakery backend rather than the block
- Issue calling my functions on Plugin activate in WordPress
- User upload dashboard
- Meta Key array building with multiple input values from fields
- How Can I display Specific User Pages?
- Create dynamic / data driven pages in wordpress
- Saving data only when payment is successful
- custom/automatic export function – one post at a time?
- Template conflict with WC Payment Method
- Get value from an input field and pass into update_meta_data as $meta_value
- Custom SportsPress list
- How to restrict “too soon” downloads with a general rule?
- Display Powerpress media url
- Hide some shortcodes on posts from back-end
- How to allow customers to input a text as a product variation *and* charge per character?
- Add a filter to a different custom plugin
- Trying to disable all notifications except for one on woocommerce checkout page with css [closed]
- Child Plugin Admin Panel
- Does anyone have the Custom Post Permalinks plugin from John P. Bloch? [closed]
- Translate text for empty product
- How to Add Extra Text In WordPress Title Before Post Publish
- How can I make a quotation engine like this website in WooCommerce?
- ShipStation WooCommerce Integration error
- Add Text in Single Product Page On a Specific Category
- How to fix a Wordfence scan that doesn’t finish?
- add to cart linking to add to cart page