Is there a hook I can use when I make a change to someone's order via the admin (such as their address, or a custom meta field)? I read this question but unfortunately woocommerce_process_shop_order_meta
is fired before the order is saved, meaning I have no access to the newly updated data. What I need is to be able to use the new data that is saved to the order.
UPDATE: An issue with using save_post_shop_order
is that the meta is updated before this is hit, so I can't compare the previously saved meta value, for example:
$metaArray = $_POST['meta'];
foreach($metaArray as $meta => $key) {
$metaArr[$key["key"]] = $key["value"];
}
$meta = get_post_meta($order->ID);
if($meta['coverstart'][0] != $metaArr['coverstart']) {
die("COVER START DATE HAS CHANGED");
}
The die()
is never hit, because the script always gets the newly saved value.