Get the order object

Hi everyone,
What’s the best way to get a specific order object in a snippet.
I am trying to get it in a snippet and not in a hook with no luck so far.
Thanks in advance,
Nir

In a finished order hook, you can access it with $hook->getValue('order') per the documentation at https://www.modmore.com/simplecart/documentation/frontend/checkout/finished-order-hooks/#jump_and_inside_your_modx_snippets

In a standalone snippet where you know the order ID, you can do something like this:

/**
 * @var scHooks $hook
 * @var SimpleCart $sc
 */
$corePath = $modx->getOption('simplecart.core_path', null, $modx->getOption('core_path').'components/simplecart/') . 'model/simplecart/';
$sc = $modx->getService('simplecart','SimpleCart', $corePath, $scriptProperties);
if (!($sc instanceof SimpleCart)) {
    $modx->log(modX::LOG_LEVEL_ERROR, '[CartHookFinished] Cannot load SimpleCart classes...');
    return false;
}

$orderId = 5;

$order = $modx->getObject('simpleCartOrder', $orderId);

Hi Mark, thanks for replying.
I actually tried to do just that based on the docs, but it doesn’t work for some reason.
I can’t get or set any field

My bad, setting works, I just forgot to save.
Still can’t get fields, I’m trying like that:
$output = $order->get('status'); return $output;

Edit: everything works now.
I think I need a break…

Thanks a lot for your help Mark.