Before HPOS the order save hook can be checked this way:
<code><?php
use AutomatticWooCommerceUtilitiesOrderUtil;
add_action('save_post', 'my_save_wc_order_other_fields', 20, 1);
function my_save_wc_order_other_fields($post_id)
{
// this check is HPOS aware already
if (!OrderUtil::is_order($post_id, wc_get_order_types())) {
return;
}
// We need to verify this with the proper authorization (security stuff).
// Check the user's permissions.
// TODO: this code is not HPOS aware yet?!
if (!current_user_can('edit_shop_order', $post_id)) {
return $post_id;
}
}
</code>
<code><?php
use AutomatticWooCommerceUtilitiesOrderUtil;
add_action('save_post', 'my_save_wc_order_other_fields', 20, 1);
function my_save_wc_order_other_fields($post_id)
{
// this check is HPOS aware already
if (!OrderUtil::is_order($post_id, wc_get_order_types())) {
return;
}
// We need to verify this with the proper authorization (security stuff).
// Check the user's permissions.
// TODO: this code is not HPOS aware yet?!
if (!current_user_can('edit_shop_order', $post_id)) {
return $post_id;
}
}
</code>
<?php
use AutomatticWooCommerceUtilitiesOrderUtil;
add_action('save_post', 'my_save_wc_order_other_fields', 20, 1);
function my_save_wc_order_other_fields($post_id)
{
// this check is HPOS aware already
if (!OrderUtil::is_order($post_id, wc_get_order_types())) {
return;
}
// We need to verify this with the proper authorization (security stuff).
// Check the user's permissions.
// TODO: this code is not HPOS aware yet?!
if (!current_user_can('edit_shop_order', $post_id)) {
return $post_id;
}
}
How the current_user_can('edit_shop_order', $post_id)
part should be replaced for the HPOS support?