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 03-30-2010 17:32:39

NicheDev
Member
Registered: 02-04-2009
Posts: 152

Restrict access to pricing

Hi guys

I want to restrict visitor access to product prices, because it's a trade-only site. I don't mind everyone seeing the site, products etc., but I only want trade customers to see prices by logging in with a username and password which are unique to each trade customer.

I've looked everywhere but can't see where to implement this.

Help would be much appreciated...

Kind regards
Paul

Offline

 

#2 03-30-2010 17:40:51

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

Re: Restrict access to pricing

The only way in the standard ccp setup to do this is to restrict all products you don't want any one to see to a certain user group other than the basic user account, since anyone hitting the site for the first time will be in the user group. This means that  you would have to manually move any customer you wanted to see the product/pricing from the group user into the specific group allowed to do so.

John

Offline

 

#3 03-30-2010 17:45:09

NicheDev
Member
Registered: 02-04-2009
Posts: 152

Re: Restrict access to pricing

Ok, so any visitor can create an account but it defaults to Basic. They can't see pricing until I move them to, say, the "Trade" group.
Simple.
Thanks, John!

Paul

P.S. Does that mean that if I set the products as viewable by only Trade users, they will not be visible by any casual visitor? Not quite what I want - I want anyone to see the whole site except prices. Only Trade users can see prices. Can that be done? I know there's a Wholesale Price field in the product record, but that doesn't allow volume pricing, which I do need.

Last edited by NicheDev (03-30-2010 17:48:37)

Offline

 

#4 03-30-2010 18:16:40

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

Re: Restrict access to pricing

If you want for everybody to see the items and you don't want to duplicate your products (one for basic users and another for trade), you would have to leave the items viewable by everybody and rap the price display call in the product detail and category views in an if statement like:

Code:

