2

In frontend/base/default/checkout/onepage.phtml there is a foreach loop

<?php $i=0; foreach($this->getSteps() as $_stepId => $_stepInfo): ?>

which renders the checkout steps

<h2><?php echo $_stepInfo['label'] ?></h2>

As fas as I know the getSteps() comes from app/code/core/Mage/Checkout/Block/Onepage.php

public function getSteps()
{
    $steps = array();
    $stepCodes = $this->_getStepCodes();

    if ($this->isCustomerLoggedIn()) {
        $stepCodes = array_diff($stepCodes, array('login'));
    }

    foreach ($stepCodes as $step) {
        $steps[$step] = $this->getCheckout()->getStepData($step);
    }

    return $steps;
}

which extends to the class in app/code/core/Mage/Checkout/Block/Onepage/Abstract.php

protected function _getStepCodes()
{
    return array('login', 'billing', 'shipping', 'shipping_method', 'payment', 'review');
}

But where is the ["label"] part coming from? Or how could I add an additional step to the checkout as well as the correct new label for it? Thx

1

label of each step are set in the _construct of each step block.

For example, look at the Mage_Checkout_Block_Onepage_Login::_construct. You will see :

$this->getCheckout()->setStepData('login', array('label'=>Mage::helper('checkout')->__('Checkout Method'), 'allow'=>true));

You will find the same logic in Mage_Checkout_Block_Onepage_Billing, Mage_Checkout_Block_Onepage_Shipping, Mage_Checkout_Block_Onepage_Shipping_Method, Mage_Checkout_Block_Onepage_Payment and finally Mage_Checkout_Block_Onepage_Review.

Adding an additional step requires a lot of job : PHP obviously but a lot of javascript updates too : see skin/frontend/base/default/js/opcheckout.js and you will find hard coded step names.

  • Thank you. That's what I was looking for. I actually don't need a new step, only a new label. Maybe I can figure out a work around, otherwise I just have to hard code a new label to my template I guess. Thank you. – zlep Feb 21 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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