Thread Starter
tom
(@klickchoice)
Could you please tell the step by step instruction . I Created a new database and uploaded backup .
I understand that order are saved in wp_posts, and post meta .
So what i need to do ? , i export the all the order in that date from wp_posts,and post meta as sql file . Then just need to import it in to current database ? It make any problem ?
Thread Starter
tom
(@klickchoice)
Is any one know the solution ,please reply .
also when i check the database i can see that order is related in 4 tables
wp_posts
wp_postmeta
wp_woocommerce_order_items
wp_woocommerce_order_itemmeta
Please reply anyone know the solution .
I don’t think we can provide a solution for you for restoring backups because your restores will be the full tables. You only want to missing orders from wp_posts.
I’d suggest importing that backup elsewhere and creating those missing orders manually, or processing them externally. Trying to merge them back is going to cause ID conflicts.
Thread Starter
tom
(@klickchoice)
I am going to select order from that particular date by downloading it from posts,post_meta,order_items,order_item_meta . After downloading each table individually with the selected data’s then i am going to insert this details to corresponding tables .
Is that a good method ? Is that work ?
Please advice .
No it’s not a good method because the auto-incremented post IDs may have already increased in the live database which means you’ll have ID conflicts.
Thread Starter
tom
(@klickchoice)
You are correct .
Please tell how can i add order by Programmatically.
How to use wc_create_order ?
Because i am planing to create a new page for staff in which they can add customers order . Just putting the product id , product quantity , customer details etc . When they adding the order shipping charge need to calculate automatically . How to do this ? Is there any function to proceed this ?
For example :
Product id=1, qty=1
customer detail
first name: ddd
last name :rr
email : [email protected]
phone :123456
Address : addressxxxx
state :statexxx
paymentmethod: cash on delivery
Please tell which function i need to use .
I see the following code from stackoverfllow
http://stackoverflow.com/questions/26581467/creating-woocommerce-order-with-line-item-programatically
Please check this code is valid
$address = array(
'first_name' => 'Fresher',
'last_name' => 'StAcK OvErFloW',
'company' => 'stackoverflow',
'email' => '[email protected]',
'phone' => '777-777-777-777',
'address_1' => '31 Main Street',
'address_2' => '',
'city' => 'Chennai',
'state' => 'TN',
'postcode' => '12345',
'country' => 'IN'
);
$order = wc_create_order();
$order->add_product( get_product( '12' ), 2 ); //(get_product with id and next is for quantity)
$order->set_address( $address, 'billing' );
$order->set_address( $address, 'shipping' );
$order->add_coupon('Fresher','10','2'); // accepted param $couponcode, $couponamount,$coupon_tax
$order->calculate_totals();
Why use code and not the backend interface?
Thread Starter
tom
(@klickchoice)
Because some times i need to add order very easily , and very fast, From the friend end , without loading header, footer and other stuffs
Then you should probably use the rest API rather than core functions.
Thread Starter
tom
(@klickchoice)
Could you please give one example .