In the example I will use variable '$sale_approve_link' from 'Merchant - new sale/lead' email template. Let's assume that our PAP is using 'https://' url. In default behaviour the variable will be filled with 'https://examplesite.com/affiliate/....'.
But we want to remove ssl protocol, and change it to 'https://examplesite.com/affiliate/....'.
1. Setup the email template:
First you have to create plugin name. For this purpose I will use 'https_to_http' name. It is very important to remember this keyword.
Now replace {$sale_approve_link} variable with modified one: {$sale_approve_link|https_to_http}. In general modified variable has to match following format:
{$variable_name|plugin_name} (separated by pipe '|')
2. Create plugin:
Name of the plugin file has to match format 'modifier.plugin_name.php', so this plugin file will be 'modifier.https_to_http.php'.
In plugin source code must be a function that describes its behaviour. In our example we will replace string 'https://' with 'https://'. Complete source code:
<?phpAgain, function name has to match following format 'smarty_modifier_plugin_name($variable)'.
/**
* Smarty |https_to_http modifier
*
* Examples:
* <pre>
* {$sale_approve_link|https_to_http}
* </pre>
* @author Ivan Ivanco
* @param string
* @return string
*/
function smarty_modifier_https_to_http($link)
{
return str_replace('https://', 'https://', $link);
}
?>
3. Upload plugin to PAP installation:
The last step is to upload plugin to following directory:
'include/Pap/SmartyPlugnis'