codemaster2008 Posted February 26, 2010 Share Posted February 26, 2010 Hi there; I'd like to modify the viewcart.tpl to allow only one trial per client. The idea is: if the client is loggedin, query the database and check if he already has that product (based on the product id), if yes, show a warning and disable the checkout button. I know there is some limitations, the client can just create a new account with a new email but that's not the point. What i really need to know is how can i insert php code or query the database inside the template. Something like: {if $loggedin} {assign var='trialid' value='101'} {assign var=clientid' value='how_do_i_get_it?'} {* query database and return true if client already ordered this item before or else, false *} {/if} Hope somebody can help me with that Thanks in advance 0 Quote Link to comment Share on other sites More sharing options...
plusplushosting Posted February 27, 2010 Share Posted February 27, 2010 Hi, just use the {php} {/php} smarty tags. 0 Quote Link to comment Share on other sites More sharing options...
codemaster2008 Posted February 27, 2010 Author Share Posted February 27, 2010 Hi, just use the {php} {/php} smarty tags. Didn't know it was that easy. Thanks! 0 Quote Link to comment Share on other sites More sharing options...
codemaster2008 Posted March 8, 2010 Author Share Posted March 8, 2010 Here is what i did (in case someone is interested): Let's say the product id's are: 50 and 51. I edit the shopping cart template, so everytime the user adds a new item it will loop through all items on the cart to make sure the items 50 and 51 aren't duplicated (the user can't insert it more than once, right?). If it find a duplicated trial item, it will remove the checkout button and give the user a warning and instructions. If it pass the first check (duplicated items on the shopping cart) and the user is logged in, it will verify if the current user already have these products associated to his account, if yes, it will again remove the checkout button and show a warning. Worked for me. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.