Serial Posted August 12, 2015 Share Posted August 12, 2015 Hi, I want in order-carrier.tpl to display a list field with all my stores. How can I do this ? My code : <select name="choix_magasin"> {foreach $stores as $store} <option value="$store.id_store">$store.name</option> {/foreach} </select> I have an error : Notice: Undefined index: stores in C:\wamp\www\PrestaTDU\tools\smarty\sysplugins\smarty_internal_templatebase.php(171) : eval()'d code on line 192 Link to comment Share on other sites More sharing options...
ventura Posted August 13, 2015 Share Posted August 13, 2015 You must add the stores db query in the controller, FrontController.php or in a module $stores = Db::getInstance()->executeS(' SELECT s.*, cl.name country, st.iso_code state FROM '._DB_PREFIX_.'store s '.Shop::addSqlAssociation('store', 's').' LEFT JOIN '._DB_PREFIX_.'country_lang cl ON (cl.id_country = s.id_country) LEFT JOIN '._DB_PREFIX_.'state st ON (st.id_state = s.id_state) WHERE s.active = 1 AND cl.id_lang = '.(int)$this->context->language->id); $this->smarty->assign('stores',$stores); Link to comment Share on other sites More sharing options...
Serial Posted August 13, 2015 Author Share Posted August 13, 2015 In what function of FrontController I must to add this ? Link to comment Share on other sites More sharing options...
Serial Posted August 14, 2015 Author Share Posted August 14, 2015 Up Link to comment Share on other sites More sharing options...
Serial Posted August 14, 2015 Author Share Posted August 14, 2015 It's OK !!! If you want the solution, I override OrderController.php and create a new function : class OrderController extends OrderControllerCore { public function get_ListeMagasins() { $stores = Db::getInstance()->executeS(' SELECT s.*, cl.name country, st.iso_code state FROM '._DB_PREFIX_.'store s '.Shop::addSqlAssociation('store', 's').' LEFT JOIN '._DB_PREFIX_.'country_lang cl ON (cl.id_country = s.id_country) LEFT JOIN '._DB_PREFIX_.'state st ON (st.id_state = s.id_state) WHERE s.active = 1 AND cl.id_lang = '.(int)$this->context->language->id); $this->context->smarty->assign('stores',$stores); return $stores; } } I'm going to the OrderController.php and I add before : $this->setTemplate(_PS_THEME_DIR_.'order-carrier.tpl'); I added : $this->get_ListeMagasins(); In the order-carrier.tpl : <select name="choix_magasin"> {foreach $stores as $store} <option value="{$store.id_store}">{$store.city}</option> {/foreach} </select> Link to comment Share on other sites More sharing options...
Serial Posted August 14, 2015 Author Share Posted August 14, 2015 Aftee this, how can I save the choice of the customer in a variable ? I must to have this variable for other traitements (invoice etc...) 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