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
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.