Jump to content

Mattholmes

Member
  • Posts

    8
  • Joined

  • Last visited

Profile Information

  • Gender
    Male

Mattholmes's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Hi bsmither, Thank you for offering your help and giving me a starting point to work from. After a morning of reading up on the documentation for smarty tags, I have solved the problem. Basically, I created a new function to check the customer id against the customer membership table and if they are a member of the group with group_id 1, it will return the html for the extra category. I'm sure there are better ways of executing this, but for anyone else stuck with a problem like this, here is the code I used (You would need to fill in the blanks for MySQL and your website address): <?php /* * Smarty plugin * ------------------------------------------------------------- * File: function.getcustid.php * Type: function * Name: getcustid * Purpose: outputs an extra category based on customer id * ------------------------------------------------------------- */ function smarty_function_getcustid($params, Smarty_Internal_Template $template) { $sessionid = $_COOKIE['PHPSESSID']; $sqlq = "SELECT * FROM `CubeCart_sessions` WHERE `session_id` = "".$sessionid."""; $mysqli = $mysqli = mysqli_connect('host', 'username', 'password', 'database'); $res = mysqli_query($mysqli, $sqlq); if ($res) { while ($newArray = mysqli_fetch_array($res, MYSQLI_ASSOC)) { $custid = $newArray['customer_id']; $returnhtml = ''; $newsqlq = "SELECT * FROM `CubeCart_customer_membership` WHERE `membership_id` = 1"; $newres = mysqli_query($mysqli, $newsqlq); if ($newres) { while ($secArray = mysqli_fetch_array($newres, MYSQLI_ASSOC)) { $custid2 = $secArray['customer_id']; if ($custid == $custid2) { $returnhtml = '<li class="li-nav"><a href="http://www.mywebsite.com/hidden-category.html" title="Extra Category">Extra Category</a></li>'; } } } } } return $returnhtml; } ?> I saved this in a file called "function.getcustid.php", dropped it in the /lib/smarty/plugins folder and added a the following tag into my box.navigation.php file, located inside the skins/yourskinname/templates folder: <div id="nav"> <div class="navContainer"> <ul class="dropdown"> <li><a href="//www.stockmonkey.co.uk/index.php" title="{$LANG.navigation.homepage}">{$LANG.navigation.homepage}</a></li> {$NAVIGATION_TREE} {if $CTRL_CERTIFICATES && !$CATALOGUE_MODE} <li class="li-nav"><a href="{$URL.certificates}" title="{$LANG.navigation.giftcerts}">{$LANG.navigation.giftcerts}</a></li> {/if} {if $CTRL_SALE} <li class="li-nav"><a href="{$URL.saleitems}" title="{$LANG.navigation.saleitems}">{$LANG.navigation.saleitems}</a></li> {/if} {getcustid} //<-- This is the extra tag <-- </ul> </div> </div> <div class="clear"> &nbsp; </div> I have combined this with making the category hidden to get the desired result. Should anyone consider using this, I wouldn't recommend just throwing this code into your website unless you are used to working with PHP and MySQL. There are parts of it that would need to be changed to fit your website. Once again, thanks for offering your help, bsmither, and thanks for pointing me in the right direction. If you have any thoughts on how I could improve my code, please let me know. I have only been working with PHP for a few months, so I am not accustomed to best practices. Thanks, Matt
  2. Hi Bsmither, thanks for your quick response. So if I would be better tieing it all together as a mod, where would I look for documentation on how to go about it? I have experience working with PHP but very little with the smarty system, so if you know of any tutorials that would help me get started I would be very greatful. Alternatively, are there any similar mods you know of that I could use as a starting point to work from? Thanks, Matt
  3. Hi everybody, long time lurker here. Wanted to say thanks for all the help you have all provided with problems in the past. I'm currently having an issue with getting the email address of a logged in user. Basically, what i'm wanting to do is get the email address of a logged in user, and if that email address matches a specific email address then display a hidden category. This is due to our biggest customer not wanting their products easily accessible by other customers, and i'm trying to keep them happy by only showing the category with their products to them. I have had some success by putting the following code in the box.navigation.php file: {if $USER.email == '[email protected]'} <li class="li-nav"><a href="www.page.co.uk/category.html" title="Customer Name">Customer Name</a></li> {/if} However, this only displays the extra link when I am on the "index.php?_a=profile" page, which is where I got the variable "$USER.email" from, so I assume this variable is only available to that page. What i'm looking for is some way of getting the current user email address reliably so my website knows when to display the category, or an alternate way of only displaying this category to a single customer. Thanks for reading, I look forward to your responses. Matt
×
×
  • Create New...