I have a CRED commerce form which adds an event (custom post). I am was not able to find any link between the post created and WooCommerce order. I tried the following code to add order number/id to the created post custom field but its not working,
/* add order number to post */
$order_number = $data['transaction_id']; //WooCommerce Order ID associated to the buying process
$post_id = $data['extra_data']['cred_post_id']; //Post ID that was created/edited with the form
update_post_meta( $post_id, 'wpcf-order-number', $order_number);
I also want to know if there is a way to get name and email id entered during checkout and save it in custom fields of the created post?
Things added during the checkout are not part of Toolset but of WooCommerce, and you should use their API to get that data.
The Toolset Commerce API hooks are only for Toolset's forms, they will not help you to manipulate WooCommerce Data, or get that data.
The Toolset Commerce API hooks are hooks that allow you to place your (custom) code at the right moment of the Form's life/actions.
This is shown here: https://toolset.com/documentation/programmer-reference/cred-commerce-api/
For example, cred_commerce_add_product_to_cart will be fired whenever the product is added to the cart.
But it doesn't allow you to manipulate that product or its order, for that, you need WooCommerce's API.
In the Forms API, you usually will have the Form data (forms ID), product Data (Product ID) and post data (Post ID of the post created)
If you know the Product ID you can eventually use that in a WooCommerce API call to get the order connected to it.
Note that Product Data is only available on cred_commerce_add_product_to_cart, cred_commerce_before_add_to_cart and in form of an associative array that also holds transaction_id, user_id, and product_id on the cred_commerce_after_order_completed, cred_commerce_after_payment_completed, cred_commerce_after_payment_refunded, cred_commerce_after_send_notifications and cred_commerce_after_payment_cancelled.
The order ID is never part of this.
Name and Email of who places the order can maximally be caught on cred_commerce_after_order_completed, https://toolset.com/documentation/programmer-reference/cred-commerce-api/#cred_commerce_after_order_completed, where you can use the User ID variable, which is the ID of the user that ordered the item.
Then use WordPress API to get the Email of that User (if it's an user on your system)
There is otherwise no method in Forms API to get the email and name of that private data of the user/client.
You can try to grab it from the $_POST of the form, or use WooCommerce's API if they offer any for it.
However this would require custom code.
I can unfortunately not help with the custom code above that, I can give examples on how to use Toolset's API - but not create ready to go codes on Toolset API or even third-party API; please see https://toolset.com/toolset-support-policy/ related to this.