Showing posts with label Wholesale customer approve by admin module magento. Show all posts
Showing posts with label Wholesale customer approve by admin module magento. Show all posts

Monday, 17 October 2016

Register Customer approve by admin for wholesale user group magento


Register Customer approve by admin for wholesale user group magento

To Enable the Require Emails Confirmation, Go to system->configuration->Customer configuration open Create New Account Options section


Open register.phtml and put the below line before the submit button for assign wholesale group.

<input type="hidden" name="group_id" id="group_id" value="2" />

Now open \app\code\core\Mage\Customer\controllers\AccountController.php

Change $message variable like below in loginPostAction() function

$message = $this->_getHelper('customer')->__('This account is not approved. You will receive an email with confirmation once your account is approved by admin.');

Change in createPostAction() function

Find $errUrl = $this->_getUrl('*/*/login', array('_secure' => true));

and replace as below

    if($this->getRequest()->getPost('group_id') == 2){
        $errUrl = $this->_getUrl('*/*/create?register=wholesale', array('_secure' => true));
    }else{
        $errUrl = $this->_getUrl('*/*/login', array('_secure' => true));
    }

Now Replace _successProcessRegistration() function as below  
   
    protected function _successProcessRegistration(Mage_Customer_Model_Customer $customer)
    {
        $session = $this->_getSession();
/* Code By Chand */
        if ($customer->isConfirmationRequired() && $this->getRequest()->getPost('group_id') == 2) {
            /** @var $app Mage_Core_Model_App */
            $app = $this->_getApp();
            /** @var $store  Mage_Core_Model_Store*/
            $store = $app->getStore();
            $customer->sendNewAccountEmail(
                'confirmation',
                $session->getBeforeAuthUrl(),
                $store->getId()
            );
            $customerHelper = $this->_getHelper('customer');
            $session->addSuccess($this->__('Thank you for registering with us. Your account is under moderation and will be approved by admin soon.',
/* End Code By Chand */  
                $customerHelper->getEmailConfirmationUrl($customer->getEmail())));
            $url = $this->_getUrl('*/*/index', array('_secure' => true));
        } else {
            $session->setCustomerAsLoggedIn($customer);
            $url = $this->_welcomeCustomer($customer);
        }
        $this->_redirectSuccess($url);
        return $this;
    }

In _getCustomer() function replace line $customer->getGroupId(); as below

if($this->getRequest()->getPost('group_id')){
       $customer->setGroupId($this->getRequest()->getPost('group_id'));
}else{
$customer->getGroupId();
}


Now open \app\code\core\Mage\Customer\Model\Customer.php and replace isConfirmationRequired() function as below

    public function isConfirmationRequired()
    {
        if ($this->canSkipConfirmation()) {
            return false;
        }
/* Code By Chand */
        if (self::$_isConfirmationRequired === null && $this->getGroupId() == 2) {
            $storeId = $this->getStoreId() ? $this->getStoreId() : null;
            self::$_isConfirmationRequired = (bool)Mage::getStoreConfig(self::XML_PATH_IS_CONFIRM, $storeId);
        }
/* End Code By Chand */
        return self::$_isConfirmationRequired;
    }


Go to magento admin panel open transactional Emails in system. Open New account confirmation key template and paste below code:

    {{template config_path="design/email/header"}}
    {{inlinecss file="email-inline.css"}}
   
    <table cellpadding="0" cellspacing="0" border="0">
        <tr>
            <td>
                <table cellpadding="0" cellspacing="0" border="0">
                    <tr>
                        <td class="action-content">
                            <h1>{{htmlescape var=$customer.name}},</h1>
                            <p>Thank you for registering with us. Your account is under moderation and will be approved by admin soon.</p>
                            <p class="highlighted-text">
                                Use the following values when prompted to log in:<br/>
                                <strong>Email:</strong> {{var customer.email}}<br/>
                                <strong>Password:</strong> {{htmlescape var=$customer.password}}
                            </p>
                            <p>
                                If you have any questions, please feel free to contact us at
                                <a href="mailto:{{var store_email}}">{{var store_email}}</a>
                                {{depend store_phone}} or by phone at <a href="tel:{{var phone}}">{{var store_phone}}</a>{{/depend}}.
                            </p>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
   
    {{template config_path="design/email/footer"}}


Open New account confirmed template and paste below code:

    {{template config_path="design/email/header"}}
    {{inlinecss file="email-inline.css"}}
   
    <table cellpadding="0" cellspacing="0" border="0">
        <tr>
            <td class="action-content">
                <h1>{{htmlescape var=$customer.name}},</h1>
                <p>Congratulations. Your account has been approved. Now you can access our wholesale catalog price.</p>
                <p>To log in when visiting our site just click <a href="{{store url="customer/account/"}}">Login</a> or <a href="{{store url="customer/account/"}}">My Account</a> at the top of every page, and then enter your email address and password.</p>
                <p>When you log in to your account, you will be able to do the following:</p>
                <ul>
                    <li>Proceed through checkout faster when making a purchase</li>
                    <li>Check the status of orders</li>
                    <li>View past orders</li>
                    <li>Make changes to your account information</li>
                    <li>Change your password</li>
                    <li>Store alternative addresses (for shipping to multiple family members and friends!)</li>
                </ul>
                <p>
                    If you have any questions, please feel free to contact us at
                    <a href="mailto:{{var store_email}}">{{var store_email}}</a>
                    {{depend store_phone}} or by phone at <a href="tel:{{var phone}}">{{var store_phone}}</a>{{/depend}}.
                </p>
            </td>
        </tr>
    </table>
   
    {{template config_path="design/email/footer"}}

Assigned both template from Customer configuration in magento admin panel.