[HACK] Login for price

Modules, Add-ons and custom code that's more than just a quick hack or Mod.
Post Reply
meules
Confirmed
Confirmed
Posts: 95
Joined: Wed Jun 17, 2009 8:56 pm
Location: NL

[HACK] Login for price

Post by meules »

Hi,

I used this hack for a B2B site. I wanted my customers to be approved before they can order anything, but give potential customers an idea what we have to offer. So what I needed was just this simple hack. It's quick and very easy to "install".

1.Open /LIB/PRICING.PHP
2.Find at the top of the file around line 21

Code: Select all

function CalculateProductPrice($product, $doLocaleFormat=true, $doCurrencyConvert=true, $strikeOutRetail=true)
{
	if (!GetConfig('ShowProductPrice') || $product['prodhideprice'] == 1) {
		return '';
	}

	$actualPrice = CalcRealPrice($product['prodprice'], $product['prodretailprice'], $product['prodsaleprice'], $product['prodistaxable']);
	$actualPrice = CalcProdCustomerGroupPrice($product, $actualPrice);
3. Replace this code with this code

Code: Select all

function CalculateProductPrice($product, $doLocaleFormat=true, $doCurrencyConvert=true, $strikeOutRetail=true)
{

	###### LOGIN FOR PRICE HACK BOF#############
	$customerClass = GetClass('ISC_CUSTOMER');
	if(!$customerClass->GetCustomerId()) {
	 return '<a href="%%GLOBAL_ShopPathNormal%%/login.php">Login voor prijs</a>';
	}  
	###### LOGIN FOR PRICE HACK EOF#############

	if (!GetConfig('ShowProductPrice') || $product['prodhideprice'] == 1) {
		return '';
	}

	$actualPrice = CalcRealPrice($product['prodprice'], $product['prodretailprice'], $product['prodsaleprice'], $product['prodistaxable']);
	$actualPrice = CalcProdCustomerGroupPrice($product, $actualPrice);
4. Open /INCLUDES/DISPLAY/RODUCTDETAILS.PHP
5. Find somewhere at the bottom around line 302

Code: Select all

	if(GetConfig('AddToCartButtonPosition') == 'middle' && $GLOBALS['ISC_CLASS_PRODUCT']->IsPurchasingAllowed()) {
	require_once ISC_BASE_PATH.'/includes/display/SideProductAddToCart.php';
	ISC_SIDEPRODUCTADDTOCART_PANEL::LoadAddToCartOptions('middle');
	$GLOBALS['SNIPPETS']['ProductAddToCart'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductAddToCart");
	}
6. Replace it with

Code: Select all

	###### LOGIN FOR PRICE HACK BOF#############
	$customerClass = GetClass('ISC_CUSTOMER');
	if(!$customerClass->GetCustomerId()) {
	return;
	}
	###### LOGIN FOR PRICE HACK EOF#############

	if(GetConfig('AddToCartButtonPosition') == 'middle' && $GLOBALS['ISC_CLASS_PRODUCT']->IsPurchasingAllowed()) {
	require_once ISC_BASE_PATH.'/includes/display/SideProductAddToCart.php';
	ISC_SIDEPRODUCTADDTOCART_PANEL::LoadAddToCartOptions('middle');
	$GLOBALS['SNIPPETS']['ProductAddToCart'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductAddToCart");
	}
I know this is probably not the best method but it works for me ;) Just wanted to share....

Regards,

Meules
Last edited by meules on Thu Jun 18, 2009 9:45 pm, edited 1 time in total.
Martin
Site Admin
Site Admin
Posts: 1854
Joined: Wed Jun 17, 2009 6:30 pm
Location: South Yorkshire UK
Contact:

Re: [HACK] Login for price

Post by Martin »

As a general rule it's better practice to provide a hack/mod like that using the format:

Open { filename }

Find { code }

After Add | Before Add | Replace with {code}

Use of line numbers as the anchor point tends to get messy if/when the original file gets upgraded or someone has already modified it.

That said, very useful little nugget... certainly simple enough :) Thanks.. :idea:
The Impossible can be on your desk by lunchtime, Miracles will take a little longer
SnailSolution Interspire Mods/Hacks store
meules
Confirmed
Confirmed
Posts: 95
Joined: Wed Jun 17, 2009 8:56 pm
Location: NL

Re: [HACK] Login for price

Post by meules »

Yeah that's right... I guess I was a bit lazy there :D I shall update that post.
ISC v6
meules
Confirmed
Confirmed
Posts: 95
Joined: Wed Jun 17, 2009 8:56 pm
Location: NL

Re: [HACK] Login for price

Post by meules »

meules wrote:Yeah that's right... I guess I was a bit lazy there :D I shall update that post.
Post updated ;)
ISC v6
Martin
Site Admin
Site Admin
Posts: 1854
Joined: Wed Jun 17, 2009 6:30 pm
Location: South Yorkshire UK
Contact:

Re: [HACK] Login for price

Post by Martin »

meules wrote:
meules wrote:Yeah that's right... I guess I was a bit lazy there :D I shall update that post.
Post updated ;)
Excellent... many thanks :)
empirehorn
Confirmed
Confirmed
Posts: 9
Joined: Sun Jul 26, 2009 9:02 pm

