# Get the order object

**URL:** <https://forum.modmore.com/t/get-the-order-object/387>\
**Category:** SimpleCart\
**Created:** [August 31, 2016, 2:00pm UTC](https://forum.modmore.com/t/get-the-order-object/387 "2016-08-31T14:00:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nirz](https://forum.modmore.com/letter_avatar_proxy/v4/letter/n/48db29/32.png) [@nirz](https://forum.modmore.com/u/nirz)\
**Post date:** [August 31, 2016, 2:00pm UTC](https://forum.modmore.com/t/get-the-order-object/387/1 "2016-08-31T14:00:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mhamstra](https://forum.modmore.com/user_avatar/forum.modmore.com/mhamstra/32/459_2.png) [@mhamstra](https://forum.modmore.com/u/mhamstra)\
**Post date:** [August 31, 2016, 2:20pm UTC](https://forum.modmore.com/t/get-the-order-object/387/2 "2016-08-31T14:20:58Z")

</div>

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](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:

```auto
/**
 * @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);

```

---

<div class="post-metadata">

**Author:** ![nirz](https://forum.modmore.com/letter_avatar_proxy/v4/letter/n/48db29/32.png) [@nirz](https://forum.modmore.com/u/nirz)\
**Post date:** [August 31, 2016, 2:40pm UTC](https://forum.modmore.com/t/get-the-order-object/387/3 "2016-08-31T14:40:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nirz](https://forum.modmore.com/letter_avatar_proxy/v4/letter/n/48db29/32.png) [@nirz](https://forum.modmore.com/u/nirz)\
**Post date:** [August 31, 2016, 2:52pm UTC](https://forum.modmore.com/t/get-the-order-object/387/4 "2016-08-31T14:52:34Z")

</div>

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.
