Cybage_SignupPromo - Version 1.0.0

Version Notes

After installation of the Marketplace plugin please clear the cache.

Download this release

Release Info

Developer Cybage Software Pvt. Ltd.
Extension Cybage_SignupPromo
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/Cybage/SignupPromo/Block/Coupon.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cybage Signup Promotion Plugin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * It is available on the World Wide Web at:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you are unable to access it on the World Wide Web, please send an email
11
+ * To: Support_Magento@cybage.com. We will send you a copy of the source file.
12
+ *
13
+ * @category Signup Promotion Plugin
14
+ * @package Cybage_SignupPromo
15
+ * @copyright Copyright (c) 2014 Cybage Software Pvt. Ltd., India
16
+ * http://www.cybage.com/pages/centers-of-excellence/ecommerce/ecommerce.aspx
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ * @author Cybage Software Pvt. Ltd. <Support_Magento@cybage.com>
19
+ */
20
+
21
+ class Cybage_SignupPromo_Block_Coupon extends Mage_Core_Block_Template
22
+ {
23
+ protected function _construct()
24
+ {
25
+ parent::_construct();
26
+ //$this->setTemplate('customer/form/newsletter.phtml');
27
+ }
28
+
29
+ public function getCouponData()
30
+ {
31
+ return Mage::getModel('signuppromo/signuppromo')->getCouponData();
32
+ }
33
+ }
app/code/community/Cybage/SignupPromo/Block/Promo/Quote/Edit/Tab/Coupons/Column/Renderer/Email.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cybage Signup Promotion Plugin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * It is available on the World Wide Web at:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you are unable to access it on the World Wide Web, please send an email
11
+ * To: Support_Magento@cybage.com. We will send you a copy of the source file.
12
+ *
13
+ * @category Signup Promotion Plugin
14
+ * @package Cybage_SignupPromo
15
+ * @copyright Copyright (c) 2014 Cybage Software Pvt. Ltd., India
16
+ * http://www.cybage.com/pages/centers-of-excellence/ecommerce/ecommerce.aspx
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ * @author Cybage Software Pvt. Ltd. <Support_Magento@cybage.com>
19
+ */
20
+
21
+ class Cybage_SignupPromo_Block_Promo_Quote_Edit_Tab_Coupons_Column_Renderer_Email extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Text
22
+ {
23
+ public function render(Varien_Object $row)
24
+ {
25
+ $value = (int)$row->getData($this->getColumn()->getIndex());
26
+ if($value) {
27
+ $customerCollection = Mage::getSingleton('customer/customer')->load($value);
28
+ return Mage::helper('adminhtml')->__($customerCollection->getEmail());
29
+ }
30
+ return '';
31
+ }
32
+ }
app/code/community/Cybage/SignupPromo/Block/Promo/Quote/Edit/Tab/Coupons/Grid.php ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cybage Signup Promotion Plugin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * It is available on the World Wide Web at:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you are unable to access it on the World Wide Web, please send an email
11
+ * To: Support_Magento@cybage.com. We will send you a copy of the source file.
12
+ *
13
+ * @category Signup Promotion Plugin
14
+ * @package Cybage_SignupPromo
15
+ * @copyright Copyright (c) 2014 Cybage Software Pvt. Ltd., India
16
+ * http://www.cybage.com/pages/centers-of-excellence/ecommerce/ecommerce.aspx
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ * @author Cybage Software Pvt. Ltd. <Support_Magento@cybage.com>
19
+ */
20
+
21
+ class Cybage_SignupPromo_Block_Promo_Quote_Edit_Tab_Coupons_Grid extends Mage_Adminhtml_Block_Widget_Grid
22
+ {
23
+ public function __construct()
24
+ {
25
+ parent::__construct();
26
+ $this->setId('couponCodesGrid');
27
+ $this->setUseAjax(true);
28
+ }
29
+
30
+ /**
31
+ * Prepare collection for grid
32
+ *
33
+ * @return Mage_Adminhtml_Block_Widget_Grid
34
+ */
35
+ protected function _prepareCollection()
36
+ {
37
+ $priceRule = Mage::registry('current_promo_quote_rule');
38
+ $tableName = Mage::getSingleton("core/resource")->getTableName('customer/entity');
39
+ $couponType = $priceRule['coupon_type'];
40
+
41
+ /**
42
+ * @var Mage_SalesRule_Model_Resource_Coupon_Collection $collection
43
+ */
44
+ $collection = Mage::getResourceModel('salesrule/coupon_collection')
45
+ ->addRuleToFilter($priceRule)
46
+ ->addGeneratedCouponsFilter();
47
+
48
+ /*Show customer email id for only coupon type "Auto generated Coupons for Customer Registration"*/
49
+ if($couponType == Cybage_SignupPromo_Model_Rule::COUPON_TYPE_AUTO_CUSTOMER_SPECIFIC){
50
+ $collection->getSelect()->join(array('t2' => $tableName),'main_table.customer_id = t2.entity_id',array('t2.email'));
51
+ }
52
+
53
+ $this->setCollection($collection);
54
+ return parent::_prepareCollection();
55
+ }
56
+
57
+ /**
58
+ * Define grid columns
59
+ *
60
+ * @return Mage_Adminhtml_Block_Widget_Grid
61
+ */
62
+ protected function _prepareColumns()
63
+ {
64
+ $priceRule = Mage::registry('current_promo_quote_rule');
65
+ $couponType = $priceRule['coupon_type'];
66
+
67
+ $this->addColumn('code', array(
68
+ 'header' => Mage::helper('salesrule')->__('Coupon Code'),
69
+ 'index' => 'code'
70
+ ));
71
+
72
+ $this->addColumn('created_at', array(
73
+ 'header' => Mage::helper('salesrule')->__('Created On'),
74
+ 'index' => 'created_at',
75
+ 'type' => 'datetime',
76
+ 'align' => 'center',
77
+ 'width' => '160'
78
+ ));
79
+
80
+ /*Show customer email id feild for only coupon type "Auto generated Coupons for Customer Registration"*/
81
+ if($couponType == Cybage_SignupPromo_Model_Rule::COUPON_TYPE_AUTO_CUSTOMER_SPECIFIC){
82
+ $this->addColumn('email', array(
83
+ 'header' => Mage::helper('salesrule')->__('Email Address'),
84
+ 'index' => 'email',
85
+ 'type' => 'text',
86
+ 'width' => '100',
87
+ //'renderer' => 'signuppromo/promo_quote_edit_tab_coupons_column_renderer_email',
88
+ ));
89
+ }
90
+
91
+ $this->addColumn('used', array(
92
+ 'header' => Mage::helper('salesrule')->__('Used'),
93
+ 'index' => 'times_used',
94
+ 'width' => '100',
95
+ 'type' => 'options',
96
+ 'options' => array(
97
+ Mage::helper('adminhtml')->__('No'),
98
+ Mage::helper('adminhtml')->__('Yes')
99
+ ),
100
+ 'renderer' => 'adminhtml/promo_quote_edit_tab_coupons_grid_column_renderer_used',
101
+ 'filter_condition_callback' => array(
102
+ Mage::getResourceModel('salesrule/coupon_collection'), 'addIsUsedFilterCallback'
103
+ )
104
+ ));
105
+
106
+ $this->addColumn('times_used', array(
107
+ 'header' => Mage::helper('salesrule')->__('Times Used'),
108
+ 'index' => 'times_used',
109
+ 'width' => '50',
110
+ 'type' => 'number',
111
+ ));
112
+
113
+ $this->addExportType('*/*/exportCouponsCsv', Mage::helper('customer')->__('CSV'));
114
+ $this->addExportType('*/*/exportCouponsXml', Mage::helper('customer')->__('Excel XML'));
115
+ return parent::_prepareColumns();
116
+ }
117
+
118
+ /**
119
+ * Configure grid mass actions
120
+ *
121
+ * @return Mage_Adminhtml_Block_Promo_Quote_Edit_Tab_Coupons_Grid
122
+ */
123
+ protected function _prepareMassaction()
124
+ {
125
+ $this->setMassactionIdField('coupon_id');
126
+ $this->getMassactionBlock()->setFormFieldName('ids');
127
+ $this->getMassactionBlock()->setUseAjax(true);
128
+ $this->getMassactionBlock()->setHideFormElement(true);
129
+
130
+ $this->getMassactionBlock()->addItem('delete', array(
131
+ 'label'=> Mage::helper('adminhtml')->__('Delete'),
132
+ 'url' => $this->getUrl('*/*/couponsMassDelete', array('_current' => true)),
133
+ 'confirm' => Mage::helper('salesrule')->__('Are you sure you want to delete the selected coupon(s)?'),
134
+ 'complete' => 'refreshCouponCodesGrid'
135
+ ));
136
+
137
+ return $this;
138
+ }
139
+
140
+ /**
141
+ * Get grid url
142
+ *
143
+ * @return string
144
+ */
145
+ public function getGridUrl()
146
+ {
147
+ return $this->getUrl('*/*/couponsGrid', array('_current'=> true));
148
+ }
149
+ }
app/code/community/Cybage/SignupPromo/Block/SignupPromo.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cybage Signup Promotion Plugin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * It is available on the World Wide Web at:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you are unable to access it on the World Wide Web, please send an email
11
+ * To: Support_Magento@cybage.com. We will send you a copy of the source file.
12
+ *
13
+ * @category Signup Promotion Plugin
14
+ * @package Cybage_SignupPromo
15
+ * @copyright Copyright (c) 2014 Cybage Software Pvt. Ltd., India
16
+ * http://www.cybage.com/pages/centers-of-excellence/ecommerce/ecommerce.aspx
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ * @author Cybage Software Pvt. Ltd. <Support_Magento@cybage.com>
19
+ */
20
+
21
+ class Cybage_SignupPromo_Block_SignupPromo extends Mage_Core_Block_Template
22
+ {
23
+ public function getCoupons(){
24
+ return Mage::getModel('signuppromo/signuppromo')->getCouponData($this->getCouponCodes());
25
+ }
26
+ }
app/code/community/Cybage/SignupPromo/Helper/Data.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cybage Signup Promotion Plugin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * It is available on the World Wide Web at:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you are unable to access it on the World Wide Web, please send an email
11
+ * To: Support_Magento@cybage.com. We will send you a copy of the source file.
12
+ *
13
+ * @category Signup Promotion Plugin
14
+ * @package Cybage_SignupPromo
15
+ * @copyright Copyright (c) 2014 Cybage Software Pvt. Ltd., India
16
+ * http://www.cybage.com/pages/centers-of-excellence/ecommerce/ecommerce.aspx
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ * @author Cybage Software Pvt. Ltd. <Support_Magento@cybage.com>
19
+ */
20
+
21
+ class Cybage_SignupPromo_Helper_Data extends Mage_Core_Helper_Abstract {
22
+
23
+ const XML_PATH_ENABLED = 'signuppromo_section/signuppromo_group/active';
24
+ const XML_PATH_SUCCESS_MSG = 'signuppromo_section/signuppromo_group/success';
25
+ const XML_PATH_EMAIL_TEMPLATE = 'signuppromo_section/signuppromo_group/emailtemplate';
26
+ const XML_PATH_EMAIL_SENDER = 'signuppromo_section/signuppromo_group/identity';
27
+ const XML_PATH_COUPON_LENGTH = 'signuppromo_section/signuppromo_group/couponlength';
28
+ const XML_PATH_COUPON_PREFIX = 'signuppromo_section/signuppromo_group/couponprefix';
29
+ const XML_PATH_COUPON_EXPIRE = 'signuppromo_section/signuppromo_group/couponexpire';
30
+
31
+ public function isModEnabled(){
32
+ return Mage::getStoreConfig(self::XML_PATH_ENABLED);
33
+ }
34
+
35
+ public function sendEmail($receiverEmail, $receiverName, $uniqueCode) {
36
+ $msg = Mage::getStoreConfig(self::XML_PATH_SUCCESS_MSG);
37
+ $storeId = Mage::app()->getStore()->getId();
38
+
39
+ try{
40
+ $vars = array('name' => $receiverName, 'coupon_codes' => $uniqueCode);
41
+
42
+ $emailTemplate = Mage::getModel('core/email_template')->loadDefault(Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE))
43
+ ->setSenderEmail(Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER, $storeId))
44
+ ->setSenderName(Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER, $storeId))
45
+ ->send($receiverEmail,$receiverName, $vars);
46
+
47
+ }catch (Exception $e) {
48
+ Mage::getSingleton('customer/session')->addError($e->getMessage());
49
+ return;
50
+ }
51
+ }
52
+
53
+ public function _genrateCoupon($customerId,$name,$customerGroupId,$email,$websiteId)
54
+ {
55
+ $model = Mage::getModel('signuppromo/signuppromo');
56
+ $uniqueCode = array();
57
+ $date = date('Y-m-d', Mage::getModel('core/date')->timestamp(time()));
58
+
59
+ $ruleCollection = Mage::getResourceModel('salesrule/rule_collection')
60
+ ->addFieldToFilter('coupon_type', 4)
61
+ ->addFieldToFilter('is_active', 1)
62
+ ->addWebsiteGroupDateFilter($websiteId, $customerGroupId, $date);
63
+
64
+ foreach($ruleCollection as $rule){
65
+
66
+ $ruleId = $rule->getRuleId();
67
+ $uniqueCode[]= $model->addPromoCode($customerId, $ruleId);
68
+ }
69
+
70
+ if($uniqueCode && Mage::getStoreConfig('signuppromo_section/signuppromo_group/couponemailnotification'))
71
+ $this->sendEmail($email, $name, $uniqueCode);
72
+ }
73
+ }
app/code/community/Cybage/SignupPromo/Model/Observer.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cybage Signup Promotion Plugin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * It is available on the World Wide Web at:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you are unable to access it on the World Wide Web, please send an email
11
+ * To: Support_Magento@cybage.com. We will send you a copy of the source file.
12
+ *
13
+ * @category Signup Promotion Plugin
14
+ * @package Cybage_SignupPromo
15
+ * @copyright Copyright (c) 2014 Cybage Software Pvt. Ltd., India
16
+ * http://www.cybage.com/pages/centers-of-excellence/ecommerce/ecommerce.aspx
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ * @author Cybage Software Pvt. Ltd. <Support_Magento@cybage.com>
19
+ */
20
+
21
+ class Cybage_SignupPromo_Model_Observer {
22
+
23
+ const XML_PATH_SUCCESS_MSG = 'signuppromo_section/signuppromo_group/success';
24
+
25
+ public function customerRegisterSave(Varien_Event_Observer $observer) {
26
+ $msg = Mage::getStoreConfig(self::XML_PATH_SUCCESS_MSG);
27
+ $helper = Mage::helper('signuppromo');
28
+ if($helper->isModEnabled()){
29
+ $customer = $observer->getEvent()->getCustomer();
30
+
31
+ if (!$customer->getId())
32
+ return $this;
33
+
34
+ $customerId = $observer->getEvent()->getCustomer()->getId();
35
+ $email = $observer->getEvent()->getCustomer()->getEmail();
36
+ $name = $observer->getEvent()->getCustomer()->getFirstname();
37
+ $customerGroupId = $customer->getGroupId();
38
+ $websiteId = $customer->getWebsiteId();
39
+
40
+ $helper->_genrateCoupon($customerId,$name,$customerGroupId,$email,$websiteId);
41
+ if($msg)
42
+ Mage::getSingleton('customer/session')->addNotice($msg);
43
+
44
+ }
45
+ }
46
+
47
+ public function checkSignupPromoCoupon(Varien_Event_Observer $observer) {
48
+ $date = date('Y-m-d', Mage::getModel('core/date')->timestamp(time()));
49
+ if(Mage::helper('signuppromo')->isModEnabled()){
50
+ $ruleCollection = Mage::getResourceModel('salesrule/rule_collection')
51
+ ->addFieldToFilter('coupon_type', 4);
52
+ foreach($ruleCollection as $rule){
53
+ $ruleId = $rule->getRuleId();
54
+ $rules[] = $ruleId;
55
+ }
56
+ if(in_array($observer->getEvent()->getRule()->getRuleId(), $rules)){
57
+ $couponCustomerId = Mage::getModel('salesrule/coupon')->load($observer->getEvent()->getRule()->getCode(), 'code');
58
+ $customerId = $observer->getEvent()->getQuote()->getCustomer()->getId();
59
+ if ($customerId==$couponCustomerId->getCustomerId() && $couponCustomerId->getExpirationDate() >= $date) {
60
+ return $this;
61
+ }else {
62
+ Mage::getSingleton('checkout/session')->getQuote()
63
+ ->setCouponCode('')
64
+ ->collectTotals()
65
+ ->save();
66
+ }
67
+ }
68
+ }
69
+ }
70
+
71
+ public function customerRegisterOnCheckout(Varien_Event_Observer $observer)
72
+ {
73
+ $helper = Mage::helper('signuppromo');
74
+ $msg = Mage::getStoreConfig(self::XML_PATH_SUCCESS_MSG);
75
+ if($helper->isModEnabled()) {
76
+ $order = $observer->getEvent()->getOrder();
77
+ $quoteId = Mage::getModel('sales/order')->loadByIncrementId($order->getIncrementId())->getQuoteId();
78
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
79
+ //print_r($quote);
80
+ $method = $quote->getData('checkout_method');
81
+
82
+ if($method == 'register')
83
+ {
84
+ $customerId = $quote->getData('customer_id');
85
+ $email = $quote->getData('customer_email');
86
+ $name = $quote->getData('customer_firstname').' '.$quote->getData('customer_lastname');
87
+ $customerGroupId = $quote->getData('customer_group_id');
88
+ $helper->_genrateCoupon($customerId,$name,$customerGroupId,$email);
89
+ if($msg)
90
+ Mage::getSingleton('customer/session')->addNotice($msg);
91
+ }
92
+ }
93
+ }
94
+ }
app/code/community/Cybage/SignupPromo/Model/Resource/Rule/Collection.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cybage Signup Promotion Plugin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * It is available on the World Wide Web at:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you are unable to access it on the World Wide Web, please send an email
11
+ * To: Support_Magento@cybage.com. We will send you a copy of the source file.
12
+ *
13
+ * @category Signup Promotion Plugin
14
+ * @package Cybage_SignupPromo
15
+ * @copyright Copyright (c) 2014 Cybage Software Pvt. Ltd., India
16
+ * http://www.cybage.com/pages/centers-of-excellence/ecommerce/ecommerce.aspx
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ * @author Cybage Software Pvt. Ltd. <Support_Magento@cybage.com>
19
+ */
20
+
21
+ class Cybage_SignupPromo_Model_Resource_Rule_Collection extends Mage_SalesRule_Model_Resource_Rule_Collection
22
+ {
23
+ /**
24
+ * Filter collection by specified website, customer group, coupon code, date.
25
+ * Filter collection to use only active rules.
26
+ * Involved sorting by sort_order column.
27
+ *
28
+ * @param int $websiteId
29
+ * @param int $customerGroupId
30
+ * @param string $couponCode
31
+ * @param string|null $now
32
+ * @use $this->addWebsiteGroupDateFilter()
33
+ *
34
+ * @return Mage_SalesRule_Model_Resource_Rule_Collection
35
+ */
36
+ public function setValidationFilter($websiteId, $customerGroupId, $couponCode = '', $now = null)
37
+ {
38
+ if (!$this->getFlag('validation_filter')) {
39
+ /* We need to overwrite joinLeft if coupon is applied */
40
+ $this->getSelect()->reset();
41
+ Mage_Rule_Model_Resource_Rule_Collection_Abstract::_initSelect(); // Called the parent's parent fucntion
42
+
43
+ $this->addWebsiteGroupDateFilter($websiteId, $customerGroupId, $now);
44
+ $select = $this->getSelect();
45
+
46
+ if (strlen($couponCode)) {
47
+ $select->joinLeft(
48
+ array('rule_coupons' => $this->getTable('salesrule/coupon')),
49
+ 'main_table.rule_id = rule_coupons.rule_id ',
50
+ array('code','expiration_date')
51
+ );
52
+
53
+ $select->where('(main_table.coupon_type = ? ', Mage_SalesRule_Model_Rule::COUPON_TYPE_NO_COUPON)
54
+ ->orWhere('(main_table.coupon_type = ? AND rule_coupons.type = 0',
55
+ Mage_SalesRule_Model_Rule::COUPON_TYPE_AUTO)
56
+ ->orWhere('main_table.coupon_type = ? AND main_table.use_auto_generation = 1 ' .
57
+ 'AND rule_coupons.type = 1', Mage_SalesRule_Model_Rule::COUPON_TYPE_SPECIFIC)
58
+ ->orWhere('main_table.coupon_type = ? AND main_table.use_auto_generation = 0 ' .
59
+ 'AND rule_coupons.type = 0', Mage_SalesRule_Model_Rule::COUPON_TYPE_SPECIFIC)
60
+ ->orWhere('main_table.coupon_type = ? AND main_table.use_auto_generation = 0 ' .
61
+ 'AND rule_coupons.type = 1)', Cybage_SignupPromo_Model_Rule::COUPON_TYPE_AUTO_CUSTOMER_SPECIFIC)//Added this
62
+ ->where('rule_coupons.code = ?)', $couponCode);
63
+ } else {
64
+ $this->addFieldToFilter('main_table.coupon_type', Mage_SalesRule_Model_Rule::COUPON_TYPE_NO_COUPON);
65
+ }
66
+
67
+ $this->setOrder('sort_order', parent::SORT_ORDER_ASC);
68
+ $this->setFlag('validation_filter', true);
69
+ }
70
+
71
+ return $this;
72
+ }
73
+ }
app/code/community/Cybage/SignupPromo/Model/Rule.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cybage Signup Promotion Plugin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * It is available on the World Wide Web at:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you are unable to access it on the World Wide Web, please send an email
11
+ * To: Support_Magento@cybage.com. We will send you a copy of the source file.
12
+ *
13
+ * @category Signup Promotion Plugin
14
+ * @package Cybage_SignupPromo
15
+ * @copyright Copyright (c) 2014 Cybage Software Pvt. Ltd., India
16
+ * http://www.cybage.com/pages/centers-of-excellence/ecommerce/ecommerce.aspx
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ * @author Cybage Software Pvt. Ltd. <Support_Magento@cybage.com>
19
+ */
20
+
21
+ class Cybage_SignupPromo_Model_Rule extends Mage_SalesRule_Model_Rule
22
+ {
23
+ const COUPON_TYPE_AUTO_CUSTOMER_SPECIFIC = 4;
24
+
25
+ /**
26
+ * Retrieve coupon types
27
+ *
28
+ * @return array
29
+ */
30
+ public function getCouponTypes()
31
+ {
32
+ if ($this->_couponTypes === null) {
33
+ $this->_couponTypes = array(
34
+ Mage_SalesRule_Model_Rule::COUPON_TYPE_NO_COUPON => Mage::helper('salesrule')->__('No Coupon'),
35
+ Mage_SalesRule_Model_Rule::COUPON_TYPE_SPECIFIC => Mage::helper('salesrule')->__('Specific Coupon'),
36
+ self::COUPON_TYPE_AUTO_CUSTOMER_SPECIFIC =>Mage::helper('salesrule')->__('Auto generated Coupons for Customer Registration'),
37
+ );
38
+
39
+ $transport = new Varien_Object(array(
40
+ 'coupon_types' => $this->_couponTypes,
41
+ 'is_coupon_type_auto_visible' => false
42
+ ));
43
+
44
+ Mage::dispatchEvent('salesrule_rule_get_coupon_types', array('transport' => $transport));
45
+ $this->_couponTypes = $transport->getCouponTypes();
46
+
47
+ if ($transport->getIsCouponTypeAutoVisible()) {
48
+ $this->_couponTypes[Mage_SalesRule_Model_Rule::COUPON_TYPE_AUTO] = Mage::helper('salesrule')->__('Auto');
49
+ }
50
+ }
51
+
52
+ return $this->_couponTypes;
53
+ }
54
+
55
+ public function getCouponData($coupons = null)
56
+ {
57
+ $isLogin = Mage::getSingleton('customer/session')->isLoggedIn();
58
+ $tableName = Mage::getSingleton("core/resource")->getTableName('salesrule/rule');
59
+
60
+ if($coupons) {
61
+ $collection = Mage::getResourceModel('salesrule/coupon_collection')
62
+ ->addFieldToFilter('code',array('in'=>array($coupons)))
63
+ ->addGeneratedCouponsFilter();
64
+ $collection->getSelect()->join(array('t2' => $tableName),'main_table.rule_id = t2.rule_id');
65
+ }
66
+
67
+ if($isLogin && $coupons == null) {
68
+ $customerId = Mage::getSingleton('customer/session')->getCustomerId();
69
+ $customerCollection = Mage::getSingleton('customer/customer')->load($customerId);
70
+
71
+ $collection = Mage::getResourceModel('salesrule/coupon_collection')
72
+ ->addFieldToFilter('customer_id',$customerCollection->getId())
73
+ ->addGeneratedCouponsFilter();
74
+ $collection->getSelect()->join(array('t2' => $tableName),'main_table.rule_id = t2.rule_id',array('t2.name','t2.description'));
75
+ }
76
+
77
+ return $collection;
78
+ }
79
+ }
app/code/community/Cybage/SignupPromo/Model/Signuppromo.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cybage Signup Promotion Plugin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * It is available on the World Wide Web at:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you are unable to access it on the World Wide Web, please send an email
11
+ * To: Support_Magento@cybage.com. We will send you a copy of the source file.
12
+ *
13
+ * @category Signup Promotion Plugin
14
+ * @package Cybage_SignupPromo
15
+ * @copyright Copyright (c) 2014 Cybage Software Pvt. Ltd., India
16
+ * http://www.cybage.com/pages/centers-of-excellence/ecommerce/ecommerce.aspx
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ * @author Cybage Software Pvt. Ltd. <Support_Magento@cybage.com>
19
+ */
20
+
21
+ class Cybage_SignupPromo_Model_Signuppromo
22
+ {
23
+ const XML_PATH_ENABLED = 'signuppromo_section/signuppromo_group/active';
24
+ const XML_PATH_SUCCESS_MSG = 'signuppromo_section/signuppromo_group/success';
25
+ const XML_PATH_EMAIL_TEMPLATE = 'signuppromo_section/signuppromo_group/emailtemplate';
26
+ const XML_PATH_EMAIL_SENDER = 'signuppromo_section/signuppromo_group/identity';
27
+ const XML_PATH_COUPON_LENGTH = 'signuppromo_section/signuppromo_group/couponlength';
28
+ const XML_PATH_COUPON_PREFIX = 'signuppromo_section/signuppromo_group/couponprefix';
29
+ const XML_PATH_COUPON_EXPIRE = 'signuppromo_section/signuppromo_group/couponexpire';
30
+
31
+ private function generatePromoCode($length)
32
+ {
33
+ $rndId = crypt(uniqid(rand(),1));
34
+ $rndId = strip_tags(stripslashes($rndId));
35
+ $rndId = str_replace(array(".", "$"),"",$rndId);
36
+ $rndId = strrev(str_replace("/","",$rndId));
37
+
38
+ if (!is_null($rndId)) {
39
+ return Mage::getStoreConfig(self::XML_PATH_COUPON_PREFIX).strtoupper(substr($rndId, 0, $length));
40
+ }
41
+ return strtoupper($rndId);
42
+ }
43
+
44
+ public function addPromoCode($customerId, $ruleId)
45
+ {
46
+ $uniqueId = $this->generatePromoCode(Mage::getStoreConfig(self::XML_PATH_COUPON_LENGTH));
47
+ $coupon = Mage::getModel('salesrule/coupon');
48
+ $createdAt = date('Y-m-d', Mage::getModel('core/date')->timestamp(time()));
49
+ $days = Mage::getStoreConfig(self::XML_PATH_COUPON_EXPIRE);
50
+ $couponExpiryDate = date('Y-m-d', strtotime('+'.trim($days).'days'));
51
+
52
+ try {
53
+ $coupon->setId(null)
54
+ ->setRuleId($ruleId)
55
+ ->setUsageLimit(1)
56
+ ->setUsagePerCustomer(1)
57
+ ->setExpirationDate($couponExpiryDate)
58
+ ->setCreatedAt($createdAt)
59
+ ->setType(Mage_SalesRule_Helper_Coupon::COUPON_TYPE_SPECIFIC_AUTOGENERATED)
60
+ ->setCode($uniqueId)
61
+ ->setCustomerId($customerId);
62
+ $coupon->save();
63
+
64
+ return $uniqueId;
65
+ } catch (Exception $e) {
66
+ Mage::getSingleton('customer/session')->addError($e->getMessage());
67
+ return;
68
+ }
69
+ }
70
+
71
+ public function getCouponData($coupons = null)
72
+ {
73
+ $isLogin = Mage::getSingleton('customer/session')->isLoggedIn();
74
+ $tableName = Mage::getSingleton("core/resource")->getTableName('salesrule/rule');
75
+
76
+ if($coupons) {
77
+ $collection = Mage::getResourceModel('salesrule/coupon_collection')
78
+ ->addFieldToFilter('code',array('in'=>array($coupons)))
79
+ ->addGeneratedCouponsFilter();
80
+ $collection->getSelect()->join(array('t2' => $tableName),'main_table.rule_id = t2.rule_id');
81
+ }
82
+
83
+ if($isLogin && $coupons == null) {
84
+ $customerId = Mage::getSingleton('customer/session')->getCustomerId();
85
+ $customerCollection = Mage::getSingleton('customer/customer')->load($customerId);
86
+
87
+ $collection = Mage::getResourceModel('salesrule/coupon_collection')
88
+ ->addFieldToFilter('customer_id',$customerCollection->getId())
89
+ ->addGeneratedCouponsFilter();
90
+ $collection->getSelect()->join(array('t2' => $tableName),'main_table.rule_id = t2.rule_id',array('t2.name','t2.description'));
91
+ }
92
+
93
+ return $collection;
94
+ }
95
+ }
app/code/community/Cybage/SignupPromo/controllers/CustomerController.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cybage Signup Promotion Plugin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * It is available on the World Wide Web at:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you are unable to access it on the World Wide Web, please send an email
11
+ * To: Support_Magento@cybage.com. We will send you a copy of the source file.
12
+ *
13
+ * @category Signup Promotion Plugin
14
+ * @package Cybage_SignupPromo
15
+ * @copyright Copyright (c) 2014 Cybage Software Pvt. Ltd., India
16
+ * http://www.cybage.com/pages/centers-of-excellence/ecommerce/ecommerce.aspx
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ * @author Cybage Software Pvt. Ltd. <Support_Magento@cybage.com>
19
+ */
20
+
21
+ class Cybage_SignupPromo_CustomerController extends Mage_Core_Controller_Front_Action
22
+ {
23
+ public function preDispatch()
24
+ {
25
+ parent::preDispatch();
26
+ if (!Mage::getSingleton('customer/session')->authenticate($this)) {
27
+ $this->setFlag('', 'no-dispatch', true);
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Check if entered secret is valid
33
+ */
34
+ public function couponAction()
35
+ {
36
+ $this->loadLayout();
37
+ $this->_initLayoutMessages('customer/session');
38
+ $this->_initLayoutMessages('catalog/session');
39
+
40
+ $this->getLayout()->getBlock('head')->setTitle($this->__('My Coupons'));
41
+ $this->renderLayout();
42
+ }
43
+ }
app/code/community/Cybage/SignupPromo/etc/adminhtml.xml ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Cybage Signup Promotion Plugin
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * It is available on the World Wide Web at:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you are unable to access it on the World Wide Web, please send an email
12
+ * To: Support_Magento@cybage.com. We will send you a copy of the source file.
13
+ *
14
+ * @category Signup Promotion Plugin
15
+ * @package Cybage_SignupPromo
16
+ * @copyright Copyright (c) 2014 Cybage Software Pvt. Ltd., India
17
+ * http://www.cybage.com/pages/centers-of-excellence/ecommerce/ecommerce.aspx
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ * @author Cybage Software Pvt. Ltd. <Support_Magento@cybage.com>
20
+ */
21
+ -->
22
+ <config>
23
+ <acl>
24
+ <resources>
25
+ <admin>
26
+ <children>
27
+ <system>
28
+ <children>
29
+ <config>
30
+ <children>
31
+ <signuppromo_section translate="title" module="signuppromo">
32
+ <title>Pricerulesextended Section</title>
33
+ <sort_order>200</sort_order>
34
+ </signuppromo_section>
35
+ </children>
36
+ </config>
37
+ </children>
38
+ </system>
39
+ </children>
40
+ </admin>
41
+ </resources>
42
+ </acl>
43
+ </config>
app/code/community/Cybage/SignupPromo/etc/config.xml ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Cybage Signup Promotion Plugin
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * It is available on the World Wide Web at:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you are unable to access it on the World Wide Web, please send an email
12
+ * To: Support_Magento@cybage.com. We will send you a copy of the source file.
13
+ *
14
+ * @category Signup Promotion Plugin
15
+ * @package Cybage_SignupPromo
16
+ * @copyright Copyright (c) 2014 Cybage Software Pvt. Ltd., India
17
+ * http://www.cybage.com/pages/centers-of-excellence/ecommerce/ecommerce.aspx
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ * @author Cybage Software Pvt. Ltd. <Support_Magento@cybage.com>
20
+ */
21
+ -->
22
+ <config>
23
+ <modules>
24
+ <Cybage_SignupPromo>
25
+ <version>1.6.0.0</version>
26
+ <platform>ce</platform>
27
+ </Cybage_SignupPromo>
28
+ </modules>
29
+ <global>
30
+ <models>
31
+ <signuppromo>
32
+ <class>Cybage_SignupPromo_Model</class>
33
+ </signuppromo>
34
+ <salesrule>
35
+ <rewrite>
36
+ <rule>Cybage_SignupPromo_Model_Rule</rule>
37
+ </rewrite>
38
+ </salesrule>
39
+ <salesrule_resource>
40
+ <rewrite>
41
+ <rule_collection>Cybage_SignupPromo_Model_Resource_Rule_Collection</rule_collection>
42
+ </rewrite>
43
+ </salesrule_resource>
44
+ </models>
45
+ <resources>
46
+ <signuppromo_setup>
47
+ <setup>
48
+ <module>Cybage_SignupPromo</module>
49
+ </setup>
50
+ <connection>
51
+ <use>core_setup</use>
52
+ </connection>
53
+ </signuppromo_setup>
54
+ <signuppromo_write>
55
+ <connection>
56
+ <use>core_write</use>
57
+ </connection>
58
+ </signuppromo_write>
59
+ <signuppromo_read>
60
+ <connection>
61
+ <use>core_read</use>
62
+ </connection>
63
+ </signuppromo_read>
64
+ </resources>
65
+ <helpers>
66
+ <signuppromo>
67
+ <class>Cybage_SignupPromo_Helper</class>
68
+ </signuppromo>
69
+ </helpers>
70
+ <blocks>
71
+ <signuppromo>
72
+ <class>Cybage_SignupPromo_Block</class>
73
+ </signuppromo>
74
+ <adminhtml>
75
+ <rewrite>
76
+ <promo_quote_edit_tab_coupons_grid>Cybage_SignupPromo_Block_Promo_Quote_Edit_Tab_Coupons_Grid</promo_quote_edit_tab_coupons_grid>
77
+ <!--promo_quote_edit_tab_main>Cybage_SignupPromo_Block_Promo_Quote_Edit_Tab_Main</promo_quote_edit_tab_main-->
78
+ </rewrite>
79
+ </adminhtml>
80
+ </blocks>
81
+ <template>
82
+ <email>
83
+ <signuppromo_section_signuppromo_group_emailtemplate module="signuppromo" translate="label">
84
+ <label>Discount coupons for New Customer Registration</label>
85
+ <file>signuppromo.html</file>
86
+ <type>html</type>
87
+ </signuppromo_section_signuppromo_group_emailtemplate>
88
+ </email>
89
+ </template>
90
+ </global>
91
+ <frontend>
92
+ <events>
93
+ <customer_register_success>
94
+ <observers>
95
+ <customerRegisterSave>
96
+ <type>singleton</type>
97
+ <class>Cybage_SignupPromo_Model_Observer</class>
98
+ <method>customerRegisterSave</method>
99
+ </customerRegisterSave>
100
+ </observers>
101
+ </customer_register_success>
102
+ <sales_order_place_before>
103
+ <observers>
104
+ <customerRegisterOnCheckout>
105
+ <type>singleton</type>
106
+ <class>Cybage_SignupPromo_Model_Observer</class>
107
+ <method>customerRegisterOnCheckout</method>
108
+ </customerRegisterOnCheckout>
109
+ </observers>
110
+ </sales_order_place_before>
111
+ <salesrule_validator_process>
112
+ <observers>
113
+ <checkEmailAddress>
114
+ <type>singleton</type>
115
+ <class>Cybage_SignupPromo_Model_Observer</class>
116
+ <method>checkSignupPromoCoupon</method>
117
+ </checkEmailAddress>
118
+ </observers>
119
+ </salesrule_validator_process>
120
+ </events>
121
+ <routers>
122
+ <signupPromo>
123
+ <use>standard</use>
124
+ <args>
125
+ <module>Cybage_SignupPromo</module>
126
+ <frontName>signuppromo</frontName>
127
+ </args>
128
+ </signupPromo>
129
+ </routers>
130
+ <layout>
131
+ <updates>
132
+ <signuppromo>
133
+ <file>signuppromo.xml</file>
134
+ </signuppromo>
135
+ </updates>
136
+ </layout>
137
+ </frontend>
138
+ <adminhtml>
139
+ <events>
140
+ <adminhtml_customer_save_after>
141
+ <observers>
142
+ <customerAdminRegistration>
143
+ <type>singleton</type>
144
+ <class>Cybage_SignupPromo_Model_Observer</class>
145
+ <method>customerRegisterSave</method>
146
+ </customerAdminRegistration>
147
+ </observers>
148
+ </adminhtml_customer_save_after>
149
+ </events>
150
+ </adminhtml>
151
+ <default>
152
+ <signuppromo_section>
153
+ <signuppromo_group>
154
+ <couponlength>6</couponlength>
155
+ <couponprefix>REG</couponprefix>
156
+ <couponexpire>5</couponexpire>
157
+ <couponemailnotification>0</couponemailnotification>
158
+ </signuppromo_group>
159
+ </signuppromo_section>
160
+ </default>
161
+ </config>
app/code/community/Cybage/SignupPromo/etc/system.xml ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <!--
3
+ /**
4
+ * Cybage Signup Promotion Plugin
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * It is available on the World Wide Web at:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you are unable to access it on the World Wide Web, please send an email
12
+ * To: Support_Magento@cybage.com. We will send you a copy of the source file.
13
+ *
14
+ * @category Signup Promotion Plugin
15
+ * @package Cybage_SignupPromo
16
+ * @copyright Copyright (c) 2014 Cybage Software Pvt. Ltd., India
17
+ * http://www.cybage.com/pages/centers-of-excellence/ecommerce/ecommerce.aspx
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ * @author Cybage Software Pvt. Ltd. <Support_Magento@cybage.com>
20
+ */
21
+ -->
22
+ <config>
23
+ <sections>
24
+ <signuppromo_section module="signuppromo" translate="label">
25
+ <label>New Customer Registraton Rule</label>
26
+ <sort_order>1200</sort_order>
27
+ <show_in_default>1</show_in_default>
28
+ <show_in_website>1</show_in_website>
29
+ <show_in_store>1</show_in_store>
30
+ <tab>customer</tab>
31
+ <groups>
32
+ <signuppromo_group translate="label">
33
+ <label>Configurations</label>
34
+ <sort_order>10</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>1</show_in_store>
38
+ <fields>
39
+ <active translate="label">
40
+ <label>Enabled</label>
41
+ <frontend_type>select</frontend_type>
42
+ <source_model>adminhtml/system_config_source_yesno</source_model>
43
+ <sort_order>1</sort_order>
44
+ <show_in_default>1</show_in_default>
45
+ <show_in_website>1</show_in_website>
46
+ <show_in_store>1</show_in_store>
47
+ </active>
48
+ <couponlength translate="label">
49
+ <label>Coupon Code Length</label>
50
+ <frontend_type>text</frontend_type>
51
+ <sort_order>2</sort_order>
52
+ <show_in_default>1</show_in_default>
53
+ <show_in_website>1</show_in_website>
54
+ <show_in_store>1</show_in_store>
55
+ </couponlength>
56
+ <couponexpire translate="label">
57
+ <label>Coupon Code Expire</label>
58
+ <frontend_type>text</frontend_type>
59
+ <validate>validate-digits</validate>
60
+ <comment>Enter the customer coupon expiry date</comment>
61
+ <sort_order>2</sort_order>
62
+ <show_in_default>1</show_in_default>
63
+ <show_in_website>1</show_in_website>
64
+ <show_in_store>1</show_in_store>
65
+ </couponexpire>
66
+ <couponprefix translate="label">
67
+ <label>Coupon Code Prefix</label>
68
+ <frontend_type>text</frontend_type>
69
+ <comment>Prefix for the Coupon</comment>
70
+ <sort_order>3</sort_order>
71
+ <show_in_default>1</show_in_default>
72
+ <show_in_website>1</show_in_website>
73
+ <show_in_store>1</show_in_store>
74
+ </couponprefix>
75
+ <couponemailnotification>
76
+ <label>Coupon Email Notification</label>
77
+ <frontend_type>select</frontend_type>
78
+ <source_model>adminhtml/system_config_source_yesno</source_model>
79
+ <sort_order>4</sort_order>
80
+ <show_in_default>1</show_in_default>
81
+ <show_in_website>1</show_in_website>
82
+ <show_in_store>1</show_in_store>
83
+ </couponemailnotification>
84
+ <success translate="label">
85
+ <label>Coupon Generated Success Message</label>
86
+ <frontend_type>text</frontend_type>
87
+ <comment></comment>
88
+ <sort_order>5</sort_order>
89
+ <show_in_default>1</show_in_default>
90
+ <show_in_website>1</show_in_website>
91
+ <show_in_store>1</show_in_store>
92
+ </success>
93
+ <identity translate="label">
94
+ <label>Email Sender</label>
95
+ <frontend_type>select</frontend_type>
96
+ <source_model>adminhtml/system_config_source_email_identity</source_model>
97
+ <sort_order>6</sort_order>
98
+ <show_in_default>1</show_in_default>
99
+ <show_in_website>1</show_in_website>
100
+ <show_in_store>1</show_in_store>
101
+ </identity>
102
+ <emailtemplate translate="label">
103
+ <label>New Customer Registraton Coupon Template</label>
104
+ <frontend_type>select</frontend_type>
105
+ <source_model>adminhtml/system_config_source_email_template</source_model>
106
+ <sort_order>20</sort_order>
107
+ <show_in_default>1</show_in_default>
108
+ <show_in_website>1</show_in_website>
109
+ <show_in_store>1</show_in_store>
110
+ </emailtemplate>
111
+ </fields>
112
+ </signuppromo_group>
113
+ </groups>
114
+ </signuppromo_section>
115
+ </sections>
116
+ </config>
app/code/community/Cybage/SignupPromo/sql/signuppromo_setup/mysql4-install-1.6.0.0.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cybage Signup Promotion Plugin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * It is available on the World Wide Web at:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you are unable to access it on the World Wide Web, please send an email
11
+ * To: Support_Magento@cybage.com. We will send you a copy of the source file.
12
+ *
13
+ * @category Signup Promotion Plugin
14
+ * @package Cybage_SignupPromo
15
+ * @copyright Copyright (c) 2014 Cybage Software Pvt. Ltd., India
16
+ * http://www.cybage.com/pages/centers-of-excellence/ecommerce/ecommerce.aspx
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ * @author Cybage Software Pvt. Ltd. <Support_Magento@cybage.com>
19
+ */
20
+
21
+ $installer = $this;
22
+ $installer->startSetup();
23
+ $installer->run("
24
+ ALTER TABLE salesrule_coupon ADD COLUMN customer_id int(11) NULL;
25
+ ");
26
+ $installer->endSetup();
app/design/frontend/base/default/layout/signuppromo.xml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Cybage Signup Promotion Plugin
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * It is available on the World Wide Web at:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you are unable to access it on the World Wide Web, please send an email
12
+ * To: Support_Magento@cybage.com. We will send you a copy of the source file.
13
+ *
14
+ * @category Signup Promotion Plugin
15
+ * @package Cybage_SignupPromo
16
+ * @copyright Copyright (c) 2014 Cybage Software Pvt. Ltd., India
17
+ * http://www.cybage.com/pages/centers-of-excellence/ecommerce/ecommerce.aspx
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ * @author Cybage Software Pvt. Ltd. <Support_Magento@cybage.com>
20
+ */
21
+ -->
22
+ <layout version="0.1.0">
23
+ <customer_account>
24
+ <reference name="customer_account_navigation">
25
+ <action method="addLink" translate="label" module="customer"><name>customer_coupon</name><path>signuppromo/customer/coupon/</path><label>My Coupon</label></action>
26
+ </reference>
27
+ </customer_account>
28
+ <customer_account_index translate="label">
29
+ <reference name="customer_account_dashboard">
30
+ <block type="signuppromo/coupon" name="customer.account.dashboard.extra" as="customer.account.dashboard.extra" template="signuppromo/dashboardcouponinfo.phtml"/>
31
+ </reference>
32
+ </customer_account_index>
33
+ <signuppromo_customer_coupon translate="label">
34
+ <label>My Coupons</label>
35
+ <update handle="customer_account"/>
36
+ <reference name="my.account.wrapper">
37
+ <block type="signuppromo/coupon" name="signuppromo_coupon" template="signuppromo/coupon.phtml"/>
38
+ </reference>
39
+ </signuppromo_customer_coupon>
40
+ </layout>
app/design/frontend/base/default/template/signuppromo/coupon.phtml ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cybage Signup Promotion Plugin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * It is available on the World Wide Web at:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you are unable to access it on the World Wide Web, please send an email
11
+ * To: Support_Magento@cybage.com. We will send you a copy of the source file.
12
+ *
13
+ * @category Signup Promotion Plugin
14
+ * @package Cybage_SignupPromo
15
+ * @copyright Copyright (c) 2014 Cybage Software Pvt. Ltd., India
16
+ * http://www.cybage.com/pages/centers-of-excellence/ecommerce/ecommerce.aspx
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ * @author Cybage Software Pvt. Ltd. <Support_Magento@cybage.com>
19
+ */
20
+
21
+ $couponData = $this->getCouponData();
22
+ ?>
23
+ <div class="page-title">
24
+ <h1><?php echo $this->__('My Coupons') ?></h1>
25
+ </div>
26
+ <?php if( count($couponData->getData()) > 0 ): ?>
27
+ <table class="data-table" id="my-orders-table">
28
+ <col width="1" />
29
+ <col width="1" />
30
+ <col />
31
+ <col width="1" />
32
+ <col width="1" />
33
+ <col width="1" />
34
+ <thead>
35
+ <tr>
36
+ <th>Coupon #</th>
37
+ <th>Expiry Date</th>
38
+ <th>Offer</th>
39
+ <th><span class="nobr">Used</span></th>
40
+ <th><span class="nobr">Times Used</span></th>
41
+ </tr>
42
+ </thead>
43
+ <tbody>
44
+ <?php foreach($couponData as $val): ?>
45
+ <tr>
46
+ <td><?php echo $this->__($val->getCode()) ?></td>
47
+ <td><span class="nobr"><?php echo $this->__(date('d-m-Y',strtotime($val->getExpirationDate()))) ?></span></td>
48
+ <td><?php echo $this->__($val->getDescription()) ?></td>
49
+ <td><span class="price"><?php echo $this->__($val->getTimesUsed() > 0 ? 'yes':'no') ?></span></td>
50
+ <td><em><?php echo $this->__($val->getTimesUsed()) ?></em></td>
51
+ </tr>
52
+ <?php endforeach; ?>
53
+ </tbody>
54
+ </table>
55
+ <?php else: ?>
56
+ <p><?php echo $this->__('You have no coupons.'); ?></p>
57
+ <?php endif; ?>
app/design/frontend/base/default/template/signuppromo/dashboardcouponinfo.phtml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cybage Signup Promotion Plugin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * It is available on the World Wide Web at:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you are unable to access it on the World Wide Web, please send an email
11
+ * To: Support_Magento@cybage.com. We will send you a copy of the source file.
12
+ *
13
+ * @category Signup Promotion Plugin
14
+ * @package Cybage_SignupPromo
15
+ * @copyright Copyright (c) 2014 Cybage Software Pvt. Ltd., India
16
+ * http://www.cybage.com/pages/centers-of-excellence/ecommerce/ecommerce.aspx
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ * @author Cybage Software Pvt. Ltd. <Support_Magento@cybage.com>
19
+ */
20
+
21
+ $couponData = $this->getCouponData();
22
+ ?>
23
+ <?php if( count($couponData->getData()) > 0 ): ?>
24
+ <div class="col2-set">
25
+ <h4><?php echo $this->__('My Coupons') ?></h4>
26
+ <table class="data-table" id="my-orders-table">
27
+ <col width="1" />
28
+ <col width="1" />
29
+ <col width="1" />
30
+ <thead>
31
+ <tr>
32
+ <th>Coupon</th>
33
+ <th>Expiry Date</th>
34
+ <th>Offer</th>
35
+ </tr>
36
+ </thead>
37
+ <tbody>
38
+ <?php foreach($couponData as $val): ?>
39
+ <tr>
40
+ <td><?php echo $this->__($val->getCode()) ?></td>
41
+ <td><span class="nobr"><?php echo $this->__(date('d-m-Y',strtotime($val->getExpirationDate()))) ?></span></td>
42
+ <td><?php echo $this->__($val->getDescription()) ?></td>
43
+ <!--td><span class="price"><?php echo $this->__($val->getTimesUsed() > 0 ? 'yes':'no') ?></span></td>
44
+ <td><em><?php echo $this->__($val->getTimesUsed()) ?></em></td-->
45
+ </tr>
46
+ <?php endforeach; ?>
47
+ </tbody>
48
+ </table>
49
+ </div>
50
+ <?php endif; ?>
app/design/frontend/base/default/template/signuppromo/email/template.phtml ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cybage Signup Promotion Plugin
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * It is available on the World Wide Web at:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you are unable to access it on the World Wide Web, please send an email
11
+ * To: Support_Magento@cybage.com. We will send you a copy of the source file.
12
+ *
13
+ * @category Signup Promotion Plugin
14
+ * @package Cybage_SignupPromo
15
+ * @copyright Copyright (c) 2014 Cybage Software Pvt. Ltd., India
16
+ * http://www.cybage.com/pages/centers-of-excellence/ecommerce/ecommerce.aspx
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ * @author Cybage Software Pvt. Ltd. <Support_Magento@cybage.com>
19
+ */
20
+
21
+ $couponData = $this->getCoupons();
22
+ ?>
23
+ <body style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
24
+ <table class="data-table" id="my-orders-table">
25
+ <col width="1" />
26
+ <col width="1" />
27
+ <col />
28
+ <col width="1" />
29
+ <col width="1" />
30
+ <col width="1" />
31
+ <thead>
32
+ <tr>
33
+ <th>Coupon #</th>
34
+ <th>Expiry Date</th>
35
+ <th>Offer</th>
36
+ </tr>
37
+ </thead>
38
+ <tbody>
39
+ <?php foreach($couponData as $val): ?>
40
+ <tr>
41
+ <td><?php echo $this->__($val->getCode()) ?></td>
42
+ <td><span class="nobr"><?php echo $this->__(date('d-m-Y',strtotime($val->getExpirationDate()))) ?></span></td>
43
+ <td><?php echo $this->__($val->getDescription()); ?></td>
44
+ </tr>
45
+ <?php endforeach; ?>
46
+ </tbody>
47
+ </table>
48
+ </body>
app/etc/modules/Cybage_SignupPromo.xml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Cybage Signup Promotion Plugin
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * It is available on the World Wide Web at:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you are unable to access it on the World Wide Web, please send an email
12
+ * To: Support_Magento@cybage.com. We will send you a copy of the source file.
13
+ *
14
+ * @category Signup Promotion Plugin
15
+ * @package Cybage_SignupPromo
16
+ * @copyright Copyright (c) 2014 Cybage Software Pvt. Ltd., India
17
+ * http://www.cybage.com/pages/centers-of-excellence/ecommerce/ecommerce.aspx
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ * @author Cybage Software Pvt. Ltd. <Support_Magento@cybage.com>
20
+ */
21
+ -->
22
+ <config>
23
+ <modules>
24
+ <Cybage_SignupPromo>
25
+ <active>true</active>
26
+ <codePool>community</codePool>
27
+ </Cybage_SignupPromo>
28
+ </modules>
29
+ </config>
app/locale/en_US/template/email/signuppromo.html ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {* This is a comment block
2
+
3
+ Available vars in this template:
4
+ - name Recipient name
5
+ - email Recipient Email address
6
+ - product_name Product name
7
+ - product_url Url for product
8
+ - product_image Url for product small image (75 px)
9
+ - message Sender custom message
10
+ - sender_name Sender name
11
+ - sender_email Sender email
12
+
13
+ Use vars: {{var var_name}}
14
+ *}<!--@subject Registration Bonus!!@-->
15
+ <!--@vars
16
+ {"htmlescape var=$name":"Recipient Name",
17
+ "var product_url":"Url for Product",
18
+ "var product_name":"Product Name",
19
+ "var message":"Sender Message"}
20
+ @-->
21
+
22
+ Registration Bonus!<br /><br />Hello {{htmlescape var=$name}} <br />
23
+ {{block type='signuppromo/signuppromo' area='frontend' template='signuppromo/email/template.phtml' coupon_codes=$coupon_codes}}
package.xml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Cybage_SignupPromo</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>The Sign-up Promotion plug-in provides the discount functionality for new sign-up customers. It generates random coupon codes for the customers.</summary>
10
+ <description>The Sign-up Promotion plug-in provides the discount functionality for new sign-up customers. It generates random coupon codes for the customers.&#xD;
11
+ Features&#xD;
12
+ &#x2022; Helps in promoting the Magento site whenever a new customer logs in.&#xD;
13
+ &#x2022; Easy reporting of the discount amount for an order.</description>
14
+ <notes>After installation of the Marketplace plugin please clear the cache.</notes>
15
+ <authors><author><name>Cybage Software Pvt. Ltd.</name><user>cybage</user><email>Support_Magento@cybage.com</email></author></authors>
16
+ <date>2014-06-11</date>
17
+ <time>13:39:29</time>
18
+ <contents><target name="magecommunity"><dir name="Cybage"><dir name="SignupPromo"><dir name="Block"><file name="Coupon.php" hash="153aaf617f815bf61b5fa9c619976599"/><dir name="Promo"><dir name="Quote"><dir name="Edit"><dir name="Tab"><dir name="Coupons"><dir name="Column"><dir name="Renderer"><file name="Email.php" hash="3d6aeab71dd44df87227b36753880783"/></dir></dir><file name="Grid.php" hash="73aaa568756a8950617afdbd6429bc87"/></dir></dir></dir></dir></dir><file name="SignupPromo.php" hash="6c00a11376d63f409f360bf158d68576"/></dir><dir name="Helper"><file name="Data.php" hash="f2c963de8e5c34f15dd0a76e353b348d"/></dir><dir name="Model"><file name="Observer.php" hash="6096765787ba647a921c3aee824fb8bc"/><dir name="Resource"><dir name="Rule"><file name="Collection.php" hash="6bc7de49aaae34f393baec03495bbd20"/></dir></dir><file name="Rule.php" hash="015b5483fe6174e742f28bdd439eaadf"/><file name="Signuppromo.php" hash="158a384c76c075305c860d5a9277bdac"/></dir><dir name="controllers"><file name="CustomerController.php" hash="877c2457f595113006a27f3a0d3e0560"/></dir><dir name="etc"><file name="adminhtml.xml" hash="3487ba7b07cddffef8605f020808a538"/><file name="config.xml" hash="3a4d50d341b9b6c60365ef3dbe87e924"/><file name="system.xml" hash="bbf68878413291b820b8ce61a1ddc753"/></dir><dir name="sql"><dir name="signuppromo_setup"><file name="mysql4-install-1.6.0.0.php" hash="c06be0d0d775ee9b480734402ac08d07"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="signuppromo.xml" hash="14703ff5856ce49236161654d3a447de"/></dir><dir name="template"><dir name="signuppromo"><file name="coupon.phtml" hash="cbe2bd13a62a9bdb0e49ceffb79ffe28"/><file name="dashboardcouponinfo.phtml" hash="f821607b9a45853ff3ef69ee824b3607"/><dir name="email"><file name="template.phtml" hash="30b1f55093d557ab5a8837e5802de372"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Cybage_SignupPromo.xml" hash="061645c8b59e4bc9c1dc9727ea0481ad"/></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><file name="signuppromo.html" hash="442a772b9595fc107e2502a13864878c"/></dir></dir></dir></target></contents>
19
+ <compatible/>
20
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
21
+ </package>