如何将PrestaShop 1.7 Checkout手风琴步骤转换为步骤进度栏?

问题描述

我对PrestaShop和PHP还是很陌生,我被要求将PrestaShop 1.7(经典主题)的当前手风琴结帐步骤转换为步骤进度栏。我有一些足够好的CSS概念和一些JavaScript,但是当我查看PrestaShop文件时,我完全迷失了。 :(

这里有一些代码(注释中是我尝试添加以创建步骤进度栏的内容)。 checkout-process.tpl是个谜:

{foreach from=$steps item="step" key="index"}
  {render identifier  =  $step.identifier
          position    =  ($index + 1)
          ui          =  $step.ui
          {* steps       =  $steps *}
  }
{/foreach}

然后我有checkout-step.tpl:

{block name='step'}
{* <div id="checkout-steps">
  <ul id="checkout-steps__bar">
    {foreach from=$steps item="step" key="index"}
    <li id="{$step.identifier}" class="step-title h3">{$step.title}</li>
    {/foreach}
  </ul>
</div> *}

<section id="{$identifier}" class="{[
                              'checkout-step'   => true,'-current'        => $step_is_current,'-reachable'      => $step_is_reachable,'-complete'       => $step_is_complete,'js-current-step' => $step_is_current
                          ]|classnames}">
  <h1 class="step-title h3">
    <i class="material-icons rtl-no-flip done">&#xE876;</i>
    <span class="step-number">{$position}</span>
    {$title}
    <span class="step-edit text-muted">
      <img src="{$urls.img_url}/icn/edit.png" alt="{l s='Update' d='Shop.Theme.Actions'}" class="icn-16" />
      {l s='Edit' d='Shop.Theme.Actions'}</span>
  </h1>

  <div class="content">
    {block name='step_content'}DUMMY STEP CONTENT{/block}
  </div>
</section>
{/block}

我设法通过编辑CheckoutProcess.php来获得标题:

public function render(array $extraParams = array())
    {
        $scope = $this->smarty->createData(
            $this->smarty
        );

        $params = array(
            'steps' => array_map(function (CheckoutStepInterface $step) {
                return array(
                    'identifier' => $step->getIdentifier(),'ui' => new RenderableProxy($step),// Add title to steps array
                    'title' => $step->getTitle(),);
            },$this->getSteps()),);

        $scope->assign(array_merge($extraParams,$params));

        $tpl = $this->smarty->createTemplate(
            $this->template,$scope
        );

        return $tpl->fetch();
    }

我认为我做的不是正确的事情,但是如果我几乎了解那里发生的事情,那么我不知道从哪里开始。 -_-“ 如果有人得到了一些建议甚至更好的建议(一个人总是可以梦想)已经尝试了这种修改,我将很高兴收到任何信息,帮助和代码示例! 预先感谢。

解决方法

花了我一段时间,这可能不是最好的方法,但是我通过添加进度条然后使用自定义CSS和JavaScript覆盖默认行为来管理转换。

有很多代码,我不确定是否在其中发布有用,但是如果有人想要一些信息或代码,我会很乐意分享!

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...