Re: [HACK] Login for price

Post by empirehorn »

Is there a relatively easy way to incorporate this to where it will only require you to login to see the price for certain items, possibly flagged by the call for price field? I've been mulling it over and it seems like with another line of code to check that field would make this possible. Any help would be appreciated.
empirehorn
Confirmed
Confirmed
Posts: 9
Joined: Sun Jul 26, 2009 9:02 pm

Re: [HACK] Login for price

Post by empirehorn »

It seems after some research that inserting a new field into the database would be the best option, as the call for price field would do other things if triggered. Does anybody know where I would need to insert code to call up another field in the database, and then how to use that?
meules
Confirmed
Confirmed
Posts: 95
Joined: Wed Jun 17, 2009 8:56 pm
Location: NL

Re: [HACK] Login for price

Post by meules »

Ok, a slight modification and an update for ISC 5.0.6
A customer is added to a 'default group' when he/she signs up with the shop. If a customer is a "guest", prices show up as "login for price". Problem with this was when a customer signs up, the customer is placed in a different customer group and I had to disable the shop functionality for that specific group
E.g:

Group: Default (used for guest customers)
Group 1: Waiting for verification
Group 2: Customer verified
Group 3: Customer with discount

What is happening with previous code was..... A guest is watching your site (default group) He/she is interested in buying some products. He/she is signing up with your shop. By default the "new" customer is placed in a different customer group. In my case "waiting for verification". Problem with the previous code was that I had to disable the complete shopping functionality for the group "Waiting for verification". This was a bit odd when a customer signs up. First he/she could see the all my products and when the customer signs up all products would disappear. Goal was to show up "waiting for verification" instead of the real prices or diable the shopping functionality. I know this sounds a bit weird/odd but people who using the code know what I'm talking about. Well here's a fix to determine in which group the customer is.

In /lib/pricing.php find around line 18

Code: Select all

function CalculateProductPrice($product, $doLocaleFormat=true, $doCurrencyConvert=true, $strikeOutRetail=true)
{
After that add

Code: Select all

	###### LOGIN FOR PRICE HACK BOF#############
	$customerClass = GetClass('ISC_CUSTOMER');
	if(!$customerClass->GetCustomerId()) {
	 return '<a href="%%GLOBAL_ShopPathNormal%%/login.php">Login voor prijs</a>';
	}  
	$groupId = 0;
	$customerClass = GetClass('ISC_CUSTOMER'); // get customer class
	$customer = $customerClass->GetCustomerInfo();
	if(isset($customer['custgroupid'])) { // which group?
	$groupId = $customer['custgroupid']; // Oh, that group
	} 
	if($customer['custgroupid'] == 0) { // If customer is in the default group return message, 0 = default group, 1 = waiting for verification etc
	return 'waiting for verification'; // 
	}
	
	###### LOGIN FOR PRICE HACK EOF#############
In /includes/display/productDetails.php find around line 73:

Code: Select all

$GLOBALS['SNIPPETS']['ProductAddToCart'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductAddToCart");
BEFORE add

Code: Select all

			###### LOGIN FOR PRICE HACK BOF#############
			$customerClass = GetClass('ISC_CUSTOMER');
			if(!$customerClass->GetCustomerId()) {
			return;
			}
			$groupId = 0;
			$customerClass = GetClass('ISC_CUSTOMER');
			$customer = $customerClass->GetCustomerInfo();
			if(isset($customer['custgroupid'])) {
			$groupId = $customer['custgroupid'];
			} 
			if($customer['custgroupid'] == 0) {
			return;
			}
			###### LOGIN FOR PRICE HACK EOF#############
The code is an update for ISC v5.0.6. So for either the "login for price" or both the login for price and "check customer group"!!
Please feel free to ask questions or when things aren't clear (because of vage description, it was a long night :evil: ) mail me or PM me or whatever....

Cheers,

Meules
ISC v6
Crisper
Posts: 12
Joined: Thu Oct 22, 2009 6:24 pm

Re: [HACK] Login for price

Post by Crisper »

This is great. Does exactly what I want it to do.

Is there a quick easy way to make it so the customer returns to the product page they were on after they log in? Right now it goes to their Account page.
Painstik
Posts: 122
Joined: Sun Jul 19, 2009 1:19 pm
Location: Croatia

Re: [HACK] Login for price

Post by Painstik »

I can say from experience that login for price is very very bad idea, it's a turn off for customers.

Me first, I don't go trough registration if I don't see prices, why should I bother if vendor is forcing me to register and to give my personal data if I only want to see products and prices. You are giving bad messages to customers who have first contact with you.

How would you feel like if you go to market, and in front of the entrance is a bodyguard who takes your ID and all your data that you can see prices? :shock:


Just my opinion...
Need custom coding for Interspire Shopping Cart? Contact me
Post Reply