Created
March 28, 2013 14:22
Magento files for question posted on stackoverflow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<config> | |
<modules> | |
<TestCheck_Checkout> | |
<version>0.1.0</version> | |
</TestCheck_Checkout> | |
</modules> | |
<global> | |
<blocks> | |
<checkout> | |
<rewrite> | |
<onepage>TestCheck_Checkout_Block_Onepage</onepage> | |
</rewrite> | |
</checkout> | |
</blocks> | |
<resources> | |
<custom_setup> | |
<setup> | |
<module>TestCheck_Checkout</module> | |
</setup> | |
<connection> | |
<use>core_setup</use> | |
</connection> | |
</custom_setup> | |
<custom_write> | |
<connection> | |
<use>core_write</use> | |
</connection> | |
</custom_write> | |
<custom_read> | |
<connection> | |
<use>core_read</use> | |
</connection> | |
</custom_read> | |
</resources> | |
</global> | |
<frontend> | |
<routers> | |
<checkout> | |
<args> | |
<modules> | |
<TestCheck_Checkout before="Mage_Checkout">TestCheck_Checkout</TestCheck_Checkout> | |
</modules> | |
</args> | |
</checkout> | |
</routers> | |
<layout> | |
<updates> | |
<custom> | |
<file>custom.xml</file> | |
</custom> | |
</updates> | |
</layout> | |
</frontend> | |
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<layout version="0.1.0"> | |
<checkout_onepage_index> <!-- Adding our new step to onepage block --> | |
<reference name='checkout.onepage'> | |
<action method='setTemplate'><template>checkout/onepage.phtml</template></action> | |
<block type="checkout_onepage_testcheck" name="checkout.onepage.testcheck" as="testcheck" template="checkout/onepage/testcheck.phtml"/> | |
</reference> | |
<reference name='checkout.progress'> <!-- Change the template of progress block --> | |
<action method='setTemplate'><template>checkout/onepage/progress.phtml</template></action> | |
</reference> | |
</checkout_onepage_index> | |
<checkout_onepage_progress> <!-- Change the template of progress block --> | |
<reference name='root'> | |
<action method='setTemplate'><template>checkout/onepage/progress.phtml</template></action> | |
</reference> | |
</checkout_onepage_progress> | |
</layout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CheckTest_Model_Checkout_Type_Onepage extends Mage_Checkout_Model_Type_Onepage{ | |
public function saveTestCheck($data){ | |
//echo 'lalala';exit; | |
if (empty($data)) { | |
return array('error' => -1, 'message' => $this->_helper->__('Invalid data.')); | |
} | |
$this->getQuote()->setTestCheckLike($data['like']); | |
$this->getQuote()->collectTotals(); | |
$this->getQuote()->save(); | |
$this->getCheckout() | |
->setStepData('testcheck', 'allow', true) | |
->setStepData('testcheck', 'complete', true) | |
->setStepData('review', 'allow', true); | |
return array(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="page-title"> | |
<h1><?php echo $this->__('Checkout') ?></h1> | |
</div> | |
testing... | |
<script type="text/javascript" src="<?php echo $this->getJsUrl('varien/accordion.js') ?>"></script> | |
<script type="text/javascript" src="<?php echo $this->getSkinUrl('js/opcheckout.js') ?>"></script> | |
<!-- New Code Added Below --> | |
<script type="text/javascript" src="<?php echo $this->getSkinUrl('js/testcheckcheckout.js') ?>"></script> | |
<script type="text/javascript">countryRegions = <?php echo $this->helper('directory')->getRegionJson() ?></script> | |
<ol class="opc" id="checkoutSteps"> | |
<?php var_dump($this->getSteps()); ?> | |
<?php $i=0; foreach($this->getSteps() as $_stepId => $_stepInfo): ?> | |
<?php if (!$this->getChild($_stepId) || !$this->getChild($_stepId)->isShow()): continue; endif; $i++ ?> | |
<li id="opc-<?php echo $_stepId ?>" class="section<?php echo !empty($_stepInfo['allow'])?' allow':'' ?><?php echo !empty($_stepInfo['complete'])?' saved':'' ?>"> | |
<div class="step-title"> | |
<span class="number"><?php echo $i ?></span> | |
<h2><?php echo $_stepInfo['label'] ?></h2> | |
<a href="#"><?php echo $this->__('Edit') ?></a> | |
</div> | |
<div id="checkout-step-<?php echo $_stepId ?>" class="step a-item" style="display:none;"> | |
<?php echo $this->getChildHtml($_stepId) ?> | |
</div> | |
</li> | |
<?php endforeach ?> | |
</ol> | |
<script type="text/javascript"> | |
var accordion = new Accordion('checkoutSteps', '.step-title', true); | |
<?php if($this->getActiveStep()): ?> | |
accordion.openSection('opc-<?php echo $this->getActiveStep() ?>'); | |
<?php endif ?> | |
var checkout = new TestCheck(accordion,{ | |
progress: '<?php echo $this->getUrl('checkout/onepage/progress') ?>', | |
review: '<?php echo $this->getUrl('checkout/onepage/review') ?>', | |
saveMethod: '<?php echo $this->getUrl('checkout/onepage/saveMethod') ?>', | |
failure: '<?php echo $this->getUrl('checkout/cart') ?>'} | |
); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'Mage/Checkout/controllers/OnepageController.php'; | |
class TestCheck_Checkout_OnepageController extends Mage_Checkout_OnepageController{ | |
public function saveTestCheckAction(){ | |
if ($this->_expireAjax()) { | |
return; | |
} | |
if ($this->getRequest()->isPost()) { | |
$data = $this->getRequest()->getPost('testcheck', array()); | |
// get section and redirect data | |
$redirectUrl = $this->getOnepage()->getQuote()->getPayment()->getCheckoutRedirectUrl(); | |
$result = $this->getOnepage()->saveTestCheck($data); | |
if (!isset($result['error'])) { | |
$this->loadLayout('checkout_onepage_review'); | |
$result['goto_section'] = 'review'; | |
$result['update_section'] = array( | |
'name' => 'review', | |
'html' => $this->_getReviewHtml() | |
); | |
} | |
if ($redirectUrl) { | |
$result['redirect'] = $redirectUrl; | |
} | |
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result)); | |
} | |
} | |
protected function _getTestCheckHtml() | |
{ | |
$layout = $this->getLayout(); | |
$update = $layout->getUpdate(); | |
$update->load('checkout_onepage_testcheck'); | |
$layout->generateXml(); | |
$layout->generateBlocks(); | |
$output = $layout->getOutput(); | |
return $output; | |
} | |
public function savePaymentAction() | |
{ | |
if ($this->_expireAjax()) { | |
return; | |
} | |
try { | |
if (!$this->getRequest()->isPost()) { | |
$this->_ajaxRedirectResponse(); | |
return; | |
} | |
// set payment to quote | |
$result = array(); | |
$data = $this->getRequest()->getPost('payment', array()); | |
$result = $this->getOnepage()->savePayment($data); | |
if (empty($result['error'])) { | |
$result['goto_section'] = 'testcheck'; | |
$result['update_section'] = array( | |
'name' => 'testcheck', | |
'html' => $this->_getTestCheckHtml() | |
); | |
} | |
} catch (Mage_Payment_Exception $e) { | |
if ($e->getFields()) { | |
$result['fields'] = $e->getFields(); | |
} | |
$result['error'] = $e->getMessage(); | |
} catch (Mage_Core_Exception $e) { | |
$result['error'] = $e->getMessage(); | |
} catch (Exception $e) { | |
Mage::logException($e); | |
$result['error'] = $this->__('Unable to set Payment Method.'); | |
} | |
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Magento | |
* | |
* NOTICE OF LICENSE | |
* | |
* This source file is subject to the Academic Free License (AFL 3.0) | |
* that is bundled with this package in the file LICENSE_AFL.txt. | |
* It is also available through the world-wide-web at this URL: | |
* http://opensource.org/licenses/afl-3.0.php | |
* If you did not receive a copy of the license and are unable to | |
* obtain it through the world-wide-web, please send an email | |
* to license@magentocommerce.com so we can send you a copy immediately. | |
* | |
* DISCLAIMER | |
* | |
* Do not edit or add to this file if you wish to upgrade Magento to newer | |
* versions in the future. If you wish to customize Magento for your | |
* needs please refer to http://www.magentocommerce.com for more information. | |
* | |
* @category design | |
* @package base_default | |
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) | |
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) | |
*/ | |
/* @var $this Mage_Checkout_Block_Onepage_Progress */ | |
?> | |
<div class="block block-progress opc-block-progress"> | |
<div class="block-title"> | |
<strong><span><?php echo $this->__('Your Checkout Progress') ?></span></strong> | |
</div> | |
<div class="block-content"> | |
<dl> | |
<?php if ($this->getCheckout()->getStepData('billing', 'is_show')): ?> | |
<?php if ($this->isStepComplete('billing')): ?> | |
<dt class="complete"> | |
<?php echo $this->__('Billing Address') ?> <span class="separator">|</span> | |
<a href="#billing" onclick="checkout.gotoSection('billing'); return false;"><?php echo $this->__('Change') ?></a> | |
</dt> | |
<dd class="complete"> | |
<address><?php echo $this->getBilling()->format('html') ?></address> | |
</dd> | |
<?php else: ?> | |
<dt> | |
<?php echo $this->__('Billing Address') ?> | |
</dt> | |
<?php endif; ?> | |
<?php endif; ?> | |
<?php if ($this->getCheckout()->getStepData('shipping', 'is_show')): ?> | |
<?php if ($this->isStepComplete('shipping')): ?> | |
<dt class="complete"> | |
<?php echo $this->__('Shipping Address') ?> <span class="separator">|</span> | |
<a href="#payment" onclick="checkout.gotoSection('shipping');return false;"><?php echo $this->__('Change') ?></a> | |
</dt> | |
<dd class="complete"> | |
<address><?php echo $this->getShipping()->format('html') ?></address> | |
</dd> | |
<?php else: ?> | |
<dt> | |
<?php echo $this->__('Shipping Address') ?> | |
</dt> | |
<?php endif; ?> | |
<?php endif; ?> | |
<?php if ($this->getCheckout()->getStepData('shipping_method', 'is_show')): ?> | |
<?php if ($this->isStepComplete('shipping_method')): ?> | |
<dt class="complete"> | |
<?php echo $this->__('Shipping Method') ?> <span class="separator">|</span> | |
<a href="#shipping_method" onclick="checkout.gotoSection('shipping_method'); return false;"><?php echo $this->__('Change') ?></a> | |
</dt> | |
<dd class="complete"> | |
<?php if ($this->getShippingMethod()): ?> | |
<?php echo $this->escapeHtml($this->getShippingDescription()) ?> | |
<?php $_excl = $this->getShippingPriceExclTax(); ?> | |
<?php $_incl = $this->getShippingPriceInclTax(); ?> | |
<?php if ($this->helper('tax')->displayShippingPriceIncludingTax()): ?> | |
<?php echo $_incl; ?> | |
<?php else: ?> | |
<?php echo $_excl; ?> | |
<?php endif; ?> | |
<?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?> | |
(<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>) | |
<?php endif; ?> | |
<?php else: ?> | |
<?php echo $this->__('Shipping method has not been selected yet') ?> | |
<?php endif; ?> | |
</dd> | |
<?php else: ?> | |
<dt> | |
<?php echo $this->__('Shipping Method') ?> | |
</dt> | |
<?php endif; ?> | |
<?php endif; ?> | |
<?php if ($this->getCheckout()->getStepData('payment', 'is_show')): ?> | |
<?php if ($this->isStepComplete('payment')): ?> | |
<dt class="complete"> | |
<?php echo $this->__('Payment Method') ?> <span class="separator">|</span> | |
<a href="#payment" onclick="checkout.gotoSection('payment'); return false;"><?php echo $this->__('Change') ?></a> | |
</dt> | |
<dd class="complete"> | |
<?php echo $this->getPaymentHtml() ?> | |
</dd> | |
<?php else: ?> | |
<dt> | |
<?php echo $this->__('Payment Method') ?> | |
</dt> | |
<?php endif; ?> | |
<?php endif; ?> | |
<?php if ($this->getCheckout()->getStepData('testcheck', 'is_show')): ?> | |
<?php if($this->getCheckout()->getStepData('testcheck', 'complete')): ?> | |
<dt class="complete"> | |
<?php echo $this->__('TestCheck Review') ?> <span class="separator">|</span> <a href="#testcheck" onclick="checkout.accordion.openSection('opc-testcheck'); return false;"><?php echo $this->__('Change') ?></a> | |
</dt> | |
<dd class="complete"> | |
<div> | |
<?php echo $this->__('Testcheck Review Is: ');?> | |
<?php | |
$like = $this->getQuote()->getTestCheckLike(); | |
echo $like; | |
?> | |
</div> | |
</dd> | |
<?php else: ?> | |
<dt> | |
<?php echo $this->__('TestCheck') ?> | |
</dt> | |
<?php endif; ?> | |
<?php endif; ?> | |
</dl> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class TestCheck_Checkout_Block_Onepage_TestCheck extends Mage_Checkout_Block_Onepage_Abstract{ | |
protected function _construct(){ | |
$this->getCheckout()->setStepData('testcheck', array( | |
'label' => Mage::helper('checkout')->__('Test Check'), | |
'is_show' => $this->isShow() | |
)); | |
parent::_construct(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php echo 'testcheck one page lalalal'; ?> | |
<form id="co-testcheck-form" action=""> | |
<fieldset> | |
<ul class="form-list"> | |
<li id="testcheck-form"> | |
<fieldset> | |
<ul> | |
<li class="wide"> | |
<label for="testcheck:like" class="required"><em>*</em><?php echo $this->__('Do you like this post?') ?></label> | |
<div class="input-box"> | |
<input type='text' name='testcheck[like]' class="required-entry input-text" id="testcheck:like" value='testing testing'/> | |
</div> | |
</li> | |
</ul> | |
</fieldset> | |
</li> | |
</ul> | |
<div class="buttons-set" id="testcheck-buttons-container"> | |
<p class="required"><?php echo $this->__('* Required Fields') ?></p> | |
<button type="button" title="<?php echo $this->__('Continue') ?>" class="button" onclick="testcheck.save()"><span><span><?php echo $this->__('Continue') ?></span></span></button> | |
<span class="please-wait" id="testcheck-please-wait" style="display:none;"> | |
<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...') ?> | |
</span> | |
</div> | |
</fieldset> | |
</form> | |
<script type="text/javascript"> | |
//<![CDATA[ | |
var testcheck = new TestCheckMethod('co-tetscheck-form','<?php echo $this->getUrl('onepage/saveTestCheck') ?>'); | |
var testcheckForm = new VarienForm('co-testcheck-form'); | |
//]]> | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<config> | |
<modules> | |
<TestCheck_Checkout> | |
<active>true</active> | |
<codePool>local</codePool> | |
</TestCheck_Checkout> | |
</modules> | |
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var TestCheck = Class.create(Checkout, { | |
initialize: function($super,accordion, urls){ | |
$super(accordion, urls); | |
//New Code Addded | |
this.steps = ['login', 'billing', 'shipping', 'shipping_method', 'payment', 'testcheck', 'review']; | |
}, | |
setMethod: function(){ | |
if ($('login:guest') && $('login:guest').checked) { | |
this.method = 'guest'; | |
var request = new Ajax.Request( | |
this.saveMethodUrl, | |
{method: 'post', onFailure: this.ajaxFailure.bind(this), parameters: {method:'guest'}} | |
); | |
Element.hide('register-customer-password'); | |
} | |
else if($('login:register') && ($('login:register').checked || $('login:register').type == 'hidden')) { | |
this.method = 'register'; | |
var request = new Ajax.Request( | |
this.saveMethodUrl, | |
{method: 'post', onFailure: this.ajaxFailure.bind(this), parameters: {method:'register'}} | |
); | |
Element.show('register-customer-password'); | |
} | |
else{ | |
alert(Translator.translate('Please choose to register or to checkout as a guest')); | |
return false; | |
} | |
} | |
}); | |
var TestCheckMethod = Class.create(); | |
TestCheckMethod.prototype = { | |
initialize: function(form, saveUrl){ | |
this.form = form; | |
if ($(this.form)) { | |
$(this.form).observe('submit', function(event){this.save();Event.stop(event);}.bind(this)); | |
} | |
this.saveUrl = saveUrl; | |
this.validator = new Validation(this.form); | |
this.onSave = this.nextStep.bindAsEventListener(this); | |
this.onComplete = this.resetLoadWaiting.bindAsEventListener(this); | |
}, | |
validate: function() { | |
if(!this.validator.validate()) { | |
return false; | |
} | |
return true; | |
}, | |
save: function(){ | |
if (checkout.loadWaiting!=false) return; | |
if (this.validate()) { | |
checkout.setLoadWaiting('testcheck'); | |
var request = new Ajax.Request( | |
this.saveUrl, | |
{ | |
method:'post', | |
onComplete: this.onComplete, | |
onSuccess: this.onSave, | |
onFailure: checkout.ajaxFailure.bind(checkout), | |
parameters: Form.serialize(this.form) | |
} | |
); | |
} | |
}, | |
resetLoadWaiting: function(transport){ | |
checkout.setLoadWaiting(false); | |
}, | |
nextStep: function(transport){ | |
if (transport && transport.responseText){ | |
try{ | |
response = eval('(' + transport.responseText + ')'); | |
} | |
catch (e) { | |
response = {}; | |
} | |
} | |
if (response.error) { | |
alert(response.message); | |
return false; | |
} | |
if (response.update_section) { | |
$('checkout-'+response.update_section.name+'-load').update(response.update_section.html); | |
} | |
if (response.goto_section) { | |
checkout.gotoSection(response.goto_section); | |
checkout.reloadProgressBlock(); | |
return; | |
} | |
checkout.review(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment