Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 07-24-2009 12:47:18

osussat
Member
Registered: 04-16-2005
Posts: 128

Skin by User / User Group

Hi all
Please can you point me in the right direction of the settings to select a particular skin to display according to a user / user group?
Many thanks
Oli

Offline

 

#2 07-24-2009 12:53:05

Dave
Member
Registered: 07-05-2003
Posts: 11233

Re: Skin by User / User Group

CCP does not support skins on a per user or user group basis.

Offline

 

#3 07-24-2009 12:54:47

osussat
Member
Registered: 04-16-2005
Posts: 128

Re: Skin by User / User Group

Hi Dave
Is this something that can be changed?  I'd like our Staff to have access to more information about products than regular users.
Best
Oli

Offline

 

#4 07-24-2009 12:59:29

Dave
Member
Registered: 07-05-2003
Posts: 11233

Re: Skin by User / User Group

Not without a custom modification.  However, the user group a logged in person is part of and their user information is available in global variables so you could build your product detail display to show more or less data based on that information fairly easily.

Offline

 

#5 07-24-2009 13:04:28

osussat
Member
Registered: 04-16-2005
Posts: 128

Re: Skin by User / User Group

Hi Dave
Thanks again for coming back to me so quickly.  I think I follow you.  So we could use IF commands to check out the Usergroup global variable, and display product information differently depending on if the IF statement is true or not?  That leads me into my next question of how on earth we add more fields to the product information screens!
Thanks as ever
Oli

Offline

 

#6 07-24-2009 13:18:22

Dave
Member
Registered: 07-05-2003
Posts: 11233

Re: Skin by User / User Group

osussat wrote:

So we could use IF commands to check out the Usergroup global variable, and display product information differently depending on if the IF statement is true or not?

Yes, exactly.

osussat wrote:

That leads me into my next question of how on earth we add more fields to the product information screens!

All of the product information is available in the product detail displays in the $proddisp PHP array.  The index keys match the column names so, for example, the inventory level would be shown using $proddisp['invlevel']

Offline

 

#7 07-24-2009 13:20:04

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Skin by User / User Group

That's right.  You could include PHP code in your skin that adjusts the display based on the usergroup.  This would be done like so:

Code:

<?php /* PHP FUNCTION: Skin startup */
      $skinfunc =& $this->include_skinfunc('CORE_SkinFunc');
      extract($skinfunc->startup()); ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />

<meta name="generator" content="Kryptronic Software" />

<meta name="keywords" content="<?php print $metakeywords; ?>" />

<meta name="description" content="<?php print $metadesc; ?>" />

<?php /* PHP FUNCTION: rints the robots tag */ 
$skinfunc->robotstag(); ?>

<base href="<?php print $disp_baseurl; ?>" />

<link rel="stylesheet" type="text/css" media="all" href="skins/YOUR_SKIN_NAME_HERE/css/all.css" />

<?php /* PHP FUNCTION: Prints JavaScript Library code */ 
$skinfunc->namespace('core','jslib'); ?>

<title><?php print $metatitle; ?></title>

</head>

<body>

<?php 

$usergroup = $this->globals('core_users.usergroup');

if ($usergroup == 'superuser' || $usergroup == 'admin' || $usergroup == 'reports') {

          /* print HTML below for backend users. */

          ?>

<div id="skin_wrapper_full"><div id="skin_wrapper">


</div>

          <?php 

} elseif ($usergroup == 'wholesale' || $usergroup == 'affiliates') {

          /* print HTML below for wholesale and affiliate account users. */

          ?>

<div id="skin_wrapper_full"><div id="skin_wrapper">


</div>

          <?php 

} elseif ($usergroup == 'users') {

          /* print HTML below for regular basic user accounts. */

          ?>

<div id="skin_wrapper_full"><div id="skin_wrapper">


</div>

          <?php 

} else {

          /* print HTML below for users who are not logged in. */

          ?>

<div id="skin_wrapper_full"><div id="skin_wrapper">


</div>

          <?php 

} /* End of if statement.. */

