How do I access the current order id in opencart and put it in a variable? I am working in a new file, which did not come with the standard opencart install.
The closest I have been able to get is the following code, which doesn’t work:
<?php
session_start();
$order_id = $this->session->data['order_id'];
?>
Thanks in advance.
The order ID isn’t set until the customer gets to the final page of the checkout process, so you won’t be able to get it before that. For your code above, you can’t use
$this->session->data['order_id']unless you are in an opencart class, therefore you would need to use$_SESSION['order_id']