[HACK] Login for price

Modules, Add-ons and custom code that's more than just a quick hack or Mod.
KevinPebbleLTD
Posts: 4
Joined: Tue Oct 12, 2010 9:17 am
Location: England

Re: [HACK] Login for price

Post by KevinPebbleLTD »

Hey I'm having problems with version 6.0.14 .
I can get the code to work on the home page but the product details page doesn't work and neither does the remove add to cart button.
I can find the code in the file as per the examples.

Any help or pointers would be greatly appreciated.

Thanks.
meules
Confirmed
Confirmed
Posts: 95
Joined: Wed Jun 17, 2009 8:56 pm
Location: NL

Re: [HACK] Login for price

Post by meules »

I'm still working on this... I'll get back to you asap
ISC v6
KevinPebbleLTD
Posts: 4
Joined: Tue Oct 12, 2010 9:17 am
Location: England

Re: [HACK] Login for price

Post by KevinPebbleLTD »

:D Ok great thanks :)
I'll keep having a look too and let you know.

Keep me posted :)
nella
Posts: 2
Joined: Wed Oct 20, 2010 1:46 am
Location: Australia

Re: [HACK] Login for price

Post by nella »

Hi Meules,

Have you had any success with the hack for Shopping Cart version 6.0.14?

Similar to KevinPebble, we are trying to setup the following scenario on Interspire Shopping Cart:

1) Retail customers can see products but not pricing, must see 'Login for Pricing' link/Approved Wholesellers can see products, pricing and place an order.

2) When a new customer signs up he/she must be approved by an ADMIN first before they view pricing and can order. After he/she signs up and prior to approval, the pricing will show something like 'Waitng for Approval' or similar.

I tried using the snippets of code in the forum but unfornuately it only half works and the retail customer can still order as they see 0.00 but the Buy Button is present. This also doesn't address the 'wholesaler needs to be approved' issue.
meules
Confirmed
Confirmed
Posts: 95
Joined: Wed Jun 17, 2009 8:56 pm
Location: NL

Re: [HACK] Login for price

Post by meules »

That's exactly what this mod does :D . But I'm still working on the product pages where indeed the buy buttons still appear. I can't figure out why the code doesn't work for v6... but I keep trying, until then you have to be patient ;)
ISC v6
dwrs
Posts: 16
Joined: Wed Feb 03, 2010 5:30 pm

Re: [HACK] Login for price

Post by dwrs »

Hi

I'm using your hack for this module and thank you very much for your efforts.
I want to ask you something this is working but for example i m a new user and cant see the price it s right but when I click a category ,I saw top right filter dropdown box. and filter price asc or desc. I'm a wholeseller and some resellers can filter and can guess my min & max price of my products .Is there anyway to dı login for price and filter ?
This problem's very annoying me :cry:
Thank you.

EDİT : and also how can I hide this SideCategoryShopByPrice side panel to guests ,I just want to show this for approved resellers ?

Code: Select all


<div class="Block ShopByPrice Moveable Panel" id="SideCategoryShopByPrice" style="display:%%GLOBAL_HideSideCategoryShopByPricePanel%%">
<h2>%%LNG_ShopByPrice%%</h2>
<div class="BlockContent">
<ul>
%%SNIPPET_SideCategoryShopByPrice%%
</ul>
</div>
</div>

meules
Confirmed
Confirmed
Posts: 95
Joined: Wed Jun 17, 2009 8:56 pm
Location: NL

Re: [HACK] Login for price

Post by meules »

Ok, finally I found a solution for V6. Basically the steps are the same but some of the code was changed and moved to different files. I've added all the necessary steps in this post.

STEP 1:
In includes\display\ProductDetails.php around line 70 find

Code: Select all

$this->SetMinMaxQty();
Add after

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#############
STEP 2:
In \lib\Pricing.php find around line 19

Code: Select all

