Create WooCommerce order (shop_order) instead of post
-
Hi,
I have added the following code into functions.php :
add_action('init', 'wc_orders_public'); function wc_orders_public() { global $wp_post_types; $wp_post_types['shop_order']->public = true; }
This way “Orders” will appear as an option on the Frontend Uploader Settings page at the “Enable Frontend Uploader for the following post types” section. This is happening because FU is listing on the settings page only the public post types.
My issue is after submission the order is not created (the Orders post type is checked in the mentioned admin section/page).
I have tried this:
add_action( 'fu_after_upload', 'my_fu_after_upload', 10, 3 ); function my_fu_after_upload( $attachment_ids, $success, $post_id ) { $address = array( 'first_name' => 'First Name', 'last_name' => 'Last Name', 'company' => 'Example Ltd.', 'email' => '[email protected]', 'phone' => '111-111-111-111', 'address_1' => '01 Test Street', 'address_2' => '', 'city' => 'Test city', 'state' => 'TS', 'postcode' => '12345', 'country' => 'TS' ); //print_r($post_id); $order = wc_create_order(); $order->add_product( get_product( '24' ), 1 ); $order->set_address( $address, 'billing' ); $order->set_address( $address, 'shipping' ); //$order->calculate_totals(); }
I do need only a very simple/basic form of the order.
Do I am missing something?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Create WooCommerce order (shop_order) instead of post’ is closed to new replies.