Jump to content

Why  {currency} variable value missing ?


serverbd

Recommended Posts

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;

 

 

Screen Shot 2022-09-27 at 10.28.28 PM.png

Edited by serverbd
img miss
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated