controller / front / validation.php
<?php
class Paytr_CheckoutValidationModuleFrontController extends ModuleFrontController
{
public function postProcess()
{
$this->display_column_left = false;
$this->display_column_right = false;
$cart = $this->context->cart;
$total = $cart->getOrderTotal;
$currency = $this->context->currency;
$customer = new Customer( $cart->id_customer );
if ( !Validate::isLoadedObject($customer) )
Tools::redirect('index.php?controller=order&step=1');
//$this->context->cart->delete();
//$isOrderX = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' SELECT * FROM '._DB_PREFIX_.'orders WHERE id_cart = '.$cart->id);
//var_dump($_POST);
//Tools::redirect('index.php?controller=history');
//Tools::redirect('index.php?controller=order-confirmation&id_cart='.$cart->id.'&id_module='.$this->module->id.'&id_order='.(int)$this->module->currentOrder.'&key='.$customer->secure_key);
echo 'index.php?controller=order-confirmation&id_cart='.$cart->id.'&id_module='.$this->module->id.'&id_order='.(int)$this->module->currentOrder.'&key='.$customer->secure_key;
}
}
我需要从购物车ID中找到订单ID。这些是我尝试过的。我无法获得id_order。我对Db查询充满希望。但这不起作用。
答案 0 :(得分:0)
您可以使用以下代码获取它:$id_order = Order::getOrderByCartId($id_cart);
答案 1 :(得分:0)
只要未注册订单,就无法获得“ id_order”。
如果已注册订单,并且确定没有更好的方法,则可以使用以下代码查找已订购的最新购物车:
$this->context->customer->getLastCart(true);
答案 2 :(得分:0)
这是导致验证订单后删除cookie的问题。所以它不显示id_cart。所以我想像这样。
$isOrderX = Db::getInstance()->getRow(' SELECT * FROM '._DB_PREFIX_.'orders WHERE id_customer = '.$cart->id_customer.' ORDER BY id_order DESC ');
Tools::redirect('index.php?controller=order-confirmation&id_cart='.$isOrderX['id_cart'].'&id_module='.$this->module->id.'&id_order='.$isOrderX['id_order'].'&key='.$customer->secure_key);