Email

These hooks let developers customize Email in the Cost Calculator.

ccb_email_attachment

This is a hook to add existing files inside WP.

Parameters:

  • $attachments(Array)

  • $calc_id(Integer)

Example:

add_filter('ccb_email_attachment', 'add_attachment', 10, 2);

function add_attachment($attachments, $params){
if ( $params['calcId'] == 257) { //change 257 to the ID of your calculator 
  $attachments[] = ABSPATH .'wp-content/uploads/2023/10/filename.pptx'; //set the ABSOLUTE path to the file here  
}
	return $attachments;	
}

ccb_email_rich_text

This hook allows you to turn off rich text format in summary, as well as customize the text itself.

Parameters:

  • $description(String)

  • $calc_id(Integer)

Example:

add_filter('ccb_email_rich_text', 'disable_rich_text', 20, 2);

function disable_rich_text($description, $calc_id){
	if($calc_id == 257){
		$description = strip_tags($description);
	}
	
	return $description;
}

ccb_email_body_client

This is a hook for changing the content of the email for clients.

Parameters:

  • $template(String)

Example:

add_filter('ccb_email_body_client', 'change_email_client_content', 10, 1);

function change_email_client_content($template){
	$template = '
		<html>
		<header>Demo Email Client</header>
		<body>
			<p> Demo email client content </p>	
		</body>
		</html>	
	';	
	return $template;
}

ccb_email_body_user

This is a hook to change the content of the email for users.

Parameters:

  • $template(String)

Example:

add_filter('ccb_email_body_user', 'change_email_user_content', 10, 1);

function change_email_user_content($template){
	$template = '
		<html>
		<header>Demo Email User Content</header>
		<body>
			<p> Demo email user content </p>	
		</body>
		</html>	
	';	
	return $template;
}

ccb_email_header

This hook allows you to change the header of the message.

Parameters:

  • $footer_content(String)

  • $calc_id(Integer)

Example:

add_filter('ccb_email_header', 'change_header_content', 10, 2);
function change_header_content($header, $args){
	if($args['calc_id'] == 257){
		$header = 'From: DemoPage  <vineere@gmail.com>
Content-Type: text/html; charset=UTF-8';		
	}
	return $header;
}

This hook allows you to change the footer of the email.

Parameters:

  • $footer_content(String)

  • $calc_id(Integer)

Example:

add_filter('ccb_email_footer', 'custom_footer_function', 10, 2);

function custom_footer_function($footer_content, $calc_id){
	if($calc_id == 257){
		$footer_content = '<p>This is a demo footer content</p>';
	}
	return $footer_content;
}

ccb_email_date

This is a hook that changes the date of sending the email or allows to change the format of the date of sending the email.

Parameters:

  • $email_date(String)

  • $calc_id(Integer)

Example:

add_filter('ccb_email_date', 'custom_email_date', 10, 2);
function custom_email_date($email_date, $calc_id){
	if($calc_id == 257){
		$email_date = gmdate("M d Y H:i:s") ."\n";
	}
	return $email_date;
}

ccb_email_logo_style

This is a hook for changing company logo styles.

Parameters:

  • $logo_style(String)

  • $calc_id(Integer)

Example:

add_filter('ccb_email_logo_style', 'custom_email_logo_style', 10, 2);
function custom_email_logo_style($logo_style, $calc_id){
	if($calc_id == 257){
		$logo_style = 'margin:50px; background:green;';
	}
	return $logo_style;
}

ccb_email_logo_html

This is a hook to add custom HTML code to the company logo block.

Parameters:

  • $email_logo(String)

  • $calc_id(Integer)

add_filter('ccb_email_logo_html', 'custom_email_logo_html', 10, 2);
function custom_email_logo_html($email_logo, $calc_id){
	if($calc_id == 257){
		$email_logo = '<p>This is a demo logo content</p>';
	}
	return $email_logo;
}

ccb_email_title

This is a hook to change the title of the email.

Parameters:

  • $email_title(String)

  • $calc_id(Integer)

add_filter('ccb_email_title', 'custom_email_title', 10, 2);
function custom_email_title($email_title, $calc_id){
	if($calc_id == 257){
		$email_title = 'Custom Email Title';	
	}

	return $email_title;
}

Last updated