These hooks let developers customize Orders in the Cost Calculator.
ccb_after_create_order
This is a hook that creates a post with a post meta after creating an order and being triggered.
Parameters:
$order_data(Array)
$payment_data(Array)
Example:
add_action('ccb_after_create_order','create_post_after_order_created',30,2);functioncreate_post_after_order_created($order_data, $payment_data){// Check if the order_data or payment_data contains the necessary informationif(isset($order_data['calc_id'])&&isset($payment_data['total'])){// Customize the post title based on the order data $post_title ='New Post for Calc ID '. $order_data['calc_id'];// Create a new post $post_data =array('post_title'=> $post_title,// Set the post title'post_content'=>'This post is related to calculator ID '. $order_data['calc_id'] .' for total amount'. $payment_data['total'],// Set the post content'post_status'=>'publish',// You can set the post status as per your requirement'post_author'=>1,// Set the post author ID'post_type'=>'post',// Set the post type );// Insert the post into the database $post_id =wp_insert_post($post_data);// Check if the post was successfully createdif($post_id){// You can perform additional actions here if needed// For example, you can update post meta data or perform any other tasksupdate_post_meta($post_id,'order_data', $order_data);update_post_meta($post_id,'payment_data', $payment_data); } }}
ccb_orders_list_query
This is a hook for filtering orders in the admin. This hook allows you to change which orders will be loaded in the dashboard.
This hook gives input data before the order is created
Parameters:
$data(Array)
Example:
add_filter('ccb_orders_before_create','send_data_before_creating_order',10,1);functionsend_data_before_creating_order( $data ) {if($data['order_data']['calc_id'] ==408){ //replace 408 with the id of the calculator $args =array();if($data['payment_data']['type'] =='paypal'){ $args['data']['status'] = $data['payment_data']['status']; //Change data according to your needsif($data['payment_data']['total'] >200){ $args['data']['currency'] = $data['payment_data']['currency']; //change 'data['total']' $response =wp_remote_post('https://webhook.site/b6d9f12f-71a5-40ca-8769-3e15023ee537', array('body'=> $args)); $body =wp_remote_retrieve_body( $response ); }if ( is_wp_error( $response )||is_wp_error( $body ) ) { $errors[] ='There was an error occurred after sening a request';return $errors; } } }}