/* PHP FUNCTION: Run the debug and closure function. */
$skinfunc->debug(); 

?>

</body>

</html>

Nick Hendler

Offline

 

#8 07-24-2009 13:25:21

osussat
Member
Registered: 04-16-2005
Posts: 128

Re: Skin by User / User Group

Brilliant!  Thank you both, you are complete stars!  I'll make a start and let you know how I get on smile
For the staff, I'd really like to display the product price in an editable box so that it can be altered before adding to the shopping cart...In CCP5 that was easily doable...is this still so in v7?

Offline

 

#9 07-24-2009 13:36:24

dh783
Member
From: Avondale, Arizona
Registered: 04-06-2005
Posts: 6233
Website

Re: Skin by User / User Group

The price of items in the cart are check several time between the cart and the checkout screens to make sure they are the prices set in the database for what ever sales type so in the stock ccp code it is not possible to edit the price on the fly. Remote items do not get the same checks so a custom mod to change the status of an item to "REMOTE-item_id" would keep the price entered but as I said would take some custom code to do so.

John

Offline

 

#10 07-24-2009 13:53:30

osussat
Member
Registered: 04-16-2005
Posts: 128

Re: Skin by User / User Group

Thanks John, it seems things have come on quite a bit from version 5 (which, of course, is great to see!).
Until I get my head around all of this, perhaps I've spotted another way around...I could create a product that was only visible to people in the STAFF usergroup and then in the Products section create a product of nil value and various product options hanging off of it with various negative price impacts....
That way, there is still a way of staff 'discounting'...

Offline

 

#11 07-24-2009 13:59:30

osussat
Member
Registered: 04-16-2005
Posts: 128

Re: Skin by User / User Group

Oops, seems like CCP7 translates any product sub-zero in price to zero before adding it to the cart....DOH!

Offline

 

#12 07-24-2009 14:09:05

Dave
Member
Registered: 07-05-2003
Posts: 11233

Re: Skin by User / User Group

osussat wrote:

For the staff, I'd really like to display the product price in an editable box so that it can be altered before adding to the shopping cart...In CCP5 that was easily doable...is this still so in v7?

As John said, no it isn't.  The price is checked against the product table at several stages and if it's different it will be adjusted back to the value that is in the product file.

Offline

 

#13 07-24-2009 14:17:56

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Skin by User / User Group

You can have a zero price product and add to it.  Or you can start with a high priced product and subtract from it.  A product with a negative price could never be added to the cart because you'd go from having an online store to an online disbursement system.  Look into the remote product add to cart functionality.  That will let your users enter a price and will carry that (if it's positive) into checkout.


Nick Hendler

Offline

 

#14 07-24-2009 14:51:19

osussat
Member
Registered: 04-16-2005
Posts: 128

Re: Skin by User / User Group

Thanks Nick, I'll take a look at that...Or else, perhaps I'll implement a load of discount codes that the staff can use...that should work, right?

Offline

 

#15 07-24-2009 14:54:54

Dave
Member
Registered: 07-05-2003
Posts: 11233

Re: Skin by User / User Group

Yes, discount codes would work.  What exactly are you trying to accomplish?

Offline

 

#16 07-24-2009 14:56:00

osussat
Member
Registered: 04-16-2005
Posts: 128

Re: Skin by User / User Group

I'd to all intents and purposes like to make our staff and consumer selling mechanism one entity (ie the website, run off CCP) , with the one difference being that staff can see more product information and can also discount items.

Offline

 

#17 07-24-2009 14:58:52

Dave
Member
Registered: 07-05-2003
Posts: 11233

Re: Skin by User / User Group

In that case discount codes probably offer you more control and accountability.  If you have staff entering orders on behalf of customers you might be interested in the .

Offline

 

