augis2003 Posted September 25, 2013 Share Posted September 25, 2013 Hi, i'm trying to make my first module. It will take customer address from order, and print postcode in order view. My code looks like: public function getCode() { $add =( 'http://postit.lt/data/?address=' . $this->ad->address1 .' ' . "+" . ' ' . $this->ad->city . '' ); $url = str_replace(' ', '%20', $add); $json = file_get_contents($url); $result = json_decode($json, true); if($result['total'] < 3) { $suc = $result['data'][0]['post_code']; echo "Pašto kodas yra: " . "LT-". $suc; }else{ echo "Pašto kodas nerastas"; } } function hookAdminOrder($params) { $display = ' <br /><fieldset style="width: 400px"> <legend><img src="../modules/'.$this->name.'/logo.png" /> '.$this->l('Pašto Kodas').'</legend> <img src="../modules/'.$this->name.'/logo.png" />'.$this->l(' Pašto kodas yra: ').' ' . $this->getCode() .' ' . "TEXT NEED HERE" . '<br /> </fieldset> '; return $display; } My problem is about view in admin side, please see attachment . Maybe someone can bring me idea what i'm doing wrong? Link to comment Share on other sites More sharing options...
vekia Posted September 25, 2013 Share Posted September 25, 2013 you've got in code: <img src="../modules/'.$this->name.'/logo.png" />'.$this->l(' Pašto kodas yra: ').' ' . $this->getCode() .' ' . "TEXT NEED HERE" . '<br /> so it shows this text instead of function results Link to comment Share on other sites More sharing options...
augis2003 Posted September 25, 2013 Author Share Posted September 25, 2013 But if i change to this: function hookAdminOrder($params) { $display = ' <br /><fieldset style="width: 400px"> <legend><img src="../modules/'.$this->name.'/logo.png" /> '.$this->l('Pašto Kodas').'</legend> ' . $this->getCode() .' </fieldset> '; return $display; } nothing changing, my function still show in top of form.. Link to comment Share on other sites More sharing options...
vekia Posted September 25, 2013 Share Posted September 25, 2013 instead of echo use return, in code: if($result['total'] < 3) { $suc = $result['data'][0]['post_code']; echo "Pašto kodas yra: " . "LT-". $suc; }else{ echo "Pašto kodas nerastas"; } } change it to: if($result['total'] < 3) { $suc = $result['data'][0]['post_code']; return "Pašto kodas yra: " . "LT-". $suc; }else{ return "Pašto kodas nerastas"; } } will work Link to comment Share on other sites More sharing options...
augis2003 Posted September 26, 2013 Author Share Posted September 26, 2013 Oh cool. Thanks, now it's working Link to comment Share on other sites More sharing options...
vekia Posted September 26, 2013 Share Posted September 26, 2013 glad to hear that i could help you a little in this case im going to mark this topic as [solved] best regards Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now