Hi everyone, on my Opencart php website I have an extension which sends emails to customers sometimes. I’m trying to implement / add a simple PHP spintax to the extension. Extension already changes some strings automatically, eg {firstname} {lastname} changes to the persons first and last name. I would also like the controller of the module to change change the spintax as well. I found this PHP Spintax code: Simple-PHP-SpinTax-Script, could anyone help me implement this? How can I get the code to look for any spintax eg {1|2|3|4|5} on my email template, than just replace it with a random spintax number 1 though 5
My mail template looks something like this:
Hello {firstname} {lastname}. Here is the spintax {1|2|3|4|5}
Part of the PHP code from the extension:
$patterns = array();
$patterns[0] = ‘{firstname}’;
$patterns[1] = ‘{lastname}’;
$patterns[2] = ‘{cart_content}’;
if (!($settingTemplate[‘DiscountType’]==‘N’)) {
$patterns[3] = ‘{discount_code}’;
$patterns[4] = ‘{discount_value}’;
$patterns[5] = ‘{total_amount}’;
$patterns[6] = ‘{date_end}’;
}
$patterns[7] = ‘{unsubscribe_link}’;
$replacements = array();
$replacements[0] = $result[‘customer_info’][‘firstname’];
$replacements[1] = $result[‘customer_info’][‘lastname’];
$replacements[2] = $CartProducts;
if (!($settingTemplate[‘DiscountType’]==‘N’)) {
$replacements[3] = $DiscountCode;
$replacements[4] = $settingTemplate[‘Discount’];
$replacements[5] = $settingTemplate[‘TotalAmount’];
$replacements[6] = date($moduleData[‘DateFormat’], $TimeEnd);
}
…
…
…
…