gpt4 book ai didi

php - 将自定义值从 parentOrderController 传递到 order-payment.tpl

转载 作者:行者123 更新时间:2023-11-30 21:55:15 24 4
gpt4 key购买 nike

我修改了 parentOrderController 中重新排序的某些部分,创建了一个变量。现在我想将该变量传递到 order-payment.tpl 中,以便我可以用它检查条件。有人可以帮帮我吗?

ParentOrderContoller.php(新增部分)

if (Tools::isSubmit('submitPay') && $id_order = (int)Tools::getValue('id_order')) {

//To check the order is in print ready state
$order = new Order((int)$id_order);
$current_order_state = $order->getCurrentOrderState();
$current_order_state_id = $current_order_state->id;
//ends here
//d($current_order_state_id);


// $this->context->cookie->current_order_state_id = $current_order_state->id;

$oldCart = new Cart(Order::getCartIdStatic($id_order, $this->context->customer->id));
$duplication = $oldCart->duplicate();

if (!$duplication || !Validate::isLoadedObject($duplication['cart'])) {
$this->errors[] = Tools::displayError('Sorry. We cannot renew your order.');
} elseif (!$duplication['success']) {
$this->errors[] = Tools::displayError('Some items are no longer available, and we are unable to renew your order.');
} else {
$this->context->cookie->id_cart = $duplication['cart']->id;

$context = $this->context;
$context->cart = $duplication['cart'];
CartRule::autoAddToCart($context);
$this->context->cookie->write();
d(Configuration::get('PS_ORDER_PROCESS_TYPE'));
if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) {
Tools::redirect('index.php?controller=order-opc');
}
Tools::redirect('index.php?controller=order');
}
}

我希望将 $current_order_state_id 传递给 order-payment.tpl。怎么做?

最佳答案

你应该能够做到这一点:

$this->context->smarty->assign(array(
'current_order_state_id' => $current_order_state_id
));

只是一个旁注。如果变量未始终设置,请在您的模板中使用:

{if isset($current_order_state_id)}
code
{/if}

关于php - 将自定义值从 parentOrderController 传递到 order-payment.tpl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45496663/

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