Auto_Subscribe_to_Newsletter_on_registration - Version 1.0.0

Version Notes

First release

Download this release

Release Info

Developer Alban Staehli
Extension Auto_Subscribe_to_Newsletter_on_registration
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/local/Oxegena/SubscribeAtCheckout/Model/Observer.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Oxegena_SubscribeAtCheckout_Model_Observer
3
+ {
4
+
5
+ public function AssignNewletter(Varien_Event_Observer $observer)
6
+ {
7
+ if (Mage::getStoreConfig('oxegenaconfig_subscribeatcheckout/section_one/subscribe_on_checkout',Mage::app()->getStore()) == 1)
8
+ {
9
+ $event = $observer->getEvent();
10
+ $order = $event->getOrder();
11
+ $Quote = $event->getQuote();
12
+ $request = Mage::app()->getRequest();
13
+
14
+ $oincid = $order->getIncrementId();
15
+ $salesOrder = Mage::getModel('sales/order')->loadByIncrementId($oincid);
16
+
17
+ $email = $salesOrder->getCustomerEmail();
18
+
19
+ $subscriberModel = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
20
+ if ((!$subscriberModel->isSubscribed()) || (!$subscriberModel->getId())) {
21
+ $status = Mage::getModel('newsletter/subscriber')->subscribe($email);
22
+ }
23
+ }
24
+ }
25
+
26
+ public function AssignNewletterFromRegister(Varien_Event_Observer $observer)
27
+ {
28
+ if (Mage::getStoreConfig('oxegenaconfig_subscribeatcheckout/section_one/subscribe_on_register',Mage::app()->getStore()) == 1)
29
+ {
30
+ $event = $observer->getEvent();
31
+ $customer = $event->getCustomer();
32
+ $email = $customer->getEmail();
33
+
34
+ $subscriberModel = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
35
+ if ((!$subscriberModel->isSubscribed()) || (!$subscriberModel->getId())) {
36
+ $status = Mage::getModel('newsletter/subscriber')->subscribe($email);
37
+ }
38
+ }
39
+ }
40
+
41
+ }
42
+ ?>
app/code/local/Oxegena/SubscribeAtCheckout/etc/config.xml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Oxegena_SubscribeAtCheckout>
5
+ <version>1.0.0</version>
6
+ </Oxegena_SubscribeAtCheckout>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <subscribeatcheckout>
11
+ <class>Oxegena_SubscribeAtCheckout_Model</class>
12
+ </subscribeatcheckout>
13
+ </models>
14
+ <events>
15
+ <checkout_submit_all_after> <!-- identifier of the event we want to catch -->
16
+ <observers>
17
+ <checkout_submit_all_after_handler> <!-- identifier of the event handler -->
18
+ <type>singleton</type> <!-- class method call type; valid are model, object and singleton -->
19
+ <class>subscribeatcheckout/observer</class> <!-- observers class alias -->
20
+ <method>AssignNewletter</method> <!-- observer's method to be called -->
21
+ </checkout_submit_all_after_handler>
22
+ </observers>
23
+ </checkout_submit_all_after>
24
+ <customer_register_success> <!-- identifier of the event we want to catch -->
25
+ <observers>
26
+ <customer_register_success_handler> <!-- identifier of the event handler -->
27
+ <type>singleton</type> <!-- class method call type; valid are model, object and singleton -->
28
+ <class>subscribeatcheckout/observer</class> <!-- observers class alias -->
29
+ <method>AssignNewletterFromRegister</method> <!-- observer's method to be called -->
30
+ </customer_register_success_handler>
31
+ </observers>
32
+ </customer_register_success>
33
+ </events>
34
+ </global>
35
+ </config>
app/code/local/Oxegena/SubscribeAtCheckout/etc/system.xml ADDED
@@ -0,0 +1 @@
 