#18 07-25-2009 06:11:10

osussat
Member
Registered: 04-16-2005
Posts: 128

Re: Skin by User / User Group

Hi guys
I'm having a little bit of trouble with the mod Dave/Nick suggested.
My product display is now as follows:

Code:

<?php 

// +--
// | Get variables we need to draw this display.
// +--

$ns       = $this->globals('core.namespace');
$eol      = $this->globals('core.eol');
$proddisp = $this->globals('ecom.prod_proddetail');
$xid      = $proddisp['id'];
$id       = $this->xhtml_encode($xid);

// +--
// | New Variable Get.
// +--

$usergroup = $this->globals('core_users.usergroup');



if ($ns == 'addcart') {$ns = 'prodshow';}

$this->globals('ecom.prod_proddisp',$proddisp);
$this->globals('ecom.prod_priceinfo',$proddisp['core.priceinfo']);

// +--
// | Create the product name and description.
// +--

$prodname  = $this->xhtml_encode($proddisp['name']);
$proddesc  = $proddisp['desclong'];
$desc_has_tags = $this->has_tags($proddesc);

if (empty($proddesc)) {

     $proddesc       = $proddisp['descshort'];
     $desc_has_tags  = 0;

} // End of if statement.

if (empty($desc_has_tags)) {$proddesc = '<p>' . $this->xhtml_encode($proddesc) . '</p>';}

// +--
// | Create the image tag(s).
// +--

$imglist  = $proddisp['imglg'];

if (empty($imglist)) {$imglist = 'none.png';}

$imglist  = $this->make_list($imglist);
$imgwidth = $this->globals('core_settings.ecom.imgsizeprodlg');
$imgtag   = '';

if (empty($imgwidth)) {$imgwidth = 200;}

foreach ($imglist as $num => $img) {

     $imgurl   = 'media/ecom/prodlg/' . $img;

     $imgtag   .= '<img src="' . $imgurl . '" ';
     if ($imgwidth) {$imgtag .= 'width="' . $imgwidth . '" ';}
     $imgtag  .= 'alt="' . $prodname . '" />';

} // End of foreach statement.

// +--
// | Handle extra large image.
// +--

$showxl  = 0;

$imglist = $proddisp['imgxl'];

if (empty($imglist)) {$imglist = 'none.png';}

if (($imglist) && ($imglist != 'none.png') && ($ns == 'prodshow')) {

     $this->globals('core.load_slimbox',1);

     $showxl   = 1;
     $xlcount  = 0;
     $xlimgtag = '';
     $zlcount  = count($imglist);

     $imglist  = $this->make_list($imglist);

     if (count($imglist) == 1) {$text = 'View Larger Image';}
     else                      {$text = 'View Larger Image Slideshow';}

     foreach ($imglist as $num => $img) {

          $xlcount++;

          $xlurl  = $this->globals('core.url_nonssl');
          $xlurl .= '/media/ecom/prodxl/' . $img;

          if ($xlcount == 1) {

               $xlimgtag .= '<p><a href="' . $xlurl . '" rel="slimbox[prodgroup]" title="';
               $xlimgtag .= $prodname . '" class="hrefbutton">' . $text . '</a></p>';

          } else {

               $xlimgtag .= '<p class="hidden"><a href="' . $xlurl . '" rel="slimbox[prodgroup]" title="';
               $xlimgtag .= $prodname . '" class="hrefbutton">' . $text . '</a></p>';

          } // End of if statement.

     } // End of foreach statement.

} // End of if statement.

// +--
// | Print the display.
// +--

?>

<table id="proddetail--<?php print $id; ?>" class="cptbl_det">

<tr class="cptbl_det"><td class="cptbl_det">

<table class="ghost"><tr><td class="ghost" style="width: <?php print $imgwidth; ?>px">

<?php print $imgtag; ?>

<?php 

// +--
// | Handle the extra large image tag and email a friend link.
// +--

