gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-05 02:17:45 25 4
gpt4 key购买 nike

引用: How to remove delivery shipping step on prestashop 1.6.1?

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

最佳答案

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

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

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

并将您的模块挂接到 actionDispatcher

modules/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();
}
}
}

3. 用硬编码的 id_address 覆盖地址

override/classes/Address.php

    class Address extends AddressCore {
public static function getFirstCustomerAddressId($id_customer, $active = true){
return 2; // hardcoded id_address
}
}

4.覆盖购物车以获得始终有效的地址

override/classes/Cart.php

    class Cart extends CartCore {
public function checkAndUpdateAddresses(){
return true; // always valid
}
}

5. 覆盖 OrderController 以从结帐中删除地址步骤

override/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()
// ))
}
}

地址步骤现在对前台隐藏了: 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');
}

干杯,

弗洛里安

关于prestashop-1.7 - 如何删除 prestashop 1.7 上的送货步骤?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47228469/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com