Cost Calculator Builder
Item PageVideo TutorialsChangelogResources Get Started
  • Cost Calculator Builder Documentation
  • Getting Started
    • Free Version and Pro Version
    • System Requirements
    • Plugin Installation
    • License Activation
      • Upgrading the License
    • Update Billing Details and Access Invoices
    • License Utilization
    • Update The Plugin
    • Templates
    • Feature Request
  • Plugin Features
    • How to Create a Calculator
    • How to Manage Calculators
    • How to Add a Calculator to the Page
    • Calculator Appearance
    • Additional Classes
  • Cost Calculator Settings
    • Calculator Settings
      • Summary Block
      • Currency
      • Warning Texts
      • Confirmation Page
      • Order Form
      • Form Manager
      • Sticky Calculator
      • Woo Products
      • Woo Checkout
      • Payments
      • Webhooks
    • Global Settings
      • Currency (Global)
      • PDF Entries
      • Share Quote Form
      • Order Form (Global)
      • Email Template
      • Backup Settings
      • AI Formula
      • Captcha
      • Payments (Global)
      • Geolocation
  • Calculator Elements
    • General Overview
    • Text
    • Quantity
    • Validated form
    • Dropdown list
    • Image Dropdown (Pro feature)
    • Radio Select
    • Image Radio (Pro feature)
    • Switch Toggle
    • Checkbox
    • Image Checkbox (Pro feature)
    • Date Picker (Pro feature)
    • Time Picker (Pro feature)
    • Basic Slider
    • Multi Range (Pro feature)
    • File Upload (Pro feature)
      • How to Allow Additional File Types in WordPress
      • How to Increase Maximum File Upload Size in WordPress
    • HTML
    • Geolocation (Pro feature)
    • Line
    • Formula
      • AI Assistant (Pro feature)
    • Repeater (Pro feature)
    • Group Field (Pro feature)
    • Page Breaker (Pro feature)
  • Conditional System
    • Introduction
    • How to Create a Condition
    • Condition Options
    • Condition Actions
    • AND/OR Conditions
    • Condition Creating Example
  • Special Plugin Features
    • Orders
    • Discounts
    • Required Fields
    • Contact Form 7 Plugin
  • Payments
    • Settings
    • PayPal
    • Stripe
    • Razorpay
    • Cash Payment
  • Translating Cost Calculator Into a Different Language
    • Translation Basics
    • Translating Static Strings
    • Translating Calculator with WPML
    • FAQ
  • Develeoper's guide
    • Cost Calculator Hooks
      • Order Management
      • Contact Form
      • Confirmation Page
      • Email
  • Troubleshooting
    • Introduction
    • Plugin Conflicts
    • Theme Compatibility
    • Calculator is not loading
    • Cache Settings
    • Email not sending
    • Debug Logs
    • Submit a Support Ticket
  • Changelog
    • Release Notes
    • Changelog (Free Version)
    • Changelog (Pro Version)
  • Pre-built Calculators & Cases
    • Service Booking
    • Graphic Design
    • Loan Interest
    • Delivery Service
    • Renovation Company
    • Dental Services
    • Car Wash Company
    • Medical Services
    • Tuition Fees
    • Printing Services
    • Car Rental
    • Venue Rental Service
  • Advanced Topics
    • License Management
  • Stylemixthemes
    • Cost Calculator Builder WordPress Plugin
    • Themes
    • Plugins
Powered by GitBook
On this page
  • ccb_after_create_order
  • ccb_orders_list_query
  • ccb_orders_before_create
  • ccb_show_delete_order
  • ccb_show_change_status
  • ccb_show_bulk_actions
  • ccb_after_delete_order

Was this helpful?

  1. Develeoper's guide
  2. Cost Calculator Hooks

Order Management

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);

function create_post_after_order_created($order_data, $payment_data){
    // Check if the order_data or payment_data contains the necessary information
    if(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 created
        if($post_id){
         // You can perform additional actions here if needed
         // For example, you can update post meta data or perform any other tasks
	      update_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.

Parameters:

  • $args(Array).

Example:

add_filter('ccb_orders_list_query', 'filter_admin_orders', 10, 1);

function filter_admin_orders( $args ){
$default_calc_ids = array(217, 234, 243);
$order_by = 'ASC';
$offset = 0;
$limit = 4;
    $args = array(
        'payment_method' => 'paypal',
        'payment_status' => 'pending',
        'calc_ids'       => $default_calc_ids,
        'orderBy'        => 'total',
        'sorting'        => 'ASC',
        'limit'          => (int) $limit,
        'offset'         => (int) $offset,
    );

    return $args;
}

ccb_orders_before_create

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);
function send_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 needs
		if($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;
    }
  }
 }
}

ccb_show_delete_order

This is a hook to hide the delete order button

Parameters:

  • $show(bool)

Example:

add_filter( 'ccb_show_delete_order', 'ccb_maybe_hide_button', 10, 1);
function ccb_maybe_hide_button( $show ) {
  $show = current_user_can('administrator');
  return $show;
}

ccb_show_change_status

This is a hook to hide the button to change the order status

Parameters:

  • $show(bool)

Example:

add_filter( 'ccb_show_delete_order', 'ccb_maybe_hide_button', 10, 1);
function ccb_maybe_hide_button( $show ) {
  $show = current_user_can('administrator');
  return $show;
}

ccb_show_bulk_actions

This is a hook to hide all bulk action buttons in the Orders tab

Parameters:

  • $show(bool)

Example:

add_filter( 'ccb_show_change_status', 'ccb_maybe_hide_dropdown', 10, 1);
function ccb_maybe_hide_dropdown( $show ) {
	$show = current_user_can('administrator');
	return $show;
}

ccb_after_delete_order

This is a hook to perform actions after deleting an order

Parameters:

  • $ids(Array)

Example:

add_filter( 'ccb_show_bulk_actions', 'ccb_maybe_hide_dropdown', 10, 1);
function ccb_maybe_hide_dropdown( $show ) {
	$show = current_user_can('administrator');
	return $show;
}
PreviousCost Calculator HooksNextContact Form

Last updated 1 year ago

Was this helpful?