Skip to content

Instantly share code, notes, and snippets.

@andyg5000
Created October 15, 2015 17:47
Show Gist options
  • Save andyg5000/fca24f278a785a14ffe6 to your computer and use it in GitHub Desktop.
Save andyg5000/fca24f278a785a14ffe6 to your computer and use it in GitHub Desktop.
Add a method to determine if an orders changed date has been updated in the database
/**
* Compares the given order's changed date against the database value.
*
* @param $order object
* A fully loaded order object.
*
* @return bool
* Boolean indicating whether or not the order object has changed.
*/
function commerce_order_has_changed($order) {
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'commerce_order', '=')
->propertyCondition('order_id', $order->order_id, '=')
->propertyCondition('changed', $order->changed, '>');
$result = $query->execute();
return (!empty($result)) ? TRUE : FALSE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment