Discount_Coupon_Code_at_Checkout_Steps - Version 0.1.0

Version Notes

Checkout Discount Coupon Step extension will add new step called 'Discount Coupon' on the Onepage checkout, where user can enter the discount coupon code during the checkout process.

Features:

Allow to enter discount coupon code on the Onepage checkout page.

Apply entered coupon code and display discount amount on the 'Order Review' step of the Onepage checkout.

Download this release

Release Info

Developer Deepak mnakotia
Extension Discount_Coupon_Code_at_Checkout_Steps
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

app/code/local/Magegeeks/Checkoutdiscountcoupon/Block/Checkout/Cart.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @Package Magegeeks_Checkoutdiscountcoupon
4
+ * @Author Deepak Mankotia
5
+ * @Email deepakmankotiacse@gmail.com
6
+ */
7
+ class Magegeeks_Checkoutdiscountcoupon_Block_Checkout_Cart extends Mage_Checkout_Block_Onepage
8
+ {
9
+ protected function _prepareLayout(){
10
+ if(Mage::getStoreConfig('magegeeks_checkoutdiscountcoupon/checkoutdiscountcoupon_config/checkoutdiscountcoupon_remove_default')){
11
+ $this->getLayout()->getBlock('checkout.cart')->unsetChild('coupon');
12
+ }
13
+ }
14
+ }
app/code/local/Magegeeks/Checkoutdiscountcoupon/Block/Checkout/Onepage.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @Package Magegeeks_Checkoutdiscountcoupon
4
+ * @Author Deepak Mankotia
5
+ * @Email deepakmankotiacse@gmail.com
6
+ */
7
+ class Magegeeks_Checkoutdiscountcoupon_Block_Checkout_Onepage extends Mage_Checkout_Block_Onepage
8
+ {
9
+
10
+ public function getSteps()
11
+ {
12
+ $steps = array();
13
+ $stepCodes = $this->_getStepCodes();
14
+
15
+ if ($this->isCustomerLoggedIn()) {
16
+ $stepCodes = array_diff($stepCodes, array('login'));
17
+ }
18
+
19
+ foreach ($stepCodes as $step) {
20
+ $steps[$step] = $this->getCheckout()->getStepData($step);
21
+ }
22
+
23
+ $steps['discountcode'] = array('label'=>'Discount Coupon','is_show'=>true);
24
+
25
+ return $steps;
26
+ }
27
+
28
+
29
+ protected function _getStepCodes()
30
+ {
31
+ $default_setting=array('login', 'billing', 'shipping', 'shipping_method', 'payment', 'review');
32
+ $discountcode=array('discountcode');
33
+
34
+ $value=Mage::getStoreConfig('magegeeks_checkoutdiscountcoupon/checkoutdiscountcoupon_config/checkoutdiscountcoupon_enable')? array_splice( $default_setting, Mage::getStoreConfig('magegeeks_checkoutdiscountcoupon/checkoutdiscountcoupon_config/checkoutdiscountcoupon_step'), 0, $discountcode ):$default_setting;
35
+
36
+
37
+ return $default_setting;
38
+ }
39
+ }
app/code/local/Magegeeks/Checkoutdiscountcoupon/Block/Checkout/Onepage/Discountcode.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @Package Magegeeks_Checkoutdiscountcoupon
4
+ * @Author Deepak Mankotia
5
+ * @Email deepakmankotiacse@gmail.com
6
+ */
7
+ class Magegeeks_Checkoutdiscountcoupon_Block_Checkout_Onepage_Discountcode extends Mage_Core_Block_Template
8
+ {
9
+ public function _prepareLayout()
10
+ {
11
+ return parent::_prepareLayout();
12
+ }
13
+
14
+ public function isShow(){
15
+ return Mage::getStoreConfig('magegeeks_checkoutdiscountcoupon/checkoutdiscountcoupon_config/checkoutdiscountcoupon_enable');
16
+ }
17
+ }
app/code/local/Magegeeks/Checkoutdiscountcoupon/Block/Checkout/Onepage/Progress.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @Package Magegeeks_Checkoutdiscountcoupon
4
+ * @Author Deepak Mankotia
5
+ * @Email deepakmankotiacse@gmail.com
6
+ */
7
+ class Magegeeks_Checkoutdiscountcoupon_Block_Checkout_Onepage_Progress extends Mage_Checkout_Block_Onepage_Progress
8
+ {
9
+
10
+ protected function _getStepCodes()
11
+ {
12
+ $default_setting=array('login', 'billing', 'shipping', 'shipping_method', 'payment', 'review');
13
+ $discountcode=array('discountcode');
14
+
15
+ $steps=array_splice( $default_setting, Mage::getStoreConfig('magegeeks_checkoutdiscountcoupon/checkoutdiscountcoupon_config/checkoutdiscountcoupon_step'), 0, $discountcode );
16
+
17
+ $value=Mage::getStoreConfig('magegeeks_checkoutdiscountcoupon/checkoutdiscountcoupon_config/checkoutdiscountcoupon_enable')?$steps:parent::_getStepCodes();
18
+
19
+ return $value;
20
+ }
21
+
22
+
23
+ public function isDiscountcodeStepComplete()
24
+ {
25
+ $stepsRevertIndex = array_flip($this->_getStepCodes());
26
+
27
+ $toStep = $this->getRequest()->getParam('toStep');
28
+
29
+ if ($stepsRevertIndex['discountcode'] >= $stepsRevertIndex[$toStep]) {
30
+ return false;
31
+ }
32
+
33
+ return true;
34
+ }
35
+
36
+ }
app/code/local/Magegeeks/Checkoutdiscountcoupon/Helper/Data.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @Package Magegeeks_Checkoutdiscountcoupon
4
+ * @Author Deepak Mankotia
5
+ * @Email deepakmankotiacse@gmail.com
6
+ */
7
+ class Magegeeks_Checkoutdiscountcoupon_Helper_Data extends Mage_Core_Helper_Abstract
8
+ {
9
+
10
+ }
app/code/local/Magegeeks/Checkoutdiscountcoupon/Model/Observer.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @Package Magegeeks_Checkoutdiscountcoupon
4
+ * @Author Deepak Mankotia
5
+ * @Email deepakmankotiacse@gmail.com
6
+ */
7
+ class Magegeeks_Checkoutdiscountcoupon_Model_Observer
8
+ {
9
+ /**
10
+ * Make sure after save billing step it go to vendor step
11
+ * @param unknown_type $observer
12
+ */
13
+ public function controller_action_postdispatch_checkout_onepage_saveBilling($observer){
14
+
15
+ if(!Mage::getStoreConfig('magegeeks_checkoutdiscountcoupon/checkoutdiscountcoupon_config/checkoutdiscountcoupon_enable') OR $this->checkNextStep() != 3) return;
16
+
17
+ $controller = $observer->getData('controller_action');
18
+ $body = Mage::helper('core')->jsonDecode($controller->getResponse()->getBody());
19
+ if($body['goto_section']=='shipping_method') $body['goto_section'] = 'discountcode';
20
+ $body['update_section'] = array(
21
+ 'name' => 'shipping-method',
22
+ 'html' => $this->_getVendorHtml($controller)
23
+ );
24
+ $body['allow_sections'] = array('billing','shipping','discountcode');
25
+ $controller->getResponse()->setBody(Mage::helper('core')->jsonEncode($body));
26
+ }
27
+ /**
28
+ * Make sure after save shipping step it go to vendor step
29
+ * @param unknown_type $observer
30
+ */
31
+ public function controller_action_postdispatch_checkout_onepage_saveShipping($observer){
32
+
33
+ if(!Mage::getStoreConfig('magegeeks_checkoutdiscountcoupon/checkoutdiscountcoupon_config/checkoutdiscountcoupon_enable') OR $this->checkNextStep() != 3) return;
34
+
35
+ $controller = $observer->getData('controller_action');
36
+ $body = Mage::helper('core')->jsonDecode($controller->getResponse()->getBody());
37
+ if($body['goto_section']=='shipping_method') $body['goto_section'] = 'discountcode';
38
+ $body['update_section'] = array(
39
+ 'name' => 'shipping-method',
40
+ 'html' => $this->_getVendorHtml($controller)
41
+ );
42
+ $controller->getResponse()->setBody(Mage::helper('core')->jsonEncode($body));
43
+ }
44
+ /**
45
+ * Make sure after save shipping Method step it go to vendor step
46
+ * @param unknown_type $observer
47
+ */
48
+ public function controller_action_postdispatch_checkout_onepage_saveShippingMethod($observer){
49
+ if(!Mage::getStoreConfig('magegeeks_checkoutdiscountcoupon/checkoutdiscountcoupon_config/checkoutdiscountcoupon_enable') OR $this->checkNextStep() != 4) return;
50
+
51
+ $controller = $observer->getData('controller_action');
52
+ $body = Mage::helper('core')->jsonDecode($controller->getResponse()->getBody());
53
+ if($body['goto_section']=='payment_method') $body['goto_section'] = 'discountcode';
54
+ $body['update_section'] = array(
55
+ 'name' => 'payment-method',
56
+ 'html' => $this->_getVendorHtml($controller)
57
+ );
58
+ $controller->getResponse()->setBody(Mage::helper('core')->jsonEncode($body));
59
+ }
60
+ /**
61
+ * Make sure after save Payment step it go to vendor step
62
+ * @param unknown_type $observer
63
+ */
64
+ public function controller_action_postdispatch_checkout_onepage_savePayment($observer){
65
+ if(!Mage::getStoreConfig('magegeeks_checkoutdiscountcoupon/checkoutdiscountcoupon_config/checkoutdiscountcoupon_enable') OR $this->checkNextStep() != 5) return;
66
+
67
+ $controller = $observer->getData('controller_action');
68
+ $body = Mage::helper('core')->jsonDecode($controller->getResponse()->getBody());
69
+ if($body['goto_section']=='review') $body['goto_section'] = 'discountcode';
70
+ $body['update_section'] = array(
71
+ 'name' => 'review',
72
+ 'html' => $this->_getVendorHtml($controller)
73
+ );
74
+ $controller->getResponse()->setBody(Mage::helper('core')->jsonEncode($body));
75
+ }
76
+
77
+ /**
78
+ * Get shipping method step html
79
+ *
80
+ * @return string
81
+ */
82
+ protected function _getVendorHtml($controller)
83
+ {
84
+ $layout = $controller->getLayout();
85
+ $update = $layout->getUpdate();
86
+ $update->load('checkout_onepage_discountcode');
87
+ $layout->generateXml();
88
+ $layout->generateBlocks();
89
+ $output = $layout->getOutput();
90
+ return $output;
91
+ }
92
+
93
+ /**
94
+ * Get Next Step
95
+ *
96
+ **/
97
+ protected function checkNextStep()
98
+ {
99
+
100
+ $steps=Mage::getStoreConfig('magegeeks_checkoutdiscountcoupon/checkoutdiscountcoupon_config/checkoutdiscountcoupon_step');
101
+
102
+ return $steps;
103
+
104
+
105
+ }
106
+
107
+
108
+ }
app/code/local/Magegeeks/Checkoutdiscountcoupon/Model/Source.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Magegeeks_Checkoutdiscountcoupon_Model_Source
3
+ {
4
+ public function toOptionArray()
5
+ {
6
+ return array(
7
+
8
+ array('value' => '3', 'label' => 'Add after Billing/shipping Address'),
9
+ array('value' => '4', 'label' =>'Add after Shipping Methods'),
10
+ array('value' => '5', 'label' =>'Add after Payment Methods'),
11
+ );
12
+ }
13
+ }
14
+
app/code/local/Magegeeks/Checkoutdiscountcoupon/controllers/IndexController.php ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * @Package Magegeeks_Checkoutdiscountcoupon
4
+ * @Author Deepak Mankotia
5
+ * @Email deepakmankotiacse@gmail.com
6
+ */
7
+ class Magegeeks_Checkoutdiscountcoupon_IndexController extends Mage_Core_Controller_Front_Action
8
+ {
9
+
10
+ protected function _expireAjax()
11
+ {
12
+ if (!$this->getOnepage()->getQuote()->hasItems()
13
+ || $this->getOnepage()->getQuote()->getHasError()
14
+ || $this->getOnepage()->getQuote()->getIsMultiShipping()) {
15
+ $this->_ajaxRedirectResponse();
16
+ return true;
17
+ }
18
+ $action = $this->getRequest()->getActionName();
19
+ if (Mage::getSingleton('checkout/session')->getCartWasUpdated(true)
20
+ && !in_array($action, array('index', 'progress'))) {
21
+ $this->_ajaxRedirectResponse();
22
+ return true;
23
+ }
24
+
25
+ return false;
26
+ }
27
+
28
+
29
+ protected function _ajaxRedirectResponse()
30
+ {
31
+ $this->getResponse()
32
+ ->setHeader('HTTP/1.1', '403 Session Expired')
33
+ ->setHeader('Login-Required', 'true')
34
+ ->sendResponse();
35
+ return $this;
36
+ }
37
+
38
+ /**
39
+ * Get shipping method step html
40
+ *
41
+ * @return string
42
+ */
43
+ protected function _getShippingMethodsHtml()
44
+ {
45
+ $layout = $this->getLayout();
46
+ $update = $layout->getUpdate();
47
+ $structure_layout=$this->checkNextStep();
48
+ $update->load('checkout_onepage_'.$structure_layout['layout']);
49
+ $layout->generateXml();
50
+ $layout->generateBlocks();
51
+ $output = $layout->getOutput();
52
+ return $output;
53
+ }
54
+
55
+ /**
56
+ * Retrieve shopping cart model object
57
+ *
58
+ * @return Mage_Checkout_Model_Cart
59
+ */
60
+ protected function _getCart()
61
+ {
62
+ return Mage::getSingleton('checkout/cart');
63
+ }
64
+
65
+ /**
66
+ * Get checkout session model instance
67
+ *
68
+ * @return Mage_Checkout_Model_Session
69
+ */
70
+ protected function _getSession()
71
+ {
72
+ return Mage::getSingleton('checkout/session');
73
+ }
74
+
75
+ /**
76
+ * Get current active quote instance
77
+ *
78
+ * @return Mage_Sales_Model_Quote
79
+ */
80
+ protected function _getQuote()
81
+ {
82
+ return $this->_getCart()->getQuote();
83
+ }
84
+
85
+ /**
86
+ * Get one page checkout model
87
+ *
88
+ * @return Mage_Checkout_Model_Type_Onepage
89
+ */
90
+ public function getOnepage()
91
+ {
92
+ return Mage::getSingleton('checkout/type_onepage');
93
+ }
94
+
95
+ public function submitAction()
96
+ {
97
+ if ($this->_expireAjax()) {
98
+ return;
99
+ }
100
+ if ($this->getRequest()->isPost()) {
101
+ $couponCode = trim($this->getRequest()->getPost('coupon_code'));
102
+ $result = array();
103
+
104
+ $this->_getQuote()->getShippingAddress()->setCollectShippingRates(true);
105
+ $this->_getQuote()->setCouponCode(strlen($couponCode) ? $couponCode : '')
106
+ ->collectTotals()
107
+ ->save();
108
+ if ($couponCode == $this->_getQuote()->getCouponCode()) {
109
+ $result = array('error' => 0);
110
+ $this->_getSession()->setStepData('discountcode', 'complete');
111
+ }
112
+ else {
113
+ $result = array('error' => 1, 'message' => $this->__('Coupon code %s is not valid.', Mage::helper('core')->htmlEscape($couponCode)));
114
+ }
115
+
116
+ if(!$result['error']) {
117
+ $this->getOnepage()->getQuote()->getShippingAddress()->setCollectShippingRates(true);
118
+ $next_step=$this->checkNextStep();
119
+ $result['goto_section'] = $next_step['goto_section'];
120
+ $result['update_section'] = array(
121
+ 'name' => $next_step['name'],
122
+ 'html' => $this->_getShippingMethodsHtml()
123
+ );
124
+ }
125
+
126
+ else {
127
+ $result['goto_section'] = 'discountcode';
128
+ }
129
+
130
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
131
+ }
132
+ }
133
+ protected function checkNextStep()
134
+ {
135
+
136
+ $steps=Mage::getStoreConfig('magegeeks_checkoutdiscountcoupon/checkoutdiscountcoupon_config/checkoutdiscountcoupon_step');
137
+
138
+ $next_step=array('3'=>
139
+ array('goto_section'=>'shipping_method','name'=>'shipping-method','layout'=>'shippingmethod'),
140
+ '4'=>
141
+ array('goto_section'=>'payment_method','name'=>'payment-method','layout'=>'paymentmethod'),
142
+ '5'=>
143
+ array('goto_section'=>'review','name'=>'review','layout'=>'review')
144
+ );
145
+
146
+ return $next_step[$steps];
147
+
148
+
149
+ }
150
+ public function indexAction(){
151
+ $this->loadLayout()->renderLayout();
152
+ }
153
+ }
app/code/local/Magegeeks/Checkoutdiscountcoupon/etc/config.xml ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Magegeeks_Checkoutdiscountcoupon>
5
+ <version>0.1.0</version>
6
+ </Magegeeks_Checkoutdiscountcoupon>
7
+ </modules>
8
+ <frontend>
9
+ <secure_url>
10
+ <checkoutdiscountcoupon_index>/checkoutdiscountcoupon/index</checkoutdiscountcoupon_index>
11
+ </secure_url>
12
+ <routers>
13
+ <checkoutdiscountcoupon>
14
+ <use>standard</use>
15
+ <args>
16
+ <module>Magegeeks_Checkoutdiscountcoupon</module>
17
+ <frontName>checkoutdiscountcode</frontName>
18
+ </args>
19
+ </checkoutdiscountcoupon>
20
+ </routers>
21
+ <layout>
22
+ <updates>
23
+ <checkoutdiscountcoupon>
24
+ <file>checkoutdiscountcoupon.xml</file>
25
+ </checkoutdiscountcoupon>
26
+ </updates>
27
+ </layout>
28
+ </frontend>
29
+ <adminhtml>
30
+ <acl>
31
+ <resources>
32
+ <all>
33
+ <title>Magegeeks Extensions</title>
34
+ </all>
35
+ <admin>
36
+ <children>
37
+ <system>
38
+ <children>
39
+ <config>
40
+ <children>
41
+ <magegeeks_checkoutdiscountcoupon translate="title" module="checkoutdiscountcoupon">
42
+ <title>Magegeeks Section</title>
43
+ <sort_order>0</sort_order>
44
+ </magegeeks_checkoutdiscountcoupon>
45
+ </children>
46
+ </config>
47
+ </children>
48
+ </system>
49
+ </children>
50
+ </admin>
51
+ </resources>
52
+ </acl>
53
+ </adminhtml>
54
+ <global>
55
+ <events>
56
+ <controller_action_postdispatch_checkout_onepage_saveBilling>
57
+ <observers>
58
+ <savebilling_event>
59
+ <type>singleton</type>
60
+ <class>checkoutdiscountcoupon/observer</class>
61
+ <method>controller_action_postdispatch_checkout_onepage_saveBilling</method>
62
+ </savebilling_event>
63
+ </observers>
64
+ </controller_action_postdispatch_checkout_onepage_saveBilling>
65
+ <controller_action_postdispatch_checkout_onepage_saveShipping>
66
+ <observers>
67
+ <saveshipping_event>
68
+ <type>singleton</type>
69
+ <class>checkoutdiscountcoupon/observer</class>
70
+ <method>controller_action_postdispatch_checkout_onepage_saveShipping</method>
71
+ </saveshipping_event>
72
+ </observers>
73
+ </controller_action_postdispatch_checkout_onepage_saveShipping>
74
+ <controller_action_postdispatch_checkout_onepage_saveShippingMethod>
75
+ <observers>
76
+ <saveshippingmethod>
77
+ <type>singleton</type>
78
+ <class>checkoutdiscountcoupon/observer</class>
79
+ <method>controller_action_postdispatch_checkout_onepage_saveShippingMethod</method>
80
+ </saveshippingmethod>
81
+ </observers>
82
+ </controller_action_postdispatch_checkout_onepage_saveShippingMethod>
83
+ <controller_action_postdispatch_checkout_onepage_savePayment>
84
+ <observers>
85
+ <savepaymentmethod>
86
+ <type>singleton</type>
87
+ <class>checkoutdiscountcoupon/observer</class>
88
+ <method>controller_action_postdispatch_checkout_onepage_savePayment</method>
89
+ </savepaymentmethod>
90
+ </observers>
91
+ </controller_action_postdispatch_checkout_onepage_savePayment>
92
+ </events>
93
+ <models>
94
+ <checkoutdiscountcoupon>
95
+ <class>Magegeeks_Checkoutdiscountcoupon_Model</class>
96
+ </checkoutdiscountcoupon>
97
+ </models>
98
+ <blocks>
99
+ <checkoutdiscountcoupon>
100
+ <class>Magegeeks_Checkoutdiscountcoupon_Block</class>
101
+ </checkoutdiscountcoupon>
102
+ <checkout>
103
+ <rewrite>
104
+ <onepage>Magegeeks_Checkoutdiscountcoupon_Block_Checkout_Onepage</onepage>
105
+ <onepage_progress>Magegeeks_Checkoutdiscountcoupon_Block_Checkout_Onepage_Progress</onepage_progress>
106
+ </rewrite>
107
+ </checkout>
108
+ </blocks>
109
+ <helpers>
110
+ <checkoutdiscountcoupon>
111
+ <class>Magegeeks_Checkoutdiscountcoupon_Helper</class>
112
+ </checkoutdiscountcoupon>
113
+ </helpers>
114
+ </global>
115
+
116
+ <default>
117
+ <magegeeks_checkoutdiscountcoupon>
118
+ <checkoutdiscountcoupon_config>
119
+ <checkoutdiscountcoupon_enable>1</checkoutdiscountcoupon_enable>
120
+ <checkoutdiscountcoupon_remove_default>1</checkoutdiscountcoupon_remove_default>
121
+ <checkoutdiscountcoupon_step>1</checkoutdiscountcoupon_step>
122
+ </checkoutdiscountcoupon_config>
123
+ </magegeeks_checkoutdiscountcoupon>
124
+ </default>
125
+ </config>
app/code/local/Magegeeks/Checkoutdiscountcoupon/etc/system.xml ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <magegeeks translate="label" module="checkoutdiscountcoupon">
5
+ <label>Magegeeks Extensions</label>
6
+ <sort_order>100</sort_order>
7
+ </magegeeks>
8
+ </tabs>
9
+
10
+ <sections>
11
+ <magegeeks_checkoutdiscountcoupon translate="label" module="checkoutdiscountcoupon">
12
+ <label>Checkout Discount Coupon Configuration</label>
13
+ <tab>magegeeks</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
+ <checkoutdiscountcoupon_config>
21
+ <label>General</label>
22
+ <frontend_type>text</frontend_type>
23
+ <sort_order>10</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
+ <checkoutdiscountcoupon_enable>
29
+ <label>Enable module</label>
30
+ <frontend_type>select</frontend_type>
31
+ <source_model>adminhtml/system_config_source_yesno</source_model>
32
+ <sort_order>10</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
+ </checkoutdiscountcoupon_enable>
37
+ <checkoutdiscountcoupon_remove_default>
38
+ <label>Remove from shopping cart page</label>
39
+ <frontend_type>select</frontend_type>
40
+ <source_model>adminhtml/system_config_source_yesno</source_model>
41
+ <sort_order>20</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ <show_in_website>1</show_in_website>
44
+ <show_in_store>1</show_in_store>
45
+ </checkoutdiscountcoupon_remove_default>
46
+ <checkoutdiscountcoupon_step>
47
+ <label>Select step to display Discount Tab</label>
48
+ <frontend_type>select</frontend_type>
49
+ <source_model>checkoutdiscountcoupon/source</source_model>
50
+ <sort_order>20</sort_order>
51
+ <show_in_default>1</show_in_default>
52
+ <show_in_website>1</show_in_website>
53
+ <show_in_store>1</show_in_store>
54
+ </checkoutdiscountcoupon_step>
55
+ </fields>
56
+ </checkoutdiscountcoupon_config>
57
+ </groups>
58
+ </magegeeks_checkoutdiscountcoupon>
59
+ </sections>
60
+ </config>
app/design/frontend/base/default/layout/checkoutdiscountcoupon.xml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+
5
+ </default>
6
+ <checkout_cart_index>
7
+ <block type="checkoutdiscountcoupon/checkout_cart" name="checkoutdiscountcoupon.cart" />
8
+ </checkout_cart_index>
9
+
10
+ <checkout_onepage_index>
11
+ <reference name="head">
12
+ <action method="addJs"><js>checkoutdiscountcoupon/checkout.js</js></action>
13
+ </reference>
14
+
15
+ <reference name ="checkout.onepage">
16
+ <block name="discountcode" type="checkoutdiscountcoupon/checkout_onepage_discountcode" template="checkoutdiscountcoupon/checkout/onepage/discountcode.phtml" />
17
+ </reference>
18
+
19
+ <reference name="checkout.progress">
20
+ <action method="setTemplate" ><template>checkoutdiscountcoupon/checkout/onepage/progress.phtml</template></action>
21
+ </reference>
22
+ </checkout_onepage_index>
23
+
24
+ <checkout_onepage_discountcode>
25
+ <block name="root" output="toHtml" type="checkoutdiscountcoupon/checkout_onepage_discountcode" template="checkoutdiscountcoupon/checkout/onepage/discountcode.phtml" />
26
+ </checkout_onepage_discountcode>
27
+
28
+ <checkout_onepage_progress>
29
+ <reference name="root">
30
+ <action method="setTemplate" ><template>checkoutdiscountcoupon/checkout/onepage/progress.phtml</template></action>
31
+ </reference>
32
+ </checkout_onepage_progress>
33
+ </layout>
app/design/frontend/base/default/template/checkoutdiscountcoupon/checkout/onepage/discountcode.phtml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <form id="co-discountcode-form" action="">
2
+ <fieldset>
3
+ <ul class="form-list">
4
+ <li class="wide">
5
+ <label for="coupon_code"><?php echo $this->__('Enter your coupon code if you have one.')?></label>
6
+ <div class="input-box"><input value="" name="coupon_code" id="coupon_code" class="input-text"></div>
7
+ <label style="font-size: 10px;">(Click "CONTINUE" button if you don't have any coupon.)</label>
8
+ </li>
9
+ </ul>
10
+ </fieldset>
11
+ </form>
12
+ <div class="buttons-set" id="discountcode-buttons-container">
13
+ <p class="back-link"><a href="#" onclick="checkout.back(); return false;"><small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
14
+ <button type="button" class="button" onclick="discountcode.save()"><span><span><?php echo $this->__('Continue') ?></span></span></button>
15
+ <span id="discountcode-please-wait" class="please-wait" style="display:none;">
16
+ <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo $this->__('Loading next step...') ?>" title="<?php echo $this->__('Loading next step...') ?>" class="v-middle" /> <?php echo $this->__('Loading next step...') ?>
17
+ </span>
18
+ </div>
19
+
20
+ <script type="text/javascript">
21
+ //<![CDATA[
22
+ var discountcode = new Discountcode('co-discountcode-form','<?php echo $this->getUrl('checkoutdiscountcode/index/submit')?>');
23
+ //]]>
24
+ </script>
app/design/frontend/base/default/template/checkoutdiscountcoupon/checkout/onepage/progress.phtml ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="block block-progress opc-block-progress">
2
+ <div class="block-title">
3
+ <strong><span><?php echo $this->__('Your Checkout Progress') ?></span></strong>
4
+ </div>
5
+ <div class="block-content">
6
+ <dl>
7
+ <?php if ($this->getCheckout()->getStepData('billing', 'is_show')): ?>
8
+ <?php if ($this->isStepComplete('billing')): ?>
9
+ <dt class="complete">
10
+ <?php echo $this->__('Billing Address') ?> <span class="separator">|</span>
11
+ <a href="#billing" onclick="checkout.gotoSection('billing'); return false;"><?php echo $this->__('Change') ?></a>
12
+ </dt>
13
+ <dd class="complete">
14
+ <address><?php echo $this->getBilling()->format('html') ?></address>
15
+ </dd>
16
+ <?php else: ?>
17
+ <dt>
18
+ <?php echo $this->__('Billing Address') ?>
19
+ </dt>
20
+ <?php endif; ?>
21
+ <?php endif; ?>
22
+
23
+ <?php if ($this->getCheckout()->getStepData('shipping', 'is_show')): ?>
24
+ <?php if ($this->isStepComplete('shipping')): ?>
25
+ <dt class="complete">
26
+ <?php echo $this->__('Shipping Address') ?> <span class="separator">|</span>
27
+ <a href="#payment" onclick="checkout.gotoSection('shipping');return false;"><?php echo $this->__('Change') ?></a>
28
+ </dt>
29
+ <dd class="complete">
30
+ <address><?php echo $this->getShipping()->format('html') ?></address>
31
+ </dd>
32
+ <?php else: ?>
33
+ <dt>
34
+ <?php echo $this->__('Shipping Address') ?>
35
+ </dt>
36
+ <?php endif; ?>
37
+ <?php endif; ?>
38
+
39
+ <?php if (Mage::getStoreConfig('magegeeks_checkoutdiscountcoupon/checkoutdiscountcoupon_config/checkoutdiscountcoupon_enable')): ?>
40
+ <?php if ($this->isDiscountcodeStepComplete()): ?>
41
+ <dt class="complete">
42
+ <?php echo $this->__('Discount Code') ?> <span class="separator">|</span>
43
+ <a href="#vendor" onclick="checkout.gotoSection('discountcode'); return false;"><?php echo $this->__('Change') ?></a>
44
+ </dt>
45
+ <dd class="complete">
46
+ <?php $couponcode = Mage::getSingleton('checkout/session')->getQuote()->getCouponCode();?>
47
+ <strong><?php echo $couponcode; ?></strong>
48
+ <?php if($couponcode):?>
49
+ <?php else:?>
50
+ <?php echo $this->__('There is no coupon code')?>
51
+ <?php endif;?>
52
+ </dd>
53
+ <?php else: ?>
54
+ <dt>
55
+ <?php echo $this->__('Discount Code') ?>
56
+ </dt>
57
+ <?php endif; ?>
58
+ <?php endif;?>
59
+
60
+ <?php if ($this->getCheckout()->getStepData('shipping_method', 'is_show')): ?>
61
+ <?php if ($this->isStepComplete('shipping_method')): ?>
62
+ <dt class="complete">
63
+ <?php echo $this->__('Shipping Method') ?> <span class="separator">|</span>
64
+ <a href="#shipping_method" onclick="checkout.gotoSection('shipping_method'); return false;"><?php echo $this->__('Change') ?></a>
65
+ </dt>
66
+ <dd class="complete">
67
+ <?php if ($this->getShippingMethod()): ?>
68
+ <?php echo $this->escapeHtml($this->getShippingDescription()) ?>
69
+
70
+ <?php $_excl = $this->getShippingPriceExclTax(); ?>
71
+ <?php $_incl = $this->getShippingPriceInclTax(); ?>
72
+ <?php if ($this->helper('tax')->displayShippingPriceIncludingTax()): ?>
73
+ <?php echo $_incl; ?>
74
+ <?php else: ?>
75
+ <?php echo $_excl; ?>
76
+ <?php endif; ?>
77
+ <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
78
+ (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
79
+ <?php endif; ?>
80
+
81
+ <?php else: ?>
82
+ <?php echo $this->__('Shipping method has not been selected yet') ?>
83
+ <?php endif; ?>
84
+ </dd>
85
+ <?php else: ?>
86
+ <dt>
87
+ <?php echo $this->__('Shipping Method') ?>
88
+ </dt>
89
+ <?php endif; ?>
90
+ <?php endif; ?>
91
+
92
+ <?php if ($this->getCheckout()->getStepData('payment', 'is_show')): ?>
93
+ <?php if ($this->isStepComplete('payment')): ?>
94
+ <dt class="complete">
95
+ <?php echo $this->__('Payment Method') ?> <span class="separator">|</span>
96
+ <a href="#payment" onclick="checkout.gotoSection('payment'); return false;"><?php echo $this->__('Change') ?></a>
97
+ </dt>
98
+ <dd class="complete">
99
+ <?php echo $this->getPaymentHtml() ?>
100
+ </dd>
101
+ <?php else: ?>
102
+ <dt>
103
+ <?php echo $this->__('Payment Method') ?>
104
+ </dt>
105
+ <?php endif; ?>
106
+ <?php endif; ?>
107
+ </dl>
108
+ </div>
109
+ </div>
app/etc/modules/Magegeeks_Checkoutdiscountcoupon.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Magegeeks_Checkoutdiscountcoupon>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ <version>0.1.0</version>
8
+ </Magegeeks_Checkoutdiscountcoupon>
9
+ </modules>
10
+ </config>
11
+
12
+
js/checkoutdiscountcoupon/checkout.js ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // vendor
2
+ var Discountcode = Class.create();
3
+ Discountcode.prototype = {
4
+ initialize: function(form, saveUrl){
5
+ this.form = form;
6
+ if ($(this.form)) {
7
+ $(this.form).observe('submit', function(event){this.save();Event.stop(event);}.bind(this));
8
+ }
9
+ this.saveUrl = saveUrl;
10
+ this.validator = new Validation(this.form);
11
+ this.onSave = this.nextStep.bindAsEventListener(this);
12
+ this.onComplete = this.resetLoadWaiting.bindAsEventListener(this);
13
+ },
14
+
15
+ validate: function() {
16
+ if(!this.validator.validate()) {
17
+ return false;
18
+ }
19
+ return true;
20
+ },
21
+
22
+ save: function(){
23
+
24
+ if (checkout.loadWaiting!=false) return;
25
+ if (this.validate()) {
26
+ checkout.setLoadWaiting('discountcode');
27
+ var request = new Ajax.Request(
28
+ this.saveUrl,
29
+ {
30
+ method:'post',
31
+ onComplete: this.onComplete,
32
+ onSuccess: this.onSave,
33
+ onFailure: checkout.ajaxFailure.bind(checkout),
34
+ parameters: Form.serialize(this.form)
35
+ }
36
+ );
37
+ }
38
+ },
39
+
40
+ resetLoadWaiting: function(transport){
41
+ checkout.setLoadWaiting(false);
42
+ },
43
+
44
+ nextStep: function(transport){
45
+ if (transport && transport.responseText){
46
+ try{
47
+ response = eval('(' + transport.responseText + ')');
48
+ }
49
+ catch (e) {
50
+ response = {};
51
+ }
52
+ }
53
+ if (response.error){
54
+ if ((typeof response.message) == 'string') {
55
+ alert(response.message);
56
+
57
+ } else {
58
+ if (window.shippingRegionUpdater) {
59
+ shippingRegionUpdater.update();
60
+ }
61
+ response.message.join("\n");
62
+ }
63
+
64
+ return false;
65
+ }
66
+
67
+ checkout.setStepResponse(response);
68
+ }
69
+ }
package.xml ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Discount_Coupon_Code_at_Checkout_Steps</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license>Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>This extension allows user to enter discount coupon code at any step of Onepage checkout page. </summary>
10
+ <description>&lt;b&gt;Want to increase your Conversion Rate? Easy!&lt;/b&gt;&lt;br /&gt;&#xD;
11
+ &#xD;
12
+ It has been proved by dozens of researches that discounts decreases cart abandonment. Customers love to pay less. That's why it's so crucial to have an option to apply a coupon not only at shopping cart page, but also at a checkout page.&lt;br /&gt;&#xD;
13
+ &#xD;
14
+ A common issue associated with the one page checkout on your store is that it won&#x2019;t provide any option for customers to feed their coupon codes directly here. However, you can make it work for your customers by installing "Checkout Discount Coupon" extension. &lt;br /&gt;&#xD;
15
+ &#xD;
16
+ This is Magento Extension which allow to add new step after Shipping/Billing Information or Shipping Methods or Payment Methods step of your checkout process. &#xD;
17
+ &#xD;
18
+ &lt;h2&gt;Features:&lt;/h2&gt;&#xD;
19
+ &#xD;
20
+ Allow to enter discount coupon code after "Billing/ Shipping Information" or "Shipping Methods" or "Payment Methods" on the Onepage checkout page.&lt;br /&gt;&#xD;
21
+ Apply entered coupon code and display discount amount on the 'Order Review' step of the Onepage checkout.&lt;br /&gt;&#xD;
22
+ Seamless integration into Magento system&lt;br /&gt;&#xD;
23
+ Coupons are being applied without page reload. &lt;br /&gt;&#xD;
24
+ Easy to install and use / Easy 2-minutes installation&lt;br /&gt;&#xD;
25
+ 100% Open Source&lt;br /&gt;&lt;br /&gt;&#xD;
26
+ &#xD;
27
+ &lt;h2&gt;Installation &lt;/h2&gt;&#xD;
28
+ &#xD;
29
+ Go to magento admin and flush store cache (System &gt; Cache Management &gt; 'Flush Magento Cache' button)&lt;br /&gt;&#xD;
30
+ Download the extension package from your account and extract the downloaded archive.&lt;br /&gt;&#xD;
31
+ Copy the content of extracted folder to your store's root directory &lt;br /&gt;&#xD;
32
+ Flush store cache again&lt;br /&gt;&#xD;
33
+ Log out from the backend and log in again.&lt;br /&gt;&#xD;
34
+ Go to extension configuration (System &gt; Configuration &gt; Magegeeks Extension &gt; Checkout Discount Coupon Configuration) and enable the extension also select the "Select step to display Discount Tab".&lt;br /&gt;&#xD;
35
+ Flush store cache again .&lt;br /&gt;&lt;br /&gt;&#xD;
36
+ &#xD;
37
+ &lt;b&gt;Congratulations! After completing this last step, you will be able to see new step on your checkout process.&lt;/b&gt;&lt;br/&gt;&lt;br/&gt;&#xD;
38
+ &#xD;
39
+ &lt;h2&gt;FAQ&lt;/h2&gt;&#xD;
40
+ &#xD;
41
+ &lt;b&gt;After installing this extension my store gives error or a blank page.&lt;/b&gt;&lt;br/&gt;&#xD;
42
+ Go to Magento Backend, Flush Store Cache (System &gt; Cache Management&gt; 'Flush Magento Cache' button), Logout and Login again. &lt;br/&gt;&lt;br/&gt;&#xD;
43
+ &#xD;
44
+ &lt;b&gt;I need additional functionality.&lt;/b&gt;&lt;br/&gt;&#xD;
45
+ Please contact "deepakmankotiacse@gmail.com". If we like the idea we can implement this in next release or do customization just for you. &#xD;
46
+ </description>
47
+ <notes>Checkout Discount Coupon Step extension will add new step called 'Discount Coupon' on the Onepage checkout, where user can enter the discount coupon code during the checkout process.&lt;br/&gt;&lt;br/&gt;&#xD;
48
+ &#xD;
49
+ &lt;b&gt;Features:&lt;/b&gt;&lt;br /&gt;&#xD;
50
+ &#xD;
51
+ Allow to enter discount coupon code on the Onepage checkout page.&lt;br/&gt;&#xD;
52
+ Apply entered coupon code and display discount amount on the 'Order Review' step of the Onepage checkout.&lt;br/&gt;&#xD;
53
+ </notes>
54
+ <authors><author><name>Deepak mnakotia</name><user>deepakmankotia</user><email>deepakmankotiacse@gmail.com</email></author></authors>
55
+ <date>2015-07-10</date>
56
+ <time>09:26:37</time>
57
+ <contents><target name="mageetc"><dir name="modules"><file name="Magegeeks_Checkoutdiscountcoupon.xml" hash="db6d640ab5355e41495bfea65bb5009e"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="checkoutdiscountcoupon.xml" hash="62981c14d4148e93bf7be2b467267355"/></dir><dir name="template"><dir name="checkoutdiscountcoupon"><dir name="checkout"><dir name="onepage"><file name="discountcode.phtml" hash="bb1acd35c2f7925f060495e561dd8a14"/><file name="progress.phtml" hash="da5609265e0bae9e7173b5534467da62"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="checkoutdiscountcoupon"><file name="checkout.js" hash="850331185f6404477ffb3cf33baa1a96"/></dir></dir></target><target name="magelocal"><dir name="Magegeeks"><dir name="Checkoutdiscountcoupon"><dir name="Block"><dir name="Checkout"><file name="Cart.php" hash="af2fcc7b835747aba9c2c49c51a1c186"/><dir name="Onepage"><file name="Discountcode.php" hash="ffb5c654c1ed0d9b8a7d5b72174df087"/><file name="Progress.php" hash="1dda984ffcc75e917ac870a60f7b0fd4"/></dir><file name="Onepage.php" hash="7a1195d39869ceb41cab13b6ec9a37ec"/></dir></dir><dir name="Helper"><file name="Data.php" hash="a4435eb1e78ddce190f4c40994036049"/></dir><dir name="Model"><file name="Observer.php" hash="4c3a2bcae4f76c497291c48cd2ac937f"/><file name="Source.php" hash="1c8d04167b1a3778249ab631ee971b6a"/></dir><dir name="controllers"><file name="IndexController.php" hash="e3b696f80c6f8bd3c63bc00e653d0e38"/></dir><dir name="etc"><file name="config.xml" hash="d9811b961e82baa9515d41141ef64222"/><file name="system.xml" hash="3f90ef1397a02edf0d59b96faa8aab88"/></dir></dir></dir></target></contents>
58
+ <compatible/>
59
+ <dependencies><required><php><min>5.1.0</min><max>5.6.0</max></php></required></dependencies>
60
+ </package>