Jump to content

Limiting 1 trial per client


codemaster2008

Recommended Posts

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

Link to comment
Share on other sites

  • 2 weeks later...

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated