According to this post, custom post type, hide or disable the trash button in publish meta box, this is specifically removing for post. I couldn’t find any post solutions relating to remove ‘Move to trash’ under woocommerce order action. Does this code apply same to removing this button on woocommerce?
function my_custom_admin_styles() {
?>
<style type="text/css">
.post-type-inhoud form #delete-action{
display:none;
}
</style>
<?php
}
add_action('admin_head', 'my_custom_admin_styles');
How do I apply this to woocommerce removing ‘move to trash’ button under order action and only specifically for shop manager.
2
Answers
To prevent deleting post/order/custom post is capability per user role. To prevent shop_manager role from deleting orders you must remove that capability. All other solutions will visualy work but someone who knows his stuff still can delete order if he wants. So place the following function in your functions.php
Bonus How to know what capabilities current user have
The correct CSS class to target is: .order_actions li #delete-action
The following will hide it for all backend users (admins, shop managers, etc.):
If you only wanted to apply this CSS for shop managers (and therefore not for admins for example), you need conditional logic, and specifically you need to use the inbuilt WooCommerce function wc_current_user_has_role():