1
+
app/code/local/Oxegena/SubscribeAtCheckoutConfig/Helper/Data.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sample Widget Helper
4
+ */
5
+ class Oxegena_SubscribeAtCheckoutConfig_Helper_Data extends Mage_Core_Helper_Abstract
6
+ {
7
+ }
8
+ ?>
app/code/local/Oxegena/SubscribeAtCheckoutConfig/Model/Options.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Oxegena_SubscribeAtCheckoutConfig_Model_Options
3
+ {
4
+ /**
5
+ * Provide available options as a value/label array
6
+ *
7
+ * @return array
8
+ */
9
+ public function toOptionArray()
10
+ {
11
+ return array(
12
+ array('value'=>0, 'label'=>'No'),
13
+ array('value'=>1, 'label'=>'Yes')
14
+ );
15
+ }
16
+ }
17
+ ?>
app/code/local/Oxegena/SubscribeAtCheckoutConfig/etc/config.xml ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Oxegena_SubscribeAtCheckoutConfig>
5
+ <version>1.0.0</version>
6
+ </Oxegena_SubscribeAtCheckoutConfig>
7
+ </modules>
8
+ <global>
9
+ <helpers>
10
+ <oxegenaconfig>
11
+ <class>Oxegena_SubscribeAtCheckoutConfig_Helper</class>
12
+ </oxegenaconfig>
13
+ </helpers>
14
+ <models>
15
+ <oxegenaconfig>
16
+ <class>Oxegena_SubscribeAtCheckoutConfig_Model</class>
17
+ </oxegenaconfig>
18
+ </models>
19
+ </global>
20
+ <adminhtml>
21
+ <acl>
22
+ <resources>
23
+ <admin>
24
+ <children>
25
+ <system>
26
+ <children>
27
+ <config>
28
+ <children>
29
+ <oxegenaconfig_subscribeatcheckout>
30
+ <title>Subscribe At Checkout</title>
31
+ </oxegenaconfig_subscribeatcheckout>
32
+ </children>
33
+ </config>
34
+ </children>
35
+ </system>
36
+ </children>
37
+ </admin>
38
+ </resources>
39
+ </acl>
40
+ </adminhtml>
41
+ </config>
app/code/local/Oxegena/SubscribeAtCheckoutConfig/etc/system.xml ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <oxegenaconfig translate="label" module="oxegenaconfig">
5
+ <label>Oxegena</label>
6
+ <sort_order>100</sort_order>
7
+ </oxegenaconfig>
8
+ </tabs>
9
+
10
+ <sections>
11
+ <oxegenaconfig_subscribeatcheckout translate="label" module="oxegenaconfig">
12
+ <label>Subscribe At Checkout</label>
13
+ <tab>oxegenaconfig</tab>
14
+ <frontend_type>text</frontend_type>
15
+ <sort_order>1</sort_order>
16
+ <show_in_default>1</show_in_default>
17
+ <show_in_website>1</show_in_website>
18
+ <show_in_store>1</show_in_store>
19
+ <groups>
20
+ <section_one translate="label">
21
+ <label>Subscribe customer</label>
22
+ <frontend_type>text</frontend_type>
23
+ <sort_order>1</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>1</show_in_website>
26
+ <show_in_store>1</show_in_store>
27
+ <fields>
28
+ <subscribe_on_register>
29
+ <label>Subscribe on registrer</label>
30
+ <frontend_type>select</frontend_type>
31
+ <source_model>oxegenaconfig/options</source_model>
32
+ <sort_order>1</sort_order>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>1</show_in_website>
35
+ <show_in_store>1</show_in_store>
36
+ <comment>If yes, will automatically subscribe clients when they register to the Shop.</comment>
37
+ </subscribe_on_register>
38
+ <subscribe_on_checkout>
39
+ <label>Subscribe on checkout</label>
40
+ <frontend_type>select</frontend_type>
41
+ <source_model>oxegenaconfig/options</source_model>
42
+ <sort_order>1</sort_order>
43
+ <show_in_default>1</show_in_default>
44
+ <show_in_website>1</show_in_website>
45
+ <show_in_store>1</show_in_store>
46
+ <comment>If yes, will automatically subscribe clients when they register to the Shop while checking out.</comment>
47
+ </subscribe_on_checkout>
48
+ </fields>
49
+ </section_one>
50
+ </groups>
51
+ </oxegenaconfig_subscribeatcheckout>
52
+ </sections>
53
+ </config>
app/etc/modules/Oxegena_SubscribeAtCheckout.xml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Oxegena_SubscribeAtCheckout>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ <version>1.0.0</version>
8
+ </Oxegena_SubscribeAtCheckout>
9
+ <Oxegena_SubscribeAtCheckoutConfig>
10
+ <active>true</active>
11
+ <codePool>local</codePool>
12
+ <version>1.0.0</version>
13
+ </Oxegena_SubscribeAtCheckoutConfig>
14
+ </modules>
15
+ </config>
package.xml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Auto_Subscribe_to_Newsletter_on_registration</name>
4
+ <version>1.0.0</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>Enable automatic customer's subscription to your newsletter when they register to your shop.</summary>
10
+ <description>By default, when a customer registers to your shop (either through the sign-in link, either through the check-out process), he isn't automatically subscribed to your newsletter.&#xD;
11
+ &#xD;
12
+ This extension allows to automatically subscribe your customer to your newsletter when they register to your shop.&#xD;
13
+ &#xD;
14
+ You can setup if you want to activate it:&#xD;
15
+ - on customer registration&#xD;
16
+ - on customer registration during check out&#xD;
17
+ &#xD;
18
+ Email confirmation are still being sent to the customer mentionning that he is now subscribed to the Newsletter.</description>
19
+ <notes>First release</notes>
20
+ <authors><author><name>Alban Staehli</name><user>albans</user><email>alban.staehli@oxegena.ch</email></author></authors>
21
+ <date>2017-01-09</date>
22
+ <time>23:24:38</time>
23
+ <contents><target name="magelocal"><dir name="."><dir name="Oxegena"><dir><dir name="SubscribeAtCheckout"><dir name="Model"><file name="Observer.php" hash="c0f8fa0e4f368eadeddba951e5f661d2"/></dir><dir name="etc"><file name="config.xml" hash="aa50afbfbbe5c556084eec3c3cdf99f2"/><file name="system.xml" hash="68b329da9893e34099c7d8ad5cb9c940"/></dir></dir><dir name="SubscribeAtCheckoutConfig"><dir name="Helper"><file name="Data.php" hash="bbfe946b909a6b1fb47a30ca52b1e576"/></dir><dir name="Model"><file name="Options.php" hash="b7e976e3624960dd8bc5cccdc2bda998"/></dir><dir name="etc"><file name="config.xml" hash="aab9dab11f1f1c841c0ddecfe99cf109"/><file name="system.xml" hash="87f6910eca6cff2a975a73c9fd12bae3"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="."><dir name="modules"><file name="Oxegena_SubscribeAtCheckout.xml" hash="3c5e2b06ac6b84fe900a3aeebdf818aa"/></dir></dir></target></contents>
24
+ <compatible/>
25
+ <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
26
+ </package>