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

时间:2017-11-10 17:48:31

标签: prestashop-1.7

参考: How to remove delivery shipping step on prestashop 1.6.1?

我正在寻找Prestashop v1.7.2.4的解决方案,任何想法? 我试图评论一些代码行,但它创建了额外的问题,如不提交订单 enter image description here

3 个答案:

答案 0 :(得分:0)

我设法通过将所有订单分配到单个地址并从结帐流程中删除地址步骤来隐藏地址步骤。假设您有一个id = 2的地址,使用下面的代码,所有订单都将使用此地址创建。

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

  2. 挂钩actionDispatcher更新我们在数据库中的购物车

  3. 并将您的模块挂钩到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覆盖地址
    2. 倍率/类/ Address.php:

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

        class Cart extends CartCore {
          public function checkAndUpdateAddresses(){
            return true; // always valid
          }
        }
        
        1. 覆盖OrderController以从结帐中删除地址步骤 倍率/控制器/前/ OrderController.php
        2. 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() // )) } }

          地址步骤现在隐藏在前台办公室: no address confirmed

          如果您只执行第5步,系统会将您重定向到checkout?step=1,因为ps_wirepayment会在验证时对cart->id_address进行检查: modules/ps_wirepayment/controllers/front/validation.php

          if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active){
            Tools::redirect('index.php?controller=order&step=1');
          }
          

          干杯,

          弗洛里安

答案 1 :(得分:0)

在prestashop 1.7。*上,我设法禁用了整个交付步骤(使它们消失了)。在我的情况下,客户的业务模型是货到付款。

为此,我在源代码中将其注释掉。

在文件中 controllers / front / OrderController.php 注释出checkoutDeliveryStep

答案 2 :(得分:0)

只需注释掉以下几行

->addStep(new CheckoutAddressesStep(
            $this->context,
            $translator,
            $this->makeAddressForm()
        ));

在/controllers/front/OrderController.php