if ($this->globals('core_user.usergroup) == 'trade') {

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

} // end

this would not show prices and options, or rap the segments of the product price display, with the same if statement, from sale to the bottom to exclude the pricing but wholesale as it will already only show for wholesale customer. This would not show the price but will not exclude any options pricing. You would also have to make sure that anything you exclude doesn't mess up the html validation or break the html.

John

Last edited by dh783 (03-31-2010 16:27:06)

Offline

 

#5 03-31-2010 09:52:57

NicheDev
Member
Registered: 02-04-2009
Posts: 152

Re: Restrict access to pricing

Hi John
I sent you a PM, hope you don't mind  smile
Paul

Offline

 

#6 03-31-2010 12:44:34

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

Re: Restrict access to pricing

Paul,

If you want to do this in the product price display you just have to look for the else if statements like

Code:

 } elseif ($priceinfo['type'] == 'S') {

and change it to

Code:

 } elseif (($priceinfo['type'] == 'S') && ($this->globals('core_user.usergroup') == 'trade')) {

so there are four parts you need to change which are

Code:

     // +--
     // | Display sale prices.
     // +--

     } elseif ($priceinfo['type'] == 'S') {

     // +--
     // | Display regular prices.
     // +--

     } elseif ($priceinfo['type'] == 'R') {

     } elseif ($priceinfo['type'] == 'V') {

     // +--
     // | Display recurring prices.
     // +--

     if ($priceinfo['displayr']) {

by adding the requirement for the right user group like in the example above.

John

Last edited by dh783 (03-31-2010 16:26:47)

Offline

 

#7 03-31-2010 15:49:03

NicheDev
Member
Registered: 02-04-2009
Posts: 152

Re: Restrict access to pricing

Hi John

A big thank you for that. I see how it works. I changed the code in those 4 places in the Product Price Display include (and in the Wholesale section of then same file), and created two accounts - one in the trade usergroup, and one in the basic usergroup. Unfortunately the prices were hidden from both accounts.

The modified code is as follows:

Code:

Code:
<?php 

$eol       = $this->globals('core.eol');
$priceinfo = $this->globals('ecom.prod_priceinfo');
$proddisp  = $this->globals('ecom.prod_proddisp');

// +--
// | Only display valid prices.
// +--

if (!(empty($priceinfo['type']))) {

     // +--
     // | Display wholesale prices.
     // +--

     if (($priceinfo['type'] == 'W') && ($this->globals('core_users.usergroup') == 'trade')) {

          print '<div class="pricediv"><p class="inline">Retail: </p>';
          print '<p class="pricex">' . $this->xhtml_encode($priceinfo['displaybx']);
          print '</p></div>' . $eol . $eol;

          print '<div class="pricediv"><p class="inline">Wholesale: </p>';
          print '<p class="price">' . $this->xhtml_encode($priceinfo['displayb']);
          print '</p></div>' . $eol . $eol;

     // +--
     // | Display sale prices.
     // +--

     } elseif (($priceinfo['type'] == 'S') && ($this->globals('core_users.usergroup') == 'trade')) {

          print '<div class="pricediv"><p class="inline">Regularly: </p>';
          print '<p class="pricex">' . $this->xhtml_encode($priceinfo['displaybx']);
          print '</p></div>' . $eol . $eol;

          print '<div class="pricediv"><p class="inline">On Sale: </p>';
          print '<p class="price">' . $this->xhtml_encode($priceinfo['displayb']);
          print '</p></div>' . $eol . $eol;

     // +--
     // | Display regular prices.
     // +--

     } elseif (($priceinfo['type'] == 'R') && ($this->globals('core_users.usergroup') == 'trade')) {

          print '<div class="pricediv"><p class="inline">Price: </p>';
          print '<p class="price">' . $this->xhtml_encode($priceinfo['displayb']);
          print '</p></div>' . $eol . $eol;

     } elseif (($priceinfo['type'] == 'V') && ($this->globals('core_users.usergroup') == 'trade')) {

          $priceinfo['displayb'] = preg_replace('/\$/','\$',$priceinfo['displayb']);

          print '<div class="pricediv">';
          print $priceinfo['displayb'];
          print '</div>' . $eol . $eol;

     } // End of if statement.

     // +--
     // | Display recurring prices.
     // +--

     if (($priceinfo['displayr']) && ($this->globals('core_users.usergroup') == 'trade')) {

          print '<div class="pricediv"><p class="inline">Recurring Charge: </p>';
          print '<p class="price">' . $this->xhtml_encode($priceinfo['displayr']);
          print '</p></div>' . $eol . $eol;

     } // End of if statement.

} // End of if statement.

// +--
// | Display out of stock message if this item is out of stock.
// +--

if (($proddisp['useinv']) && (!($proddisp['invlevel'] > 0))) {

     print '<div class="pricediv"><p class="outstock">This item is currently out of stock.</p>';
     print '</div>' . $eol . $eol;

} // End of if statement.

?>

What did I do wrong?  :-)

Paul

Offline

 

#8 03-31-2010 16:25:40

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

Re: Restrict access to pricing

Sorry I messed up on the code, it should be

Code:

if (($priceinfo['type'] == 'W') && ($this->globals('core_user.usergroup') == 'trade')) {

I placed an "s" in core_user.usergroup which is not what it should be, so remove the s and it will work.

John

Offline

 

#9 03-31-2010 16:37:26

NicheDev
Member
Registered: 02-04-2009
Posts: 152

Re: Restrict access to pricing

No apology necessary, John, I'm grateful for your help.
Works a treat!

I guess I now do the same in the Shopping Cart and the Mini Cart...

Oh, and is there a switch somewhere to turn on a "You are / are not logged in" message on the site?

Regards
Paul

Offline

 

#10 03-31-2010 17:25:16

NicheDev
Member
Registered: 02-04-2009
Posts: 152

Re: Restrict access to pricing

For the mini-cart, I wrapped the  "skin widget mini shopping cart" display include, with:

Code:

if ($this->globals('core_user.usergroup') == 'trade'){

}

Seems to work...mini-cart appears on screen only for trade logins.

Did the same for the shopping cart include, seems to work ok.

I assume I won't have broken anything, since these are only display includes?

Paul

Last edited by NicheDev (03-31-2010 17:37:27)

Offline

 

Board footer