chary Posted July 23, 2015 Share Posted July 23, 2015 (edited) Q: I would like to display pin-code service check availability. Description : I have done checking database and displaying an error message if pincode is not available and also success message by using echo .so by writing this line($this->errors[] = Tools::displayError('no pincode available');i'm able to display an error message but i'm not able to display success message in this way.i kept this line in controller.but i want a success message in .tpl file and it should get displayed in a same page.so can u please help me out . theme/bob/product.tpl <div class="col-xs-12 col-sm-6"> <form action="{$customizationFormTarget}" method="post" id="login_form" class="box"> <div class="form_content clearfix"> <div class="form-group"> <label for="zip">{l s='zip address'}</label> <input class="is_required validate account_input form-control" data-validate="iszip" type="text" id="zip" name="zip" value="{if isset($smarty.post.zip)}{$smarty.post.zip|stripslashes}{/if}" /> </div> <p class="submit"> <button type="submit" id="SubmitZip" name="SubmitZip" class="button btn btn-default button-medium exclusive1"><span>{l s='ok'}</span> </button> </p> </div> </form> </div> controller/productController.php /** ************* ZIP CODE ************ **/ public function postProcess() { if (Tools::isSubmit('SubmitZip'))$this->processSubmitZip(); } protected function processSubmitZip() { Hook::exec('actionBeforeAuthentication');$zip = trim(Tools::getValue('zip')); if (empty($zip))$this->errors[] = Tools::displayError('An zip address required.'); else { $customer = new Product();$zipcode_val = $customer->getByZip(trim($zip)); if (!$zipcode_val || !$customer->id) $this->errors[] = Tools::displayError('please enter the correct zip-code.'); else { //echo "this is chary123==" . $this->context->cookie->id_customer = (int)($customer->id); $success = $this->context->cookie->id_customer = (int)($customer->id); //$this->errors[] = Tools::displayError('pincode available'); //echo "pincode available"; } } } class/product.php /** new custome zip **/ public function getByZip($zip) { $sql = 'SELECT *FROM `'._DB_PREFIX_.'zipcode` WHERE `zip_code` = \''.pSQL($zip).'\''; $result = Db::getInstance()->getRow($sql); if (!$result) return false; $this->id = $result['sno']; foreach ($result as $key => $value) // print_r($result); if (array_key_exists($key, $this)) $this->{$key} = $value; return $this; } Edited July 23, 2015 by chary (see edit history) 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