1

我试图在一步结帐过程中引入一个额外的步骤(在开始时,就在登录之后)。这是在 Magento v1.8 上出售的商品是虚拟产品类型(因此结帐时应该出现的唯一部分是:[新部分]、计费、付款和订单审查。

我看过很多文章——一篇最适合我的需要(尽管我认为它是为 v1.4 编写的,并且使用现有页面的重载而不是编写新模块)。我也关注了这篇文章,但它旨在介绍一个模块——我认为这不是绝对需要的。SO 文章Magento 添加步骤到 Onepage Checkout也被引用。

我的问题: 我在 OPC 页面上出现了额外的步骤,但是应该扩展活动部分的手风琴却没有。这是由于active未设置 CSS 类,而由于新模块未标记为活动,因此未设置该类。

我的问题: 为了确保将新模块设置为 ActiveStep,我从以下步骤中遗漏了什么?

到目前为止我所做的尝试: 简而言之,我<?php echo $this->getActiveStep(); ?>在 onepage.phtml 上引入了声明,它表明“计费”仍然是活动页面(默认第一页)。

到目前为止,我已经针对页面的顺序进行了以下更改:

  • _getStepCodes()在 abstract.php 中添加了新部分(registerkids)

    return array('login', 'registerkids', 'billing', 'shipping', 'shipping_method', 'payment', 'review');
    
  • 在 Checkout/Block/Onepage/registerkids.php 中创建了一个 app/code/local 文件

    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();
        }
    }
    
  • 从 Checkout\Block\Onepage\billing.php 中删除了if ($this->isCustomerLoggedIn())设置下一步的语句

  • 更新 Checkout\Model\Type\Onepage.phpinitCheckout()

    if (!($step==='login' || $customerSession->isLoggedIn() && $step==='registerkids')) {
        $checkout->setStepData($step, 'allow', false); // where 'registerkids' used to say 'billing'
    
  • 对 opcheckout.js 进行了以下更改 -

    • this.steps = ['login', 'registerkids', 'billing', 'shipping', 'shipping_method', 'payment', 'review'];(增加了新的部分)
    • this.currentStep = 'registerkids';
    • 更新setMethod: function(),以便登录后的下一部分是this.gotoSection('registerkids', true);
    • 将 template/persistent/checkout/onepage/login.phtml JS 更新customMethod()checkout.gotoSection('registerkids');
    • 将 Checkout/Onepage.php 更新getActiveStep()return $this->isCustomerLoggedIn() ? 'registerkids' : 'login';
4

1 回答 1

1

经过相当多的调查,控制初始 Active 步骤的函数是:

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

这可以在 中找到Mage\Checkout\Block\Onepage.php,调用它的函数onepage.phtml$this->getActiveStep()

它对我不起作用的原因是该文件位于错误的位置。现在工作正常。希望这可以帮助某人

于 2014-01-15T20:44:46.167 回答