mohamedali Posted March 27, 2015 Share Posted March 27, 2015 (edited) hi friends, i am a new to php and prestashop, now i am working in online grocery shop site. what i need is when a customer entered into the site,first they want to select their city. once they select their city, the page never ask to select city till the session expire.. i wrote jquery ajax for this.it works fine first time and display the session $_SESSION['city'] variable value. if i refresh the page the {if !isset($smarty.cookies.city)} condition does not work again.. help me.. header.tpl -------------------------------- {if !isset($smarty.session.city)} <div id="graybg"> </div> <div id="city_select_div"> Select your city : <div id="mycity">MYCITY</div> </div> {/if} global.js ----------------- $('#mycity').click(function(){ var city=$('#mycity').text(); $(this).parent().hide(); $(this).parent().prev().hide(); $.ajax({ url: 'themes/default-bootstrap/city_session.php', type: "POST", datatype: 'json', data: "city_value="+city, success: function (jsonData) { $('.shop-phone').append('<span>City :'+jsonData+'</span>'); } }); }); ----------------------- city_session.php ------------------------ <?php echo $_SESSION['city']=$_REQUEST['city_value']; ?> Edited March 27, 2015 by mohamedali (see edit history) Link to comment Share on other sites More sharing options...
mohamedali Posted April 4, 2015 Author Share Posted April 4, 2015 i got solution and solved it.. Link to comment Share on other sites More sharing options...
goutham7p Posted April 15, 2015 Share Posted April 15, 2015 what was the solution? how did you solve it? Link to comment Share on other sites More sharing options...
mohamedali Posted April 18, 2015 Author Share Posted April 18, 2015 i created a php file "city_session.php" in root folder with following code, /*----------------city_session.php-------------------*/ <?phpinclude 'config/config.inc.php' ;include 'init.php' ; Context::getContext()->cookie->city="chennai"; //echo Context::getContext()->cookie->city; ?>/*-------------------------------*/ and call it via normal jquer ajax... globa.js $('#mycity').click(function(){ var city=$('#mycity').text(); $(this).parent().hide(); $(this).parent().prev().hide(); $.ajax({url: 'city_session.php',type: "POST",datatype: 'json',data: "city_value="+city,success: function (jsonData){//alert(jsonData); $('.shop-phone').append('<span>City :'+jsonData+'</span>');} }); });}); /*--------------------------------*/ header.tpl {if !isset($cookie->city)} <div id="graybg"> </div> <div id="city_select_div"> Select your city : <div id="mycity">MYCITY</div> </div> {/if} /*---------------------------*/ 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