Skip to content

Instantly share code, notes, and snippets.

@garvs
Last active August 14, 2017 04:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garvs/953e5eb87405571be64710703b063ad1 to your computer and use it in GitHub Desktop.
Save garvs/953e5eb87405571be64710703b063ad1 to your computer and use it in GitHub Desktop.
Block WooCommerce refunds for role
<?php
add_action('admin_head', 'hide_wc_refund_button');
function hide_wc_refund_button() {
global $post;
if (!current_user_can('sales')) {
return;
}
if (strpos($_SERVER['REQUEST_URI'], 'post.php?post=') === false) {
return;
}
if (empty($post) || $post->post_type != 'shop_order') {
return;
}
?>
<script>
jQuery(function () {
jQuery('.refund-items').hide();
jQuery(document).ajaxComplete(function() {
jQuery('.refund-items').css("display","none");})
});
jQuery('.order_actions option[value=send_email_customer_refunded_order]').remove();
if (jQuery('#original_post_status').val()=='wc-refunded') {
jQuery('#s2id_order_status').html('Refunded');
} else {
jQuery('#order_status option[value=wc-refunded]').remove();
}
</script>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment