Version Notes
Release extension
Download this release
Release Info
Developer | Magento Core Team |
Extension | Checkout_Discount_Code |
Version | 1.0.0.0 |
Comparing to | |
See all releases |
Version 1.0.0.0
- app/code/community/VES/CheckoutDiscountCode/Block/Checkout/Cart.php +9 -0
- app/code/community/VES/CheckoutDiscountCode/Block/Checkout/Onepage.php +36 -0
- app/code/community/VES/CheckoutDiscountCode/Block/Checkout/Onepage/Discountcode.php +12 -0
- app/code/community/VES/CheckoutDiscountCode/Block/Checkout/Onepage/Progress.php +32 -0
- app/code/community/VES/CheckoutDiscountCode/Helper/Data.php +6 -0
- app/code/community/VES/CheckoutDiscountCode/Model/Observer.php +54 -0
- app/code/community/VES/CheckoutDiscountCode/controllers/IndexController.php +131 -0
- app/code/community/VES/CheckoutDiscountCode/etc/config.xml +105 -0
- app/code/community/VES/CheckoutDiscountCode/etc/system.xml +51 -0
- app/design/frontend/default/default/layout/ves_checkoutdiscountcode.xml +33 -0
- app/design/frontend/default/default/template/ves_checkoutcouponcode/checkout/onepage/discountcode.phtml +23 -0
- app/design/frontend/default/default/template/ves_checkoutcouponcode/checkout/onepage/progress.phtml +109 -0
- app/etc/modules/VES_CheckoutDiscountCode.xml +9 -0
- js/ves_checkoutdiscountcode/checkout.js +68 -0
- package.xml +18 -0
app/code/community/VES/CheckoutDiscountCode/Block/Checkout/Cart.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class VES_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/VES/CheckoutDiscountCode/Block/Checkout/Onepage.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class VES_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/VES/CheckoutDiscountCode/Block/Checkout/Onepage/Discountcode.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class VES_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/VES/CheckoutDiscountCode/Block/Checkout/Onepage/Progress.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class VES_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/VES/CheckoutDiscountCode/Helper/Data.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class VES_CheckoutDiscountCode_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
}
|
app/code/community/VES/CheckoutDiscountCode/Model/Observer.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class VES_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/VES/CheckoutDiscountCode/controllers/IndexController.php
ADDED
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class VES_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/VES/CheckoutDiscountCode/etc/config.xml
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<VES_CheckoutDiscountCode>
|
5 |
+
<version>1.0.0.0</version>
|
6 |
+
</VES_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>VES_CheckoutDiscountCode</module>
|
17 |
+
<frontName>checkoutdiscountcode</frontName>
|
18 |
+
</args>
|
19 |
+
</checkoutdiscountcode>
|
20 |
+
</routers>
|
21 |
+
<layout>
|
22 |
+
<updates>
|
23 |
+
<checkoutdiscountcode>
|
24 |
+
<file>ves_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>VES_CheckoutDiscountCode_Model</class>
|
77 |
+
</checkoutdiscountcode>
|
78 |
+
</models>
|
79 |
+
<blocks>
|
80 |
+
<checkoutdiscountcode>
|
81 |
+
<class>VES_CheckoutDiscountCode_Block</class>
|
82 |
+
</checkoutdiscountcode>
|
83 |
+
<checkout>
|
84 |
+
<rewrite>
|
85 |
+
<onepage>VES_CheckoutDiscountCode_Block_Checkout_Onepage</onepage>
|
86 |
+
<onepage_progress>VES_CheckoutDiscountCode_Block_Checkout_Onepage_Progress</onepage_progress>
|
87 |
+
</rewrite>
|
88 |
+
</checkout>
|
89 |
+
</blocks>
|
90 |
+
<helpers>
|
91 |
+
<checkoutdiscountcode>
|
92 |
+
<class>VES_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/VES/CheckoutDiscountCode/etc/system.xml
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<ves translate="label">
|
5 |
+
<label>VnEcoms</label>
|
6 |
+
<sort_order>400</sort_order>
|
7 |
+
</ves>
|
8 |
+
</tabs>
|
9 |
+
|
10 |
+
<sections>
|
11 |
+
<checkoutdiscountcode translate="label" module="checkoutdiscountcode">
|
12 |
+
<label>Checkout Discount Code</label>
|
13 |
+
<tab>ves</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 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 |
+
</enable>
|
37 |
+
<remove_discount_box>
|
38 |
+
<label>Remove discount box 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 |
+
</remove_discount_box>
|
46 |
+
</fields>
|
47 |
+
</config>
|
48 |
+
</groups>
|
49 |
+
</checkoutdiscountcode>
|
50 |
+
</sections>
|
51 |
+
</config>
|
app/design/frontend/default/default/layout/ves_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>ves_checkoutdiscountcode/checkout.js</js></action>
|
13 |
+
</reference>
|
14 |
+
|
15 |
+
<reference name ="checkout.onepage">
|
16 |
+
<block name="discountcode" type="checkoutdiscountcode/checkout_onepage_discountcode" template="ves_checkoutcouponcode/checkout/onepage/discountcode.phtml" />
|
17 |
+
</reference>
|
18 |
+
|
19 |
+
<reference name="checkout.progress">
|
20 |
+
<action method="setTemplate" ><template>ves_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="ves_checkoutcouponcode/checkout/onepage/discountcode.phtml" />
|
26 |
+
</checkout_onepage_discountcode>
|
27 |
+
|
28 |
+
<checkout_onepage_progress>
|
29 |
+
<reference name="root">
|
30 |
+
<action method="setTemplate" ><template>ves_checkoutcouponcode/checkout/onepage/progress.phtml</template></action>
|
31 |
+
</reference>
|
32 |
+
</checkout_onepage_progress>
|
33 |
+
</layout>
|
app/design/frontend/default/default/template/ves_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/ves_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/VES_CheckoutDiscountCode.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<VES_CheckoutDiscountCode>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</VES_CheckoutDiscountCode>
|
8 |
+
</modules>
|
9 |
+
</config>
|
js/ves_checkoutdiscountcode/checkout.js
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
} else {
|
57 |
+
if (window.shippingRegionUpdater) {
|
58 |
+
shippingRegionUpdater.update();
|
59 |
+
}
|
60 |
+
response.message.join("\n");
|
61 |
+
}
|
62 |
+
|
63 |
+
return false;
|
64 |
+
}
|
65 |
+
|
66 |
+
checkout.setStepResponse(response);
|
67 |
+
}
|
68 |
+
}
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Checkout_Discount_Code</name>
|
4 |
+
<version>1.0.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license/>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Add discount code on onepage checkout page.</summary>
|
10 |
+
<description>Add discount code on onepage checkout page.</description>
|
11 |
+
<notes>Release extension</notes>
|
12 |
+
<authors><author><name>Vnecoms</name><user>auto-converted</user><email>hungvt@vnecoms.com</email></author></authors>
|
13 |
+
<date>2013-11-16</date>
|
14 |
+
<time>05:01:25</time>
|
15 |
+
<contents><target name="mageetc"><dir name="modules"><file name="VES_CheckoutDiscountCode.xml" hash="56f1dc648d258e3ec7f396598075d242"/></dir></target><target name="magecommunity"><dir name="VES"><dir name="CheckoutDiscountCode"><dir name="Block"><dir name="Checkout"><dir name="Onepage"><file name="Discountcode.php" hash="2db3b92a401d23903b32c5a33d94dd47"/><file name="Progress.php" hash="6661487caed5d43af6c691ed762e9629"/></dir><file name="Cart.php" hash="86895a529d2e71e9e7ffb17a6b31723e"/><file name="Onepage.php" hash="6da14079eaef0cf239f4ff89f1593203"/></dir></dir><dir name="Helper"><file name="Data.php" hash="bc58cc96c521e3c6e399d20e4abaa781"/></dir><dir name="Model"><file name="Observer.php" hash="04ac98a23a0855d444e63e245d6e3378"/></dir><dir name="controllers"><file name="IndexController.php" hash="be0b34b8e2d35f5bfba5ab9f603cff1b"/></dir><dir name="etc"><file name="config.xml" hash="45cf2f8fc325389081553792fac9e423"/><file name="system.xml" hash="d47956717c52a534a3a5b43803f743dc"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="ves_checkoutdiscountcode.xml" hash="04532dd09586b346ff36673b068f78cf"/></dir><dir name="template"><dir name="ves_checkoutcouponcode"><dir name="checkout"><dir name="onepage"><file name="discountcode.phtml" hash="6de8add389c0ce5a5aaa2e2a39eb6274"/><file name="progress.phtml" hash="9bbb74039a66f3397394e6be89db5536"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="ves_checkoutdiscountcode"><file name="checkout.js" hash="30e287511e6f459f600254f6c8b024ff"/></dir></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies/>
|
18 |
+
</package>
|