$emailfr = $this->globals('core_settings.ecom.emailfriend');

if ($ns != 'prodshow') {$emailfr = 0;}

if (($showxl) || ($emailfr)) {

     print '<div style="width:' . $imgwidth . 'px">' . $eol;

     if ($showxl) {print $xlimgtag;}

     if ($emailfr) {

          $link_emailf = $this->link_namespace('ecom','emailfriend',array('ref' => $proddisp['id']));

          print '<p><a href="' . $link_emailf . '" title="Email a Friend" ';
          print 'class="hrefbutton">Email This Item to a Friend</a></p>';

     } // End of if statement.

     print '</div>' . $eol;

} // End of if statement.

?>

</td><td class="ghost">

<p><strong><?php print $prodname; ?></strong></p>

<?php print $proddesc; ?>

<?php $this->include_file('ecom','pricedisp.php'); ?>

</td></tr>

</table>

</td></tr></table>



// +--
// | Check the user type and display something if there is a match.
// +--

<?php 


if ($usergroup == 'superuser' || $usergroup == 'admin' || $usergroup == 'staff') {

  print 'THIS IS WORKING';

}

?>




<?php 

// +--
// | Print the product options if we can add the item to the 
// | shopping cart or wish list and we're on the prodshow
// | namespace.
// +--

$add_ok = 1;

if (($proddisp['useinv']) && (!($proddisp['invlevel'] > 0))) {$add_ok = 0;}
if ($proddisp['pricestatus'] == 'D') {$add_ok = 0;}

if (($ns == 'prodshow') && ($add_ok)) {

     $this->include_namespace('ecom','prodshowopt',array());

} // End of if statement.

if (($ns == 'prodshow') && ($add_ok)) {

     $this->globals('xmodshipestimator_prodid',$xid);
     $this->include_namespace('ecom','xmodshipestimator');

} // End of if statement.

?>

Note the two changes highlighted...No matter if I'm logged in as admin or otherwise, the change doesn't take effect.

Any ideas gang?

Oli

Last edited by osussat (07-25-2009 06:12:55)

Offline

 

#19 07-25-2009 06:12:12

Dave
Member
Registered: 07-05-2003
Posts: 11233

Re: Skin by User / User Group

There's no bold since you (correctly) enclosed the code with code tags so it's really difficult to see what you modified.

Offline

 

#20 07-25-2009 06:13:15

osussat
Member
Registered: 04-16-2005
Posts: 128

Re: Skin by User / User Group

Sorry Dave, I'm a dufus! smile
I've re-edited

Offline

 

#21 07-25-2009 06:19:51

Dave
Member
Registered: 07-05-2003
Posts: 11233

Re: Skin by User / User Group

You're retrieving the wrong global variable. The user group global variable name is .

BTW, when you use code tags no highlighting or coloring works.

Offline

 

#22 07-25-2009 06:21:08

osussat
Member
Registered: 04-16-2005
Posts: 128

Re: Skin by User / User Group

CHAMPION! smile Thanks Dave!

Offline

 

#23 07-25-2009 07:52:57

osussat
Member
Registered: 04-16-2005
Posts: 128

Re: Skin by User / User Group

If I wanted to make a similar change with regards to product option displays as opposed to main product displays, where would I go about finding the relevant codes?
Oli

Offline

 

#24 07-25-2009 18:47:40

Dave
Member
Registered: 07-05-2003
Posts: 11233

Re: Skin by User / User Group

Options are displayed from within the product detail display.  Look near the end of what you posted.

Code:

$this->include_namespace('ecom','prodshowopt',array());

Offline

 

#25 07-26-2009 05:51:34

osussat
Member
Registered: 04-16-2005
Posts: 128

Re: Skin by User / User Group

Perhaps I'm being silly buy I just can't find where to edit how the options display...The prodshowopt namespace screen doesn't give much away...

Offline

 

Board footer