I have a script file called 99bill_received.php
.
Within that script, I need to call a method update()
within a class called ModelCheckoutOrder
, which resides in a different path from this PHP script.
The class name of where the update()
method resides is called ModelCheckoutOrder
.
For most OpenCart extensions, the PHP files are class files, so you can inherently call something like this without initializing an object.
/**
* Updates an existing order history using the order_id and the updated
* order_status
* @param $order_id
* @param $order_status
*/
function update_order_history($order_id, $order_status)
{
// load the order.php file
$this->load->model('checkout/order');
// Execute update()
$this->model_checkout_order->update(
$order_id,
$order_status,
"",
true
);
}
Notice the $this->load->model()
line. You don't need to initialize the ModelCheckoutOrder
object in order to use it (correct me if I am wrong here about that).
My question is - how do I access this class method within my PHP script file? I am NOT in an OpenCart .php
script at the moment - only calling it since I need to access the function update()
which is an OpenCart file.
I have tried to initialize the ModelCheckoutOrder
class by using $model = new ModelCheckoutOrder()
, but it did not work as I intended (meaning, I have no idea what went right or wrong). Please pardon my ignorance in the OOPHP.