function formatProductCatalogPrice($product, array $options = array())
{
	$displayFormat = getConfig('taxDefaultTaxDisplayCatalog');
	$options['displayInclusive'] = $displayFormat;

	if($displayFormat != TAX_PRICES_DISPLAY_BOTH) {
		return formatProductPrice($product, $product['prodcalculatedprice'], $options);
	}
Replace with:

Code: Select all

function formatProductCatalogPrice($product, array $options = array())
{
   ###### 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'); 
   $customer = $customerClass->GetCustomerInfo();
   if(isset($customer['custgroupid'])) { 
   $groupId = $customer['custgroupid']; 
   }
   if($customer['custgroupid'] == 0) { 
   return '<a href="#">waiting for verification</a>'; //
   }
   
   ###### LOGIN FOR PRICE HACK EOF#############
	$displayFormat = getConfig('taxDefaultTaxDisplayCatalog');
	$options['displayInclusive'] = $displayFormat;

	if($displayFormat != TAX_PRICES_DISPLAY_BOTH) {
		return formatProductPrice($product, $product['prodcalculatedprice'], $options);
	}
A little further around line 75 find

Code: Select all

function formatProductDetailsPrice($product, array $options = array())
{
	$displayFormat = getConfig('taxDefaultTaxDisplayProducts');
	$options['displayInclusive'] = $displayFormat;

	if($displayFormat != TAX_PRICES_DISPLAY_BOTH) {
		return formatProductPrice($product, $product['prodcalculatedprice'], $options);
	}
Replace with

Code: Select all

function formatProductDetailsPrice($product, array $options = array())
{
   ###### 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#############
   
	$displayFormat = getConfig('taxDefaultTaxDisplayProducts');
	$options['displayInclusive'] = $displayFormat;

	if($displayFormat != TAX_PRICES_DISPLAY_BOTH) {
		return formatProductPrice($product, $product['prodcalculatedprice'], $options);
	}
STEP 3:
We need to hide the "add to cart" button in all panels for people who are not logged in or are approved by the store owner.
in lib\templates\products_panel.php find around line 94:

Code: Select all

if (isId($row['prodvariationid']) || trim($row['prodconfigfields'])!='' || $row['prodeventdaterequired'] == 1) {
			$GLOBALS['ProductURL'] = ProdLink($row['prodname']);
			$GLOBALS['ProductAddText'] = GetLang('ProductChooseOptionLink');
		} else {
			$GLOBALS['ProductURL'] = CartLink($row['productid']);
			if ($GLOBALS['ProductPreOrder']) {
				$GLOBALS['ProductAddText'] = GetLang('ProductPreOrderCartLink');
			} else {
				$GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink');
			}
		}
Replace with

Code: Select all

		  $customerClass = GetClass('ISC_CUSTOMER');
		  $groupId = 0;
		  $customer = $customerClass->GetCustomerInfo();
		  if(isset($customer['custgroupid'])) {
			  $groupId = $customer['custgroupid'];
		   }
		  if(!$customerClass->GetCustomerId()) {
			 $GLOBALS['HideActionAdd'] = 'none';
		  } elseif($customer['custgroupid'] == 0) {
			 $GLOBALS['HideActionAdd'] = 'none';
		  }
		  else {
		if (isId($row['prodvariationid']) || trim($row['prodconfigfields'])!='' || $row['prodeventdaterequired'] == 1) {
			$GLOBALS['ProductURL'] = ProdLink($row['prodname']);
			$GLOBALS['ProductAddText'] = GetLang('ProductChooseOptionLink');
		} else {
			$GLOBALS['ProductURL'] = CartLink($row['productid']);
			if ($GLOBALS['ProductPreOrder']) {
				$GLOBALS['ProductAddText'] = GetLang('ProductPreOrderCartLink');
			} else {
				$GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink');
			}
		}
	}
STEP 4:

In your admin panel create 3 customer groups. For example:
group 1: Accepted
group 2: With discount
group 3: Foreign

STEP 5 [OPTIONAL]
First of all credits go to Painstik who made this nice little addition.
If you want to send an (automatic) email to your customers, who you just have approved, we need to set up some things. Here we go...

1. First create a new html file in templates/__emails and name it verified_account.html
Add this in that file:

Code: Select all

<html><body style="font-family:Arial; font-size:12px">
   <div style="padding:0px 20px 20px 20px">
      <h2 style="font-size:22px; height:30px; color:#cc6600; border-bottom:dashed 1px gray">%%LNG_ThanksForRegisteringAt%% %%GLOBAL_StoreName%%</h2>

      <p>%%LNG_Hi%% %%GLOBAL_FirstName%%,</p>

      <p>%%LNG_YourAccountIsVerified%%</a>

      <p>%%LNG_ThanksForRegisteringEmailLogin%%</a>

      <p>%%LNG_ThanksForRegisteringAtIntro%%</p>      

      %%GLOBAL_EmailFooter%%
   </div>
</body></html>
2. Open: language/admin/customers.ini
Add this:

Code: Select all

YourAccountIsVerifiedIntro = "Your account is verified."
YourAccountIsVerified = "You account is verified blabla (text within content)."
ThanksForRegisteringAtIntro = "Thank you for registering on our site bla bla bla"
ThanksForRegisteringEmailLogin = "For login on your account please visit <a href='%s'>%s</a> or <a href='%s'>click here</a>."
3. Open: admin/includes/classes/class.customers.php
Find around line 2862

Code: Select all

if (gzte11(ISC_MEDIUMPRINT)) {
            $existingCustomer = $this->customerEntity->get($customerId);
            if (isId($existingCustomer['custformsessionid'])) {
               $GLOBALS['ISC_CLASS_FORM']->saveFormSession(FORMFIELDS_FORM_ACCOUNT, true, $existingCustomer['custformsessionid']);
            } else {
               $formSessionId = $GLOBALS['ISC_CLASS_FORM']->saveFormSession(FORMFIELDS_FORM_ACCOUNT);
               if (isId($formSessionId)) {
                  $StoreCustomer['custformsessionid'] = $formSessionId;
               }
            }
         }
Add before:

Code: Select all

    $GLOBALS['FirstName'] = isc_html_escape($StoreCustomer['firstname']);
             $GLOBALS['ISC_LANG']['ThanksForRegisteringEmailLogin'] = sprintf(GetLang('ThanksForRegisteringEmailLogin'), $GLOBALS['ShopPathSSL']."/account.php", $GLOBALS['ShopPathSSL']."/account.php", $GLOBALS['ShopPathSSL']."/account.php");
             
             if ($StoreCustomer['customergroupid']) {
                $store_name = GetConfig('StoreName');
                $subject = GetLang('YourAccountIsVerifiedIntro');

                $emailTemplate = FetchEmailTemplateParser();
                $emailTemplate->SetTemplate("verified_account");
                $message = $emailTemplate->ParseTemplate(true);

                require_once(ISC_BASE_PATH . "/lib/email.php");
                $obj_email = GetEmailClass();
                $obj_email->Set('CharSet', GetConfig('CharacterSet'));
                $obj_email->From(GetConfig('OrderEmail'), $store_name);
                $obj_email->Set("Subject", $subject);
                $obj_email->AddBody("html", $message);
                $obj_email->AddRecipient($StoreCustomer['email'], "", "h");
                $email_result = $obj_email->Send();            
             }
Important note!!
The email is only send when you update the customer group in the edit panel for a customer. Go to the new signed up customer --> click "edit" --> update customer group and then hit "Save & Exit".
It doesn't work when you change customers group from customers grid at the dropdown menu.
Last edited by meules on Tue Oct 26, 2010 10:34 pm, edited 1 time in total.
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 »

@dwrs

I will try to make such addition to this mod.
ISC v6
KevinPebbleLTD
Posts: 4
Joined: Tue Oct 12, 2010 9:17 am
Location: England

Re: [HACK] Login for price

Post by KevinPebbleLTD »

Hey thats great thanks.

I have a slight problem though.

When you view a product it shows the price:
http://foodmakerdirect.co.uk/products.p ... n-Stuffing

Everywhere else it seems to be hidden like its suppose to be :)

great work on finding the fix :)
meules
Confirmed
Confirmed
Posts: 95
Joined: Wed Jun 17, 2009 8:56 pm
Location: NL

Re: [HACK] Login for price

Post by meules »

I forgot to mention something in my previous post. Post is already edited.
What you have to do is
In /lib/pricing.php

Around line 75 find

Code: Select all

    function formatProductDetailsPrice($product, array $options = array())
    {
       $displayFormat = getConfig('taxDefaultTaxDisplayProducts');
       $options['displayInclusive'] = $displayFormat;

       if($displayFormat != TAX_PRICES_DISPLAY_BOTH) {
          return formatProductPrice($product, $product['prodcalculatedprice'], $options);
       }
replace with

Code: Select all

    function formatProductCatalogPrice($product, array $options = array())
    {
       ###### 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');
       $customer = $customerClass->GetCustomerInfo();
       if(isset($customer['custgroupid'])) {
       $groupId = $customer['custgroupid'];
       }
       if($customer['custgroupid'] == 0) {
       return '<a href="#">waiting for verification</a>'; //
       }
       
       ###### LOGIN FOR PRICE HACK EOF#############
       $displayFormat = getConfig('taxDefaultTaxDisplayCatalog');
       $options['displayInclusive'] = $displayFormat;

       if($displayFormat != TAX_PRICES_DISPLAY_BOTH) {
          return formatProductPrice($product, $product['prodcalculatedprice'], $options);
       }
Now it should work fine. Please let me know.

Cheers
ISC v6
Post Reply