Expert_CustomerRedirect - Version 1.0.0.1

Version Notes

Customer Redirect to Link/Page After Login and Create Accounts

Download this release

Release Info

Developer Suraj Kumawat
Extension Expert_CustomerRedirect
Version 1.0.0.1
Comparing to
See all releases


Version 1.0.0.1

app/code/local/Expert/CustomerRedirect/Helper/Data.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Expert_CustomerRedirect_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+
5
+ }
app/code/local/Expert/CustomerRedirect/controllers/AccountController.php ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Expert_CustomerRedirect_AccountController extends Mage_Customer_AccountController
3
+ {
4
+
5
+ public function indexAction()
6
+ {
7
+
8
+ $this->loadLayout();
9
+ $this->_initLayoutMessages('customer/session');
10
+ $this->_initLayoutMessages('catalog/session');
11
+
12
+ $this->getLayout()->getBlock('content')->append(
13
+ $this->getLayout()->createBlock('customer/account_dashboard')
14
+ );
15
+ $this->getLayout()->getBlock('head')->setTitle($this->__('My Account'));
16
+ $this->renderLayout();
17
+ }
18
+
19
+
20
+ protected function _welcomeCustomer(Mage_Customer_Model_Customer $customer, $isJustConfirmed = false)
21
+ {
22
+ $this->_getSession()->addSuccess(
23
+ $this->__('Thank you for registering with %s.', Mage::app()->getStore()->getFrontendName())
24
+ );
25
+ if ($this->_isVatValidationEnabled()) {
26
+
27
+ $configAddressType = Mage::helper('customer/address')->getTaxCalculationAddressType();
28
+ $userPrompt = '';
29
+ switch ($configAddressType) {
30
+ case Mage_Customer_Model_Address_Abstract::TYPE_SHIPPING:
31
+ $userPrompt = $this->__('If you are a registered VAT customer, please click <a href="%s">here</a> to enter you shipping address for proper VAT calculation', Mage::getUrl('customer/address/edit'));
32
+ break;
33
+ default:
34
+ $userPrompt = $this->__('If you are a registered VAT customer, please click <a href="%s">here</a> to enter you billing address for proper VAT calculation', Mage::getUrl('customer/address/edit'));
35
+ }
36
+ $this->_getSession()->addSuccess($userPrompt);
37
+ }
38
+
39
+ $customer->sendNewAccountEmail(
40
+ $isJustConfirmed ? 'confirmed' : 'registered',
41
+ '',
42
+ Mage::app()->getStore()->getId()
43
+ );
44
+
45
+
46
+ $cusromerRedirectStatus = Mage::getStoreConfig('customer/customercreateredirect/active');
47
+ $customerCreateRedirectUrl = Mage::getStoreConfig('customer/customercreateredirect/redirecturl');
48
+
49
+
50
+ if($cusromerRedirectStatus==1)
51
+ {
52
+ $successUrl = Mage::getUrl().$customerCreateRedirectUrl;
53
+
54
+ }
55
+ else{
56
+ $successUrl = Mage::getUrl('*/*/index', array('_secure'=>true));}
57
+ if ($this->_getSession()->getBeforeAuthUrl()) {
58
+
59
+ if($cusromerRedirectStatus==1)
60
+ {
61
+ $successUrl = Mage::getUrl().$customerCreateRedirectUrl;
62
+ }else
63
+ {
64
+
65
+ $successUrl = $this->_getSession()->getBeforeAuthUrl(true);
66
+ }
67
+ }
68
+ return $successUrl;
69
+
70
+ }
71
+
72
+
73
+
74
+
75
+
76
+
77
+ /**
78
+ * Login post action
79
+ */
80
+ public function loginPostAction()
81
+ {
82
+ if ($this->_getSession()->isLoggedIn()) {
83
+ $this->_redirect('*/*/');
84
+ return;
85
+ }
86
+ $session = $this->_getSession();
87
+
88
+
89
+ if ($this->getRequest()->isPost()) {
90
+ $login = $this->getRequest()->getPost('login');
91
+ if (!empty($login['username']) && !empty($login['password'])) {
92
+ try {
93
+ $session->login($login['username'], $login['password']);
94
+ if ($session->getCustomer()->getIsJustConfirmed()) {
95
+ $this->_welcomeCustomer($session->getCustomer(), true);
96
+ }
97
+ } catch (Mage_Core_Exception $e) {
98
+ switch ($e->getCode()) {
99
+ case Mage_Customer_Model_Customer::EXCEPTION_EMAIL_NOT_CONFIRMED:
100
+ $value = Mage::helper('customer')->getEmailConfirmationUrl($login['username']);
101
+ $message = Mage::helper('customer')->__('This account is not confirmed. <a href="%s">Click here</a> to resend confirmation email.', $value);
102
+ break;
103
+ case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:
104
+ $message = $e->getMessage();
105
+ break;
106
+ default:
107
+ $message = $e->getMessage();
108
+ }
109
+ $session->addError($message);
110
+ $session->setUsername($login['username']);
111
+ } catch (Exception $e) {
112
+
113
+ }
114
+ } else {
115
+ $session->addError($this->__('Login and password are required.'));
116
+ }
117
+ }
118
+
119
+ $this->_loginPostRedirect();
120
+ }
121
+
122
+
123
+ protected function _loginPostRedirect()
124
+ {
125
+
126
+ $session = $this->_getSession();
127
+ $preUrl = $session->getBeforeAuthUrl(true);
128
+
129
+ $cusromerRedirectStatus = Mage::getStoreConfig('customer/customerloginredirect/active');
130
+ $customerLoginRedirectUrl = Mage::getStoreConfig('customer/customerloginredirect/redirecturl');
131
+
132
+ $redirectUrl = $preUrl;
133
+ if(($cusromerRedirectStatus) && ($customerLoginRedirectUrl) && (strpos($preUrl, 'checkout/onepage') == '')){
134
+ $redirectUrl = Mage::getUrl().$customerLoginRedirectUrl;
135
+ }
136
+
137
+ if(($cusromerRedirectStatus) && ($customerLoginRedirectUrl)){
138
+ $redirectUrl = Mage::getUrl().$customerLoginRedirectUrl;
139
+ }
140
+
141
+ if ($this->_getSession()->isLoggedIn()) {
142
+ $this->_redirectUrl($redirectUrl);
143
+ return;
144
+ }
145
+
146
+ $this->_redirectUrl($preUrl);
147
+ }
148
+ }
app/code/local/Expert/CustomerRedirect/etc/config.xml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Expert_CustomerRedirect>
5
+ <version>1.0.0.1</version>
6
+ </Expert_CustomerRedirect>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <customer>
11
+ <args>
12
+ <modules>
13
+ <expert_customerredirect before="Mage_Customer">Expert_CustomerRedirect</expert_customerredirect>
14
+ </modules>
15
+ </args>
16
+ </customer>
17
+ </routers>
18
+ </frontend>
19
+ <global>
20
+ <helpers>
21
+ <expert_customerredirect>
22
+ <class>Expert_CustomerRedirect_Helper</class>
23
+ </expert_customerredirect>
24
+ </helpers>
25
+ </global>
26
+ </config>
app/code/local/Expert/CustomerRedirect/etc/system.xml ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <customer translate="label" module="customer">
5
+ <class>separator-top</class>
6
+ <label>Customer Configuration</label>
7
+ <tab>customer</tab>
8
+ <sort_order>130</sort_order>
9
+ <show_in_default>1</show_in_default>
10
+ <show_in_website>1</show_in_website>
11
+ <show_in_store>1</show_in_store>
12
+ <groups>
13
+ <customerloginredirect translate="label">
14
+ <label>Customer Login After Redirect</label>
15
+ <frontend_type>text</frontend_type>
16
+ <sort_order>10</sort_order>
17
+ <show_in_default>1</show_in_default>
18
+ <show_in_website>1</show_in_website>
19
+ <show_in_store>1</show_in_store>
20
+ <fields>
21
+ <active translate="label">
22
+ <label>Enable</label>
23
+ <frontend_type>select</frontend_type>
24
+ <source_model>adminhtml/system_config_source_yesno</source_model>
25
+ <sort_order>10</sort_order>
26
+ <show_in_default>1</show_in_default>
27
+ <show_in_website>1</show_in_website>
28
+ <show_in_store>1</show_in_store>
29
+ </active>
30
+ <redirecturl translate="label">
31
+ <label>Redirect Url</label>
32
+ <frontend_type>text</frontend_type>
33
+ <sort_order>20</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ <show_in_website>1</show_in_website>
36
+ <show_in_store>1</show_in_store>
37
+ <comment><![CDATA[write url in format : checkout/cart]]></comment>
38
+ <depends>
39
+ <active>1</active>
40
+ </depends>
41
+ </redirecturl>
42
+ </fields>
43
+ </customerloginredirect>
44
+ </groups>
45
+ <groups>
46
+ <customercreateredirect translate="label">
47
+ <label>Customer Create Account After Redirect</label>
48
+ <frontend_type>text</frontend_type>
49
+ <sort_order>10</sort_order>
50
+ <show_in_default>1</show_in_default>
51
+ <show_in_website>1</show_in_website>
52
+ <show_in_store>1</show_in_store>
53
+ <fields>
54
+ <active translate="label">
55
+ <label>Enable</label>
56
+ <frontend_type>select</frontend_type>
57
+ <source_model>adminhtml/system_config_source_yesno</source_model>
58
+ <sort_order>10</sort_order>
59
+ <show_in_default>1</show_in_default>
60
+ <show_in_website>1</show_in_website>
61
+ <show_in_store>1</show_in_store>
62
+ </active>
63
+ <redirecturl translate="label">
64
+ <label>Redirect Url</label>
65
+ <frontend_type>text</frontend_type>
66
+ <sort_order>20</sort_order>
67
+ <show_in_default>1</show_in_default>
68
+ <show_in_website>1</show_in_website>
69
+ <show_in_store>1</show_in_store>
70
+ <comment><![CDATA[write url in format : checkout/cart]]></comment>
71
+ <depends>
72
+ <active>1</active>
73
+ </depends>
74
+ </redirecturl>
75
+ </fields>
76
+ </customercreateredirect>
77
+ </groups>
78
+ </customer>
79
+ </sections>
80
+ </config>
app/etc/modules/Expert_CustomerRedirect.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Expert_CustomerRedirect>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Expert_CustomerRedirect>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Expert_CustomerRedirect</name>
4
+ <version>1.0.0.1</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>The Extension Provide function to redirect Customer after login or Create account.&#xD;
10
+ </summary>
11
+ <description>The Extension Provide function to redirect Customer after login or Create account.&#xD;
12
+ In admin there is two tab Under System-&gt;Configuration-&gt;Customer Configuration (Customer Section).&#xD;
13
+ Please refer Image , &#xD;
14
+ &#xD;
15
+ For More Info : www.expertsofttechsolution.com&#xD;
16
+ Email: support@expertsofttechsolution.com</description>
17
+ <notes>Customer Redirect to Link/Page After Login and Create Accounts</notes>
18
+ <authors><author><name>Sharad Patel</name><user>coderz_expert</user><email>coderz.expert@gmail.com</email></author></authors>
19
+ <date>2013-08-04</date>
20
+ <time>10:45:21</time>
21
+ <contents><target name="magelocal"><dir name="Expert"><dir name="CustomerRedirect"><dir name="Helper"><file name="Data.php" hash="c4b4aa249af0a84c79703474950919b8"/></dir><dir name="controllers"><file name="AccountController.php" hash="df5302b6ee0d68aead49f19b32f2a81d"/></dir><dir name="etc"><file name="config.xml" hash="6c2c226403622529256c5b586932fe8c"/><file name="system.xml" hash="a915a426d13bb747497dac86b67e1b98"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Expert_CustomerRedirect.xml" hash="67117d17099a061bb0cb66362547369b"/></dir></target></contents>
22
+ <compatible/>
23
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.5.0.0</min><max>1.7</max></package><extension><name>gd</name><min>2.0.20</min><max>3.0</max></extension></required></dependencies>
24
+ </package>