• tom

    (@klickchoice)


    [Moderator Note: Topic title amended. Your problem is no more “important” than anyone else’s.]

    Hi, recently my server team replaced my database and they put our previous database . So we lost our order details of one day . Now the server team give the backup that contain the lost day order details . Now please tell how can i restore these orders .

    I cannot replace our database with the given backup , because today also we have orders .

    Please give the best solution .

    Thank you

    https://www.ads-software.com/plugins/woocommerce/

Viewing 11 replies - 1 through 11 (of 11 total)
  • 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 .

    Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

    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 .

    Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

    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
    https://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();
    Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

    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

    Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

    Then you should probably use the rest API rather than core functions.

    Thread Starter tom

    (@klickchoice)

    Could you please give one example .

    Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Restore woocommerce orders.’ is closed to new replies.