[英]Accessing the Order object from the Cart Id in Prestashop
I am POSTing the Cart id to my module method.我正在将 Cart id 发布到我的模块方法中。 From that I can obviously create the Cart object using that id.
由此我显然可以使用该 ID 创建 Cart 对象。 But how do I access the Order object that corresponds to that Cart object?
但是如何访问对应于 Cart 对象的 Order 对象呢?
I've tried something like;我试过类似的东西;
$cart = new Cart($_POST['id']);
var_dump($this->context->order);
And also trying to do a sort of where() query on the Order (where id_cart is equal to the id in my Cart object);并且还尝试对订单进行一种 where() 查询(其中 id_cart 等于我的 Cart 对象中的 id);
$order = new Order('id_cart', $cart->id);
It is probably really obvious but I just don't know Prestashop very well.这可能真的很明显,但我只是不太了解 Prestashop。
The reason I am trying to do this is so I change the status of an Order if the payment has timed out.我尝试这样做的原因是,如果付款超时,我会更改订单的状态。
我赢了;
$order = Order::getOrderByCartId((int)($cart->id));
尝试
$order = Order::getByCartId($cart->id)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.