0

I am create SMS module and in SMS template i use custom variable such as {{var customer.getName()}} .

How i can convert this variable to same variable for example if user use {{var customer.getName()}} in SMS template when SMS was sent customer see his/here name in SMS

1 Answer 1

0

I create this method

    private function replace($string, $customer='', $order=''){


            $str='';
            $string=explode(" ",$string);
            foreach ($string as $item){
                $new_word=$item;
                if(strpos($item,'$') !== false){
                    $word=explode(".",$item);

                    if($word[0]=='$customer')
                    {
                        $c_word="get".ucfirst($word[1]);
                       $new_word= $customer->$c_word();

                    }elseif($word[0]=='$order'){
                        $o_word="get".ucfirst($word[1]);
                        $new_word= $order->$o_word();

                    }
                }

                $str.=" ".$new_word;

            }
            return $str;
  }

I know this way is not a magento way but for now fixed my problem and i am stay in waiting for better way

            $this->replace("hi $customer.name your id is $customer.id ",$customer,$order);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.