I am Currently following the free video guides on magento training website. Part 2 Has you create a new module and define the views for it. creating your own theme, block, template, js in the design and skin folders.
My first attempt of following the guide I created all my files per the video in the location they specified ./app/design/frontend/default/practice and ./skin/frontend/default/practice.
Following the guide again I moved the files needed to be created while following the guides under rwd as per theming of rwd for this thread. But the results are the same.
I don't know if this is a theming or a module issue cause the error. but i have added this OneStepCheckout.xml to the app/etc/modules just like in Part1 of the video guides. However this is the results of both,
Edit: after some naming issues from OnePageController to Onepagecowtroller, the default One Page Checkout is displayed It looks like the actual Model in etc/modules/Practice_OneStepCheckout.xml is not be loaded/called Can anyone help me solve this please?
Code:
app/etc/modules/Practice_OneStepCheckout.xml
<?xml version="1.0" ?>
<config>
<modules>
<Practice_OneStepCheckout>
<active>true</active>
<codePool>local</codePool>
<depends> <!-- this module only works when the 3 listed modules are enabled -->
<Mage_Sales/>
<Mage_CatalogInventory/>
<Mage_Checkout/>
</depends>
</Practice_OneStepCheckout>
</modules>
</config>
app/code/local/Practice/OneStepCheckout/Block/OneStep.php
<?php
class Practice_OneStepCheckout_Block_Onestep extends Mage_Checkout_Block_Onepage {
//overwriting getSteps as the view removes 3 standard handlers of the onepage controller
public function getSteps()
{
$steps = array();
$stepsCodes = array('billing', 'shipping', 'shipping_method', 'payment');
foreach ($stepsCodes as $step)
{
$steps[$step] = $this->getCheckout()->getStepData($step);
}
return $steps;
}
}
app/code/local/Practice/OneStepCheckout/controllers/OnepageController.php
<?php
require_once('Mage/Checkout/controllers/OnepageController.php');
class Practice_OneStepCheckout_OnepageController extends Mage_Checkout_OnepageController {
public function saveCartAction()
{
$this->saveBillingAction();
$this->saveShippingAction();
$this->saveShippingMethodAction();
$this->savePaymentAction();
$this->saveOrderAction();
}
}
app/code/local/Practice/OneStepCheckout/etc/config.xml
<?xml version="1.0" ?>
<config>
<modules>
<Practice_OneStepCheckout>
<version>0.0.1</version>
</Practice_OneStepCheckout>
</modules>
<frontend>
<routers>
<checkout>
<args>
<modules>
<!-- refer to existing route
place are controller node before the core MAGE_Checkout.
-->
<onestepcheckout before="Mage_Checkout">Practice_OneStepCheckout</onestepcheckout>
</modules>
</args>
</checkout>
</routers>
<layout>
<updates>
<onestepcheckout>
<file>onestepcheckout.xml</file>
</onestepcheckout>
</updates>
</layout>
</frontend>
<!--
<global>
<blocks>
<onestepcheckout><class>Practice_OnStepCheckout_Block</class></onestepcheckout>
</blocks>
</global>
-->
<global>
<blocks>
<checkout>
<!-- rewrite the default Onepage checkout module name -->
<rewrite>
<onepage>Practice_OnStepCheckout_Block_Onestep</onepage>
</rewrite>
</checkout>
</blocks>
</global>
<store>
<default>
<design>
<theme>
<layout>practice</layout>
<template>practice</template>
<skin>practice</skin>
</theme>
</design>
</default>
</store>
</config>
app/design/frontend/rwd/practice/layout/onestepcheckout.xml
<?xml version="1.0" ?>
<!-- elements on this level is treated as a handle, minimum are default and ActionBase which takes the
format of [route_name]_[controller_name]_[action_name] -->
<layout version="0.1.0">
<checkout_onepage_index translate="label">
<label>One Step Checkout</label>
<!-- Mage_Checkout -->
<remove name="left"/>
<remove name="right"/>
<reference name="root">
<action method="setTemplate">
<template>page/1column.phtml</template>
</action>
</reference>
<reference name="content">
<remove name="checkout.onepage"/>
<block type="checkout/onepage" name="checkout.onepage2" template="checkout/onestep.phtml">
<block type="checkout/onepage_billing" name="checkout.onepage.billing" as="billing"
template="checkout/onestep/billing.phtml"/>
<block type="checkout/onepage_shipping" name="checkout.onepage.shipping" as="shipping"
template="checkout/onestep/shipping.phtml"/>
<block type="checkout/onepage_shipping_method" name="checkout.onepage.shipping_method"
as="shipping_method" template="checkout/onestep/shipping_method.phtml">
<block type="checkout/onepage_shipping_method_available"
name="checkout.onepage.shipping_method.available" as="available"
template="checkout/onestep/shipping_method/available.phtml"/>
</block>
<block type="checkout/onepage_payment" name="checkout.onepage.payment" as="payment"
template="checkout/onestep/payment.phtml">
<block type="checkout/onepage_payment_methods" name="checkout.payment.methods" as="methods"
template="checkout/onespage/payment/info.phtml">
<action method="setMethodFormTemplate">
<method>purchaseorder</method>
<template>payment/form/purchaseorder.phtml</template>
</action>
</block>
<block type="core/template" name="checkout.onepage.payment.additional" as="additional"/>
<block type="core/template" name="checkout.onepage.payment.methods_additional"
as="methods_additional"/>
</block>
</block>
</reference>
</checkout_onepage_index>
</layout>
app/design/frontend/rwd/practice/template/checkout/onestep.phtml
<?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 [email protected] 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.magento.com for more information.
*
* @category design
* @package rwd_default
* @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
?>
<div class="page-title">
<h1><?php echo $this->__('One Step Checkout') ?></h1>
</div>
<script type="text/javascript" src="<?php echo $this->getSkinUrl('js/onestepcheckout.js') ?>"></script>
<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>
<script type="text/javascript" src="<?php echo $this->getSkinUrl('js/opcheckout_rwd.js') ?>"></script>
<ol class="opc" id="checkoutSteps">
<?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 allow active">
<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" >
<?php echo $this->getChildHtml($_stepId) ?>
</div>
</li>
<?php endforeach ?>
</ol>
<script type="text/javascript">
//<![CDATA[
var accordion = new Accordion('checkoutSteps', '.step-title', true);
<?php if($this->getActiveStep()): ?>
accordion.openSection('opc-<?php echo $this->getActiveStep() ?>');
<?php endif ?>
var checkout = new Checkout(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>
skin/frontend/rwd/practice/js/onestepcheckout.js
var Onestep = Class.create();
Onestep.prototype = {
initialize: function(saveUrl, successUrl, parentId){
this.saveUrl = saveUrl;
this.successUrl = successUrl;
this.parentId = parentId;
this.onSave = this.nextStep.bindAsEventListener(this);
this.onComplete = this.resetLoadWaiting.bindAsEventListener(this);
},
save: function(){
var validator = new Validation(this.parentId);
if (validator.validate()) {
checkout.setLoadWaiting('payment');
var request = new Ajax.Request(
this.saveUrl,
{
method:'post',
onComplete: this.onComplete,
onSuccess: this.onSave,
onFailure: checkout.ajaxFailure.bind(checkout),
parameters: Form.serialize(this.parentId)
}
);
}
},
resetLoadWaiting: function(transport){
checkout.setLoadWaiting(false, this.isSuccess);
},
nextStep: function(transport){
if (transport && transport.responseText) {
try{
response = eval('(' + transport.responseText + ')');
}
catch (e) {
response = {};
}
if (response.redirect) {
this.isSuccess = true;
location.href = response.redirect;
return;
}
if (response.success) {
this.isSuccess = true;
window.location=this.successUrl;
}
else{
var msg = response.error_messages;
if (typeof(msg)=='object') {
msg = msg.join("\n");
}
if (msg) {
alert(msg);
}
}
if (response.update_section) {
$('checkout-'+response.update_section.name+'-load').update(response.update_section.html);
}
if (response.goto_section) {
checkout.gotoSection(response.goto_section, true);
}
}
},
isSuccess: false
}