Page 8 of 8

Re: [HACK] Login for price

Posted: Tue Feb 28, 2012 12:53 am
by catalinux
I finally managed to do it. I manually removed the bottom add to cart button. As for the quantities and prices shown on search page results I simply hide them by unticking Settings - Store Settings - Display - Yes, show the "Add to Cart" link in all the small product boxes option.
I hope this helps anyone.
Now I still have problems with email sending once I approve the customer and add it to Approved Customer Group.
I did the modifications in Admin/includes/classes/class.customers.php at line 2895 but it's not working :(
Any help ?

Re: [HACK] Login for price

Posted: Fri Jun 22, 2012 9:01 am
by softwaremaster
I tried to test this coding with Interspire Version 6.1.1 but i removed variations only, no prices removed and even after loging in no add to card button found. Is any further modifications required for version 6.1.1?

Will appreciate if anyone tested with latest version?

Thanks!

SM
meules wrote: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.

Re: [HACK] Login for price

Posted: Fri Aug 24, 2012 11:43 am
by Aileefaria
Thank you for fantastic posting. Where else could anyone get that kind of information in such a perfect way of writing and i was looking for more info.

Re: [HACK] Login for price

Posted: Mon Oct 29, 2012 2:32 pm
by emediaukcom
Hi - im so glad i found this post, exactly what i needed

Followed the mods above which all work but below the prompt for the hidden price it puts the add to cart button which is empty

any ideas where i need to change it so it sets the display mode to none for the button

doing it in the admin panel 'hide from all small product boxes' works but i need it showing for someone who is approved

cheers
mike