1
votes

i'm trying to introduce an additional step in the one step checkout process (at the start, just after login). This is on Magento v1.8 and the items being sold are virtual product types (therefore the only sections that should appear at checkout are: [new section], billing, payment, and order review.

I've had a look at a number of articles - this one being most suited to my needs (albeit written for v1.4 i think, and uses a the overloading of existing pages instead of writing a new module). I've also followed along with this article however it aims to introduce a module - something which I don't think is absolutely required for this. SO article Magento Adding Step to Onepage Checkout was also referenced.

My problem: I have the additional step appearing on the OPC page, however the accordion which should be expanding the active section isn't. This is due to the CSS class active not being set, which is in turn not set since the new module is not marked as active.

My question: What have I missed from the steps below to ensure that the new module is set as the ActiveStep?

What I've attempted to so far: In short, I've introduced <?php echo $this->getActiveStep(); ?>statement on onepage.phtml and it's indicating that 'billing' is still the active page (the default first page).

I've made the following changes so far specifically around the ordering of pages:

  • added the new section (registerkids) to _getStepCodes() in abstract.php

    return array('login', 'registerkids', 'billing', 'shipping', 'shipping_method', 'payment', 'review');
    
  • created a app/code/local file in Checkout/Block/Onepage/registerkids.php with

    class Mage_Checkout_Block_Onepage_Registerkids extends Mage_Checkout_Block_Onepage_Abstract
    { 
       protected function _construct()
        {
            $this->getCheckout()->setStepData('registerkids', array(
                'label'     => Mage::helper('checkout')->__('Assign your kids to the booking'),
                'is_show'   => $this->isShow()
            ));
            if ($this->isCustomerLoggedIn()) {
                $this->getCheckout()->setStepData('registerkids', 'allow', true);
    
            }
            parent::_construct();
        }
    }
    
  • removed the if ($this->isCustomerLoggedIn()) statement from Checkout\Block\Onepage\billing.php that sets the next step

  • updated Checkout\Model\Type\Onepage.php initCheckout() with

    if (!($step==='login' || $customerSession->isLoggedIn() && $step==='registerkids')) {
        $checkout->setStepData($step, 'allow', false); // where 'registerkids' used to say 'billing'
    
  • made the following changes to opcheckout.js -

    • this.steps = ['login', 'registerkids', 'billing', 'shipping', 'shipping_method', 'payment', 'review']; (added new section)
    • this.currentStep = 'registerkids';
    • updated setMethod: function() so that next section after login is this.gotoSection('registerkids', true);
    • updated template/persistent/checkout/onepage/login.phtml JS customMethod() to checkout.gotoSection('registerkids');
    • updated Checkout/Onepage.php getActiveStep() to return $this->isCustomerLoggedIn() ? 'registerkids' : 'login';
1
Instead of new step, why dont you add new custom fields on existing step, i have developed a solution adding custom fields on checkout page.user2499580
thanks for this - i've toyed with that idea however in terms of the input (from a customer standpoint) the type of data is quite different - it would appear "weird" to a customer. I also don't want to re-purpose any other modules that aren't being used (e.g. shipping method) just in case they'll be required in a few months as the business model evolvesAndrewO

1 Answers

1
votes

after quite a bit of investigation, the function that controls the initial Active step is:

public function getActiveStep()
{
    return $this->isCustomerLoggedIn() ? 'yoursection' : 'login';
}

this can be found in Mage\Checkout\Block\Onepage.php, and the function that calls it from onepage.phtml is $this->getActiveStep()

The reason it wasn't working for me was that the file was in the wrong place. Working fine now. Hope this helps someone