1

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,

blank cart

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
}
5
  • Could you paste all your code?
    – michael
    May 27, 2015 at 18:28
  • I've added what i think are the core files.
    – mushcraft
    May 27, 2015 at 23:25
  • Is error reporting enabled in index.php? There might be an error which is not shown. May 28, 2015 at 4:28
  • where do you turn it on? I have this line already error_reporting(E_ALL | E_STRICT); do you have to do anything else?
    – mushcraft
    May 29, 2015 at 10:05
  • I notice the rwd has a cart.phtml which the video guide does not address would that file need to be copied and edited perhaps?
    – mushcraft
    May 29, 2015 at 10:16

2 Answers 2

2

I found a few more typos in your code. If these don't help, could you turn debug logging on (System->Configuration->Advanced->Developer->Log Settings->Enabled) and post any error logs you get (var/log/*.log)?

In the app/code/local/Practice/OneStepCheckout/etc/config.xml file, try changing <default> to <rwd>, and <store> to <stores>:

<?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>
    <stores>
        <rwd>
            <design>
                <theme>
                    <layout>practice</layout>
                    <template>practice</template>
                    <skin>practice</skin>
                </theme>
            </design>
        </rwd>
    </stores>
</config>

In app/design/frontend/rwd/practice/layout/onestepcheckout.xml, you mispelt onepage as onespage: <block type="checkout/onepage_payment_methods" name="checkout.payment.methods" as="methods" template="checkout/onespage/payment/info.phtml">

app/code/local/Practice/OneStepCheckout/Block/OneStep.php should have a lower case 's': ../Onestep.php

0

You have typo in your config.xml in your global tags under rewrite you misspelled your module name your missing the 'e' in oneStepCheckout. Also you phtml file is wrong; don't if just a copy-error but you have the oneStepCheckout data there.

11
  • Thanks for the typo spot, however it was not the main error as there is still no cart. I have also placed the correct phtml data. So now I am wondering if the module is even being called? I have the cache disable for all components as this is just a developer environment so it isn't a matter of the old cart being cached.
    – mushcraft
    May 29, 2015 at 10:13
  • Ok, so the problem is you are clicking on the cart icon but nothing is showing? May 29, 2015 at 14:39
  • no just checkout area. add a demo item to the cart, viewing what's in the cart all okay. click checkout and it is blank like the image shown. inspecting the element there are no errors in the console, but first indication is the checkout title of the page is not the one I have defined.
    – mushcraft
    May 29, 2015 at 16:23
  • Ok, found another potential error. Your file OnePageController.php should be OnepageController.php; dont think this the source of the problem though as it not even loading. Are the javascript files that you included all native javascript files or is any of them customized? May 30, 2015 at 15:04
  • There is one js file which i have added to the end of the question. That is called in the onestep.phtml, all other js files are the default js files. Are there any other beginning magento video tutorials?
    – mushcraft
    May 31, 2015 at 21:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.