Jump to content

How to run custom php code in prestashop 1.6


Recommended Posts

Since php tags no longer work inside smarty, how can I run php code from my prestashop site?  I have a php script that checks users location and if in a certain area it will call a javascript function that displays a warning.


Since I can't add this code directly to my .tpl files, how can run the script from within prestashop.  It should work on all pages, incase someone enters the site from outside the landing page.  Also, can I make the script only run once, so that if a user has been to any store page already the code is just ignored?


Link to comment
Share on other sites

I think I would try to would make a small template 'plugin' and use that to get the answer of in/outside the area. Then based on the answer run some javascript.


This was quite a clear example for me:



My 2 cents,



P.S. smarty var in JS: http://iamrookie.com/blog/296/using-smarty-variable-within-javascript-or-jquery-function.html

Edited by PascalVG (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...