serverbd Posted September 27, 2022 Share Posted September 27, 2022 (edited) Im my sms clients template i missed {currency} variable value code have 'variables' => '{firstname}, {lastname}, {duedate}, {total}, {invoiceid}, {currency}' When my user getting sms they also missing country code like USD or BDT they getting first name last name and ammount perfect but missing country code only . My hook full code blew can any one suggest what is missing or wrong in the code? <?php $hook = array( 'hook' => 'InvoiceCreated', 'function' => 'InvoiceCreatedWa', 'description' => array( 'english' => 'After Invoice Creation' ), 'type' => 'client', 'extra' => '', 'defaultmessage' => 'Hello {firstname} {lastname}, Your invoice with id {invoiceid} has been generated. Total amount is {currency} {total}. The last day of payment is {duedate}. Kindly pay your bill before due date to use services without interruption', 'variables' => '{firstname}, {lastname}, {duedate}, {total}, {invoiceid}, {currency}' ); if(!function_exists('InvoiceCreatedWa')){ function InvoiceCreatedWa($args){ $api = new wamessenger(); $template = $api->getTemplateDetails(__FUNCTION__); if($template['active'] == 0){ return null; } $settings = $api->apiSettings(); if(!$settings['api_key'] || !$settings['api_token']){ return null; } $userSql = " SELECT a.total,a.duedate,b.id as userid,b.firstname,b.lastname,b.currency,`b`.`country`,`b`.`phonenumber` as `gsmnumber` FROM `tblinvoices` as `a` JOIN tblclients as b ON b.id = a.userid WHERE a.id = '".$args['invoiceid']."' LIMIT 1 "; $result = mysql_query($userSql); $num_rows = mysql_num_rows($result); if($num_rows == 1){ $UserInformation = mysql_fetch_assoc($result); $currency_sql=mysql_query('SELECT code FROM tblcurrencies WHERE id='.$UserInformation['currency']); $replace_currency=""; if(mysql_num_rows($currency_sql) > 0){ $currency_result=mysql_fetch_assoc($currency_sql); $replace_currency=$currency_result['code']; } $template['variables'] = str_replace(" ","",$template['variables']); $replacefrom = explode(",",$template['variables']); $replaceto = array($UserInformation['firstname'],$UserInformation['lastname'],$api->changeDateFormat($UserInformation['duedate']),$UserInformation['total'],$args['invoiceid'],$replace_currency); $message = str_replace($replacefrom,$replaceto,$template['template']); $api->setCountryCode($UserInformation['country']); $api->setGsmnumber($UserInformation['gsmnumber']); $api->setMessage($message); $api->setUserid($UserInformation['userid']); $api->send(); } } } return $hook; Edited September 27, 2022 by serverbd img miss 0 Quote Link to comment Share on other sites More sharing options...
serverbd Posted September 27, 2022 Author Share Posted September 27, 2022 I fixed it my self 0 Quote Link to comment Share on other sites More sharing options...
leemahoney3 Posted September 28, 2022 Share Posted September 28, 2022 Hi, Can you explain how you resolved this? Might be useful for others in the future. 1 Quote Link to comment Share on other sites More sharing options...
serverbd Posted October 3, 2022 Author Share Posted October 3, 2022 (edited) On 9/28/2022 at 8:04 PM, leemahoney3 said: Hi, Can you explain how you resolved this? Might be useful for others in the future. {currency} is missed in Database table so i put {currency} in database Edited October 3, 2022 by serverbd 0 Quote Link to comment Share on other sites More sharing options...
leemahoney3 Posted October 3, 2022 Share Posted October 3, 2022 16 hours ago, serverbd said: {currency} is missed in Database table so i put {currency} in database Ah yes, that was my understanding. Glad to hear you got it sorted! 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.