Skip to main content

Create your own custom content variable

You are here:
← All Topics

This article belongs to our plugin : WooCommerce Customize My account Pro

Below given code is a sample code that will create content variable {smart_offer} , you can create your own custom variable like this. This will require version >=3.6.17

You may use Code Snippets plugin to to use any such custom code.

/**
 * $content - endpoint content
 * $endpoint_label - endpoint label
 * variable - smart_offer
 */

add_filter('wcmamtx_modify_existing_content_variables','wcmamtx_modify_existing_content_function',10,2);

function wcmamtx_modify_existing_content_function($content, $endpoint_label) {
	
	$smart_offer = 'We have 20% discount offer this week. Valid for this month only. Use Coupon Code 20OFF';
	
	$content     = str_replace( '{smart_offer}', $smart_offer, $content );
	
	return $content;
}