如何删除prestashop 8.1上的送货步骤?

问题描述 投票:0回答:1

参考:如何删除prestashop 1.7上的送货步骤?

我想完全禁用结账订单流程中的地址步骤,因为我只销售数字产品,对了解客户地址不感兴趣

enter image description here

我按照Address.php、Cart.php和OrderController.php中的答案进行了覆盖,但我只得到一个空白页面

  1. 从 BO 创建一个地址,假设它的 id_address = 2

  2. 挂钩actionDispatcher以更新数据库中的购物车

并将你的模块挂接到actionDispatcher

模块/yourmodule/yourmodule.php

<?php
public function hookActionDispatcher($params = []){
  // every time we go to a payment controller, we update current cart id_addresses to 2
  $payments_controllers = [
    'ps_wirepaymentvalidationModuleFrontController',
    'ps_checkpaymentvalidationModuleFrontController',
  ];
  if($params['controller_type'] == Dispatcher::FC_FRONT &&
    in_array($params['controller_class'], $payments_controllers) &&
    $params['is_module']){

    $cart = new Cart($this->context->cookie->id_cart);
    if($cart->id_address_delivery == 0 || $cart->id_address_invoice){
      $cart->id_address_delivery = 2;
      $cart->id_address_invoice = 2;
      $cart->update();
    }
  }
}
  1. 用硬编码的 id_address 覆盖地址

覆盖/类/Address.php

class Address extends AddressCore {
  public static function getFirstCustomerAddressId($id_customer, $active = true){
    return 2; // hardcoded id_address
  }
}
  1. 覆盖购物车以获得始终有效的地址

覆盖/classes/Cart.php

class Cart extends CartCore {
  public function checkAndUpdateAddresses(){
    return true; // always valid
  }
}
  1. 重写 OrderController 以从结帐中删除地址步骤

覆盖/controllers/front/OrderController.php

class OrderController extends OrderControllerCore {
  protected function bootstrap(){
    // copy everything from https://github.com/PrestaShop/PrestaShop/blob/1.7.2.x/controllers/front/OrderController.php#L90
    // but comment those lines:
    // ->addStep(new CheckoutAddressesStep(
    //     $this->context,
    //     $translator,
    //     $this->makeAddressForm()
    // ))
  }
}
prestashop
1个回答
0
投票

这就是你需要做的,我在搞乱代码库很长时间后发现了它:

  1. 转到 checkout-process.tpl

  2. 替换这个:

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

与:

{foreach from=$steps item="step" key="index"}
  {if $index != 2}
    {if $index == 3}
      {assign var="position" value=3}
    {else}
      {assign var="position" value=($index + 1)}
    {/if}
    {render identifier  =  $step.identifier
            position    =  $position
            ui          =  $step.ui
    }
  {/if}
{/foreach}

你的工作已经完成了!希望这有效 我的 prestashop 版本:8.1.6

© www.soinside.com 2019 - 2024. All rights reserved.