Version Notes
1.0.1 stable version
Download this release
Release Info
Developer | SoftProdigyINC |
Extension | Softprodigy_CheckoutDiscountCode |
Version | 1.0.1 |
Comparing to | |
See all releases |
Version 1.0.1
- app/code/community/Softprodigy/CheckoutDiscountCode/Block/Checkout/Cart.php +9 -0
- app/code/community/Softprodigy/CheckoutDiscountCode/Block/Checkout/Onepage.php +36 -0
- app/code/community/Softprodigy/CheckoutDiscountCode/Block/Checkout/Onepage/Discountcode.php +12 -0
- app/code/community/Softprodigy/CheckoutDiscountCode/Block/Checkout/Onepage/Progress.php +32 -0
- app/code/community/Softprodigy/CheckoutDiscountCode/Helper/Data.php +6 -0
- app/code/community/Softprodigy/CheckoutDiscountCode/Model/Observer.php +54 -0
- app/code/community/Softprodigy/CheckoutDiscountCode/controllers/IndexController.php +131 -0
- app/code/community/Softprodigy/CheckoutDiscountCode/etc/config.xml +105 -0
- app/code/community/Softprodigy/CheckoutDiscountCode/etc/system.xml +51 -0
- app/design/frontend/default/default/layout/softprodigy_checkoutdiscountcode.xml +33 -0
- app/design/frontend/default/default/template/softprodigy_checkoutcouponcode/checkout/onepage/discountcode.phtml +23 -0
- app/design/frontend/default/default/template/softprodigy_checkoutcouponcode/checkout/onepage/progress.phtml +109 -0
- app/etc/modules/Softprodigy_CheckoutDiscountCode.xml +9 -0
- js/softprodigy_checkoutdiscountcode/checkout.js +67 -0
- package.xml +18 -0
app/code/community/Softprodigy/CheckoutDiscountCode/Block/Checkout/Cart.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Softprodigy_CheckoutDiscountCode_Block_Checkout_Cart extends Mage_Checkout_Block_Onepage
|
3 |
+
{
|
4 |
+
protected function _prepareLayout(){
|
5 |
+
if(Mage::getStoreConfig('checkoutdiscountcode/config/remove_discount_box')){
|
6 |
+
$this->getLayout()->getBlock('checkout.cart')->unsetChild('coupon');
|
7 |
+
}
|
8 |
+
}
|
9 |
+
}
|
app/code/community/Softprodigy/CheckoutDiscountCode/Block/Checkout/Onepage.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Softprodigy_CheckoutDiscountCode_Block_Checkout_Onepage extends Mage_Checkout_Block_Onepage
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Get 'one step checkout' step data
|
6 |
+
*
|
7 |
+
* @return array
|
8 |
+
*/
|
9 |
+
public function getSteps()
|
10 |
+
{
|
11 |
+
$steps = array();
|
12 |
+
$stepCodes = $this->_getStepCodes();
|
13 |
+
|
14 |
+
if ($this->isCustomerLoggedIn()) {
|
15 |
+
$stepCodes = array_diff($stepCodes, array('login'));
|
16 |
+
}
|
17 |
+
|
18 |
+
foreach ($stepCodes as $step) {
|
19 |
+
$steps[$step] = $this->getCheckout()->getStepData($step);
|
20 |
+
}
|
21 |
+
|
22 |
+
$steps['discountcode'] = array('label'=>'Discount Code','is_show'=>true);
|
23 |
+
|
24 |
+
return $steps;
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Get checkout steps codes
|
29 |
+
*
|
30 |
+
* @return array
|
31 |
+
*/
|
32 |
+
protected function _getStepCodes()
|
33 |
+
{
|
34 |
+
return array('login', 'billing', 'shipping', 'discountcode', 'shipping_method', 'payment', 'review');
|
35 |
+
}
|
36 |
+
}
|
app/code/community/Softprodigy/CheckoutDiscountCode/Block/Checkout/Onepage/Discountcode.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Softprodigy_CheckoutDiscountCode_Block_Checkout_Onepage_Discountcode extends Mage_Core_Block_Template
|
3 |
+
{
|
4 |
+
public function _prepareLayout()
|
5 |
+
{
|
6 |
+
return parent::_prepareLayout();
|
7 |
+
}
|
8 |
+
|
9 |
+
public function isShow(){
|
10 |
+
return Mage::getStoreConfig('checkoutdiscountcode/config/enable');
|
11 |
+
}
|
12 |
+
}
|
app/code/community/Softprodigy/CheckoutDiscountCode/Block/Checkout/Onepage/Progress.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Softprodigy_CheckoutDiscountCode_Block_Checkout_Onepage_Progress extends Mage_Checkout_Block_Onepage_Progress
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Get checkout steps codes
|
6 |
+
*
|
7 |
+
* @return array
|
8 |
+
*/
|
9 |
+
protected function _getStepCodes()
|
10 |
+
{
|
11 |
+
return Mage::getStoreConfig('checkoutdiscountcode/config/enable')?array('login', 'billing', 'shipping', 'discountcode', 'shipping_method', 'payment', 'review'):parent::_getStepCodes();
|
12 |
+
}
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Get is discountcode step completed.
|
16 |
+
*
|
17 |
+
* @return bool
|
18 |
+
*/
|
19 |
+
public function isDiscountcodeStepComplete()
|
20 |
+
{
|
21 |
+
$stepsRevertIndex = array_flip($this->_getStepCodes());
|
22 |
+
|
23 |
+
$toStep = $this->getRequest()->getParam('toStep');
|
24 |
+
|
25 |
+
if ($stepsRevertIndex['discountcode'] >= $stepsRevertIndex[$toStep]) {
|
26 |
+
return false;
|
27 |
+
}
|
28 |
+
|
29 |
+
return true;
|
30 |
+
}
|
31 |
+
|
32 |
+
}
|
app/code/community/Softprodigy/CheckoutDiscountCode/Helper/Data.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Softprodigy_CheckoutDiscountCode_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
}
|
app/code/community/Softprodigy/CheckoutDiscountCode/Model/Observer.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Softprodigy_CheckoutDiscountCode_Model_Observer
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Make sure after save billing step it go to vendor step
|
7 |
+
* @param unknown_type $observer
|
8 |
+
*/
|
9 |
+
public function controller_action_postdispatch_checkout_onepage_saveBilling($observer){
|
10 |
+
if(!Mage::getStoreConfig('checkoutdiscountcode/config/enable')) return;
|
11 |
+
|
12 |
+
$controller = $observer->getData('controller_action');
|
13 |
+
$body = Mage::helper('core')->jsonDecode($controller->getResponse()->getBody());
|
14 |
+
if($body['goto_section']=='shipping_method') $body['goto_section'] = 'discountcode';
|
15 |
+
$body['update_section'] = array(
|
16 |
+
'name' => 'shipping-method',
|
17 |
+
'html' => $this->_getVendorHtml($controller)
|
18 |
+
);
|
19 |
+
$body['allow_sections'] = array('billing','shipping','discountcode');
|
20 |
+
$controller->getResponse()->setBody(Mage::helper('core')->jsonEncode($body));
|
21 |
+
}
|
22 |
+
/**
|
23 |
+
* Make sure after save shipping step it go to vendor step
|
24 |
+
* @param unknown_type $observer
|
25 |
+
*/
|
26 |
+
public function controller_action_postdispatch_checkout_onepage_saveShipping($observer){
|
27 |
+
if(!Mage::getStoreConfig('checkoutdiscountcode/config/enable')) return;
|
28 |
+
|
29 |
+
$controller = $observer->getData('controller_action');
|
30 |
+
$body = Mage::helper('core')->jsonDecode($controller->getResponse()->getBody());
|
31 |
+
if($body['goto_section']=='shipping_method') $body['goto_section'] = 'discountcode';
|
32 |
+
$body['update_section'] = array(
|
33 |
+
'name' => 'shipping-method',
|
34 |
+
'html' => $this->_getVendorHtml($controller)
|
35 |
+
);
|
36 |
+
$controller->getResponse()->setBody(Mage::helper('core')->jsonEncode($body));
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Get shipping method step html
|
41 |
+
*
|
42 |
+
* @return string
|
43 |
+
*/
|
44 |
+
protected function _getVendorHtml($controller)
|
45 |
+
{
|
46 |
+
$layout = $controller->getLayout();
|
47 |
+
$update = $layout->getUpdate();
|
48 |
+
$update->load('checkout_onepage_discountcode');
|
49 |
+
$layout->generateXml();
|
50 |
+
$layout->generateBlocks();
|
51 |
+
$output = $layout->getOutput();
|
52 |
+
return $output;
|
53 |
+
}
|
54 |
+
}
|
app/code/community/Softprodigy/CheckoutDiscountCode/controllers/IndexController.php
ADDED
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Softprodigy_CheckoutDiscountCode_IndexController extends Mage_Core_Controller_Front_Action
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Validate ajax request and redirect on failure
|
6 |
+
*
|
7 |
+
* @return bool
|
8 |
+
*/
|
9 |
+
protected function _expireAjax()
|
10 |
+
{
|
11 |
+
if (!$this->getOnepage()->getQuote()->hasItems()
|
12 |
+
|| $this->getOnepage()->getQuote()->getHasError()
|
13 |
+
|| $this->getOnepage()->getQuote()->getIsMultiShipping()) {
|
14 |
+
$this->_ajaxRedirectResponse();
|
15 |
+
return true;
|
16 |
+
}
|
17 |
+
$action = $this->getRequest()->getActionName();
|
18 |
+
if (Mage::getSingleton('checkout/session')->getCartWasUpdated(true)
|
19 |
+
&& !in_array($action, array('index', 'progress'))) {
|
20 |
+
$this->_ajaxRedirectResponse();
|
21 |
+
return true;
|
22 |
+
}
|
23 |
+
|
24 |
+
return false;
|
25 |
+
}
|
26 |
+
|
27 |
+
|
28 |
+
protected function _ajaxRedirectResponse()
|
29 |
+
{
|
30 |
+
$this->getResponse()
|
31 |
+
->setHeader('HTTP/1.1', '403 Session Expired')
|
32 |
+
->setHeader('Login-Required', 'true')
|
33 |
+
->sendResponse();
|
34 |
+
return $this;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Get shipping method step html
|
39 |
+
*
|
40 |
+
* @return string
|
41 |
+
*/
|
42 |
+
protected function _getShippingMethodsHtml()
|
43 |
+
{
|
44 |
+
$layout = $this->getLayout();
|
45 |
+
$update = $layout->getUpdate();
|
46 |
+
$update->load('checkout_onepage_shippingmethod');
|
47 |
+
$layout->generateXml();
|
48 |
+
$layout->generateBlocks();
|
49 |
+
$output = $layout->getOutput();
|
50 |
+
return $output;
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Retrieve shopping cart model object
|
55 |
+
*
|
56 |
+
* @return Mage_Checkout_Model_Cart
|
57 |
+
*/
|
58 |
+
protected function _getCart()
|
59 |
+
{
|
60 |
+
return Mage::getSingleton('checkout/cart');
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Get checkout session model instance
|
65 |
+
*
|
66 |
+
* @return Mage_Checkout_Model_Session
|
67 |
+
*/
|
68 |
+
protected function _getSession()
|
69 |
+
{
|
70 |
+
return Mage::getSingleton('checkout/session');
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Get current active quote instance
|
75 |
+
*
|
76 |
+
* @return Mage_Sales_Model_Quote
|
77 |
+
*/
|
78 |
+
protected function _getQuote()
|
79 |
+
{
|
80 |
+
return $this->_getCart()->getQuote();
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Get one page checkout model
|
85 |
+
*
|
86 |
+
* @return Mage_Checkout_Model_Type_Onepage
|
87 |
+
*/
|
88 |
+
public function getOnepage()
|
89 |
+
{
|
90 |
+
return Mage::getSingleton('checkout/type_onepage');
|
91 |
+
}
|
92 |
+
|
93 |
+
public function submitAction()
|
94 |
+
{
|
95 |
+
if ($this->_expireAjax()) {
|
96 |
+
return;
|
97 |
+
}
|
98 |
+
if ($this->getRequest()->isPost()) {
|
99 |
+
$couponCode = trim($this->getRequest()->getPost('coupon_code'));
|
100 |
+
$result = array();
|
101 |
+
|
102 |
+
$this->_getQuote()->getShippingAddress()->setCollectShippingRates(true);
|
103 |
+
$this->_getQuote()->setCouponCode(strlen($couponCode) ? $couponCode : '')
|
104 |
+
->collectTotals()
|
105 |
+
->save();
|
106 |
+
if ($couponCode == $this->_getQuote()->getCouponCode()) {
|
107 |
+
$result = array('error' => 0);
|
108 |
+
$this->_getSession()->setStepData('discountcode', 'complete');
|
109 |
+
}
|
110 |
+
else {
|
111 |
+
$result = array('error' => 1, 'message' => $this->__('Coupon code %s is not valid.', Mage::helper('core')->htmlEscape($couponCode)));
|
112 |
+
}
|
113 |
+
|
114 |
+
if(!$result['error']) {
|
115 |
+
$this->getOnepage()->getQuote()->getShippingAddress()->setCollectShippingRates(true);
|
116 |
+
$result['goto_section'] = 'shipping_method';
|
117 |
+
$result['update_section'] = array(
|
118 |
+
'name' => 'shipping-method',
|
119 |
+
'html' => $this->_getShippingMethodsHtml()
|
120 |
+
);
|
121 |
+
}else {
|
122 |
+
$result['goto_section'] = 'discountcode';
|
123 |
+
}
|
124 |
+
|
125 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
126 |
+
}
|
127 |
+
}
|
128 |
+
public function indexAction(){
|
129 |
+
$this->loadLayout()->renderLayout();
|
130 |
+
}
|
131 |
+
}
|
app/code/community/Softprodigy/CheckoutDiscountCode/etc/config.xml
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Softprodigy_CheckoutDiscountCode>
|
5 |
+
<version>1.0.1</version>
|
6 |
+
</Softprodigy_CheckoutDiscountCode>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<secure_url>
|
10 |
+
<checkoutdiscountcode_index>/checkoutdiscountcode/index</checkoutdiscountcode_index>
|
11 |
+
</secure_url>
|
12 |
+
<routers>
|
13 |
+
<checkoutdiscountcode>
|
14 |
+
<use>standard</use>
|
15 |
+
<args>
|
16 |
+
<module>Softprodigy_CheckoutDiscountCode</module>
|
17 |
+
<frontName>checkoutdiscountcode</frontName>
|
18 |
+
</args>
|
19 |
+
</checkoutdiscountcode>
|
20 |
+
</routers>
|
21 |
+
<layout>
|
22 |
+
<updates>
|
23 |
+
<checkoutdiscountcode>
|
24 |
+
<file>softprodigy_checkoutdiscountcode.xml</file>
|
25 |
+
</checkoutdiscountcode>
|
26 |
+
</updates>
|
27 |
+
</layout>
|
28 |
+
</frontend>
|
29 |
+
<adminhtml>
|
30 |
+
<acl>
|
31 |
+
<resources>
|
32 |
+
<all>
|
33 |
+
<title>Allow Everything</title>
|
34 |
+
</all>
|
35 |
+
<admin>
|
36 |
+
<children>
|
37 |
+
<system>
|
38 |
+
<children>
|
39 |
+
<config>
|
40 |
+
<children>
|
41 |
+
<checkoutdiscountcode translate="title" module="checkoutdiscountcode">
|
42 |
+
<title>Checkout Discount Code</title>
|
43 |
+
</checkoutdiscountcode>
|
44 |
+
</children>
|
45 |
+
</config>
|
46 |
+
</children>
|
47 |
+
</system>
|
48 |
+
</children>
|
49 |
+
</admin>
|
50 |
+
</resources>
|
51 |
+
</acl>
|
52 |
+
</adminhtml>
|
53 |
+
<global>
|
54 |
+
<events>
|
55 |
+
<controller_action_postdispatch_checkout_onepage_saveBilling>
|
56 |
+
<observers>
|
57 |
+
<checkoutdiscountcode>
|
58 |
+
<type>singleton</type>
|
59 |
+
<class>checkoutdiscountcode/observer</class>
|
60 |
+
<method>controller_action_postdispatch_checkout_onepage_saveBilling</method>
|
61 |
+
</checkoutdiscountcode>
|
62 |
+
</observers>
|
63 |
+
</controller_action_postdispatch_checkout_onepage_saveBilling>
|
64 |
+
<controller_action_postdispatch_checkout_onepage_saveShipping>
|
65 |
+
<observers>
|
66 |
+
<checkoutdiscountcode>
|
67 |
+
<type>singleton</type>
|
68 |
+
<class>checkoutdiscountcode/observer</class>
|
69 |
+
<method>controller_action_postdispatch_checkout_onepage_saveShipping</method>
|
70 |
+
</checkoutdiscountcode>
|
71 |
+
</observers>
|
72 |
+
</controller_action_postdispatch_checkout_onepage_saveShipping>
|
73 |
+
</events>
|
74 |
+
<models>
|
75 |
+
<checkoutdiscountcode>
|
76 |
+
<class>Softprodigy_CheckoutDiscountCode_Model</class>
|
77 |
+
</checkoutdiscountcode>
|
78 |
+
</models>
|
79 |
+
<blocks>
|
80 |
+
<checkoutdiscountcode>
|
81 |
+
<class>Softprodigy_CheckoutDiscountCode_Block</class>
|
82 |
+
</checkoutdiscountcode>
|
83 |
+
<checkout>
|
84 |
+
<rewrite>
|
85 |
+
<onepage>Softprodigy_CheckoutDiscountCode_Block_Checkout_Onepage</onepage>
|
86 |
+
<onepage_progress>Softprodigy_CheckoutDiscountCode_Block_Checkout_Onepage_Progress</onepage_progress>
|
87 |
+
</rewrite>
|
88 |
+
</checkout>
|
89 |
+
</blocks>
|
90 |
+
<helpers>
|
91 |
+
<checkoutdiscountcode>
|
92 |
+
<class>Softprodigy_CheckoutDiscountCode_Helper</class>
|
93 |
+
</checkoutdiscountcode>
|
94 |
+
</helpers>
|
95 |
+
</global>
|
96 |
+
|
97 |
+
<default>
|
98 |
+
<checkoutdiscountcode>
|
99 |
+
<config>
|
100 |
+
<enable>1</enable>
|
101 |
+
<remove_discount_box>1</remove_discount_box>
|
102 |
+
</config>
|
103 |
+
</checkoutdiscountcode>
|
104 |
+
</default>
|
105 |
+
</config>
|
app/code/community/Softprodigy/CheckoutDiscountCode/etc/system.xml
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<softprodigy translate="label">
|
5 |
+
<label>SoftProdigy</label>
|
6 |
+
<sort_order>400</sort_order>
|
7 |
+
</softprodigy>
|
8 |
+
</tabs>
|
9 |
+
|
10 |
+
<sections>
|
11 |
+
<checkoutdiscountcode translate="label" module="checkoutdiscountcode">
|
12 |
+
<label>Checkout Discount Box</label>
|
13 |
+
<tab>softprodigy</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 |
+
<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 |
+
<enable>
|
29 |
+
<label>Enable</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 |
+
</enable>
|
37 |
+
<remove_discount_box>
|
38 |
+
<label>Disable discount box from 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 |
+
</remove_discount_box>
|
46 |
+
</fields>
|
47 |
+
</config>
|
48 |
+
</groups>
|
49 |
+
</checkoutdiscountcode>
|
50 |
+
</sections>
|
51 |
+
</config>
|
app/design/frontend/default/default/layout/softprodigy_checkoutdiscountcode.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="checkoutdiscountcode/checkout_cart" name="checkoutdiscountcode.cart" />
|
8 |
+
</checkout_cart_index>
|
9 |
+
|
10 |
+
<checkout_onepage_index>
|
11 |
+
<reference name="head">
|
12 |
+
<action method="addJs"><js>softprodigy_checkoutdiscountcode/checkout.js</js></action>
|
13 |
+
</reference>
|
14 |
+
|
15 |
+
<reference name ="checkout.onepage">
|
16 |
+
<block name="discountcode" type="checkoutdiscountcode/checkout_onepage_discountcode" template="softprodigy_checkoutcouponcode/checkout/onepage/discountcode.phtml" />
|
17 |
+
</reference>
|
18 |
+
|
19 |
+
<reference name="checkout.progress">
|
20 |
+
<action method="setTemplate" ><template>softprodigy_checkoutcouponcode/checkout/onepage/progress.phtml</template></action>
|
21 |
+
</reference>
|
22 |
+
</checkout_onepage_index>
|
23 |
+
|
24 |
+
<checkout_onepage_discountcode>
|
25 |
+
<block name="root" output="toHtml" type="checkoutdiscountcode/checkout_onepage_discountcode" template="softprodigy_checkoutcouponcode/checkout/onepage/discountcode.phtml" />
|
26 |
+
</checkout_onepage_discountcode>
|
27 |
+
|
28 |
+
<checkout_onepage_progress>
|
29 |
+
<reference name="root">
|
30 |
+
<action method="setTemplate" ><template>softprodigy_checkoutcouponcode/checkout/onepage/progress.phtml</template></action>
|
31 |
+
</reference>
|
32 |
+
</checkout_onepage_progress>
|
33 |
+
</layout>
|
app/design/frontend/default/default/template/softprodigy_checkoutcouponcode/checkout/onepage/discountcode.phtml
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
</li>
|
8 |
+
</ul>
|
9 |
+
</fieldset>
|
10 |
+
</form>
|
11 |
+
<div class="buttons-set" id="discountcode-buttons-container">
|
12 |
+
<p class="back-link"><a href="#" onclick="checkout.back(); return false;"><small>« </small><?php echo $this->__('Back') ?></a></p>
|
13 |
+
<button type="button" class="button" onclick="discountcode.save()"><span><span><?php echo $this->__('Continue') ?></span></span></button>
|
14 |
+
<span id="discountcode-please-wait" class="please-wait" style="display:none;">
|
15 |
+
<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...') ?>
|
16 |
+
</span>
|
17 |
+
</div>
|
18 |
+
|
19 |
+
<script type="text/javascript">
|
20 |
+
//<![CDATA[
|
21 |
+
var discountcode = new Discountcode('co-discountcode-form','<?php echo $this->getUrl('checkoutdiscountcode/index/submit')?>');
|
22 |
+
//]]>
|
23 |
+
</script>
|
app/design/frontend/default/default/template/softprodigy_checkoutcouponcode/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('checkoutdiscountcode/config/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/Softprodigy_CheckoutDiscountCode.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Softprodigy_CheckoutDiscountCode>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</Softprodigy_CheckoutDiscountCode>
|
8 |
+
</modules>
|
9 |
+
</config>
|
js/softprodigy_checkoutdiscountcode/checkout.js
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var Discountcode = Class.create();
|
2 |
+
Discountcode.prototype = {
|
3 |
+
initialize: function(form, saveUrl){
|
4 |
+
this.form = form;
|
5 |
+
if ($(this.form)) {
|
6 |
+
$(this.form).observe('submit', function(event){this.save();Event.stop(event);}.bind(this));
|
7 |
+
}
|
8 |
+
this.saveUrl = saveUrl;
|
9 |
+
this.validator = new Validation(this.form);
|
10 |
+
this.onSave = this.nextStep.bindAsEventListener(this);
|
11 |
+
this.onComplete = this.resetLoadWaiting.bindAsEventListener(this);
|
12 |
+
},
|
13 |
+
|
14 |
+
validate: function() {
|
15 |
+
if(!this.validator.validate()) {
|
16 |
+
return false;
|
17 |
+
}
|
18 |
+
return true;
|
19 |
+
},
|
20 |
+
|
21 |
+
save: function(){
|
22 |
+
|
23 |
+
if (checkout.loadWaiting!=false) return;
|
24 |
+
if (this.validate()) {
|
25 |
+
checkout.setLoadWaiting('discountcode');
|
26 |
+
var request = new Ajax.Request(
|
27 |
+
this.saveUrl,
|
28 |
+
{
|
29 |
+
method:'post',
|
30 |
+
onComplete: this.onComplete,
|
31 |
+
onSuccess: this.onSave,
|
32 |
+
onFailure: checkout.ajaxFailure.bind(checkout),
|
33 |
+
parameters: Form.serialize(this.form)
|
34 |
+
}
|
35 |
+
);
|
36 |
+
}
|
37 |
+
},
|
38 |
+
|
39 |
+
resetLoadWaiting: function(transport){
|
40 |
+
checkout.setLoadWaiting(false);
|
41 |
+
},
|
42 |
+
|
43 |
+
nextStep: function(transport){
|
44 |
+
if (transport && transport.responseText){
|
45 |
+
try{
|
46 |
+
response = eval('(' + transport.responseText + ')');
|
47 |
+
}
|
48 |
+
catch (e) {
|
49 |
+
response = {};
|
50 |
+
}
|
51 |
+
}
|
52 |
+
if (response.error){
|
53 |
+
if ((typeof response.message) == 'string') {
|
54 |
+
alert(response.message);
|
55 |
+
} else {
|
56 |
+
if (window.shippingRegionUpdater) {
|
57 |
+
shippingRegionUpdater.update();
|
58 |
+
}
|
59 |
+
response.message.join("\n");
|
60 |
+
}
|
61 |
+
|
62 |
+
return false;
|
63 |
+
}
|
64 |
+
|
65 |
+
checkout.setStepResponse(response);
|
66 |
+
}
|
67 |
+
}
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Softprodigy_CheckoutDiscountCode</name>
|
4 |
+
<version>1.0.1</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.opensource.org/licenses/gpl-license.php">OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>This extension allows customer to enter discount code at checkout process</summary>
|
10 |
+
<description>This extension allows customer to enter discount code at checkout process</description>
|
11 |
+
<notes>1.0.1 stable version</notes>
|
12 |
+
<authors><author><name>SoftProdigyINC</name><user>softprodigy</user><email>magento@softprodigy.com</email></author></authors>
|
13 |
+
<date>2015-07-29</date>
|
14 |
+
<time>07:57:00</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Softprodigy"><dir name="CheckoutDiscountCode"><dir name="Block"><dir name="Checkout"><file name="Cart.php" hash="b247bedeebbd0052125b49e8351b37ec"/><dir name="Onepage"><file name="Discountcode.php" hash="9203fcb3c328c4950202fec8bfbaf683"/><file name="Progress.php" hash="08dacc24165c187fb6cbda6d38a6ea0d"/></dir><file name="Onepage.php" hash="9d4d0e2897ce6afae4ecca59af1c5baf"/></dir></dir><dir name="Helper"><file name="Data.php" hash="563fc8bec19fc4f096aab0fa1f83a722"/></dir><dir name="Model"><file name="Observer.php" hash="c33f8a490a3dffc784e90dc3887a7674"/></dir><dir name="controllers"><file name="IndexController.php" hash="c666733d1319c3ee5eeeb3c930292b09"/></dir><dir name="etc"><file name="config.xml" hash="517913e384eb9f612b8a7c9db0b5ae6a"/><file name="system.xml" hash="7b665754e2061b06a82f609d3e6269a5"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Softprodigy_CheckoutDiscountCode.xml" hash="4f5531c68867e1e6deb9225da7aafb6e"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="softprodigy_checkoutdiscountcode.xml" hash="08ddef38ef2c82137385cc32286ff574"/></dir><dir name="template"><dir name="softprodigy_checkoutcouponcode"><dir name="checkout"><dir name="onepage"><file name="discountcode.phtml" hash="94927cb26941edf79cd4b93022fbc982"/><file name="progress.phtml" hash="9bbb74039a66f3397394e6be89db5536"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="softprodigy_checkoutdiscountcode"><file name="checkout.js" hash="6a13a0d03be9d6676f0469721ebe39ec"/></dir></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
+
</package>
|