Skip to content

Instantly share code, notes, and snippets.

@stevejburge
Created January 23, 2024 17:53
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 stevejburge/dcef793341d129c10ce28e736d85536c to your computer and use it in GitHub Desktop.
Save stevejburge/dcef793341d129c10ce28e736d85536c to your computer and use it in GitHub Desktop.
WooCommerce Hide Refund Button
add_action('admin_head', 'hide_wc_refund_button');
function hide_wc_refund_button() {
global $post;
if (!current_user_can('administrator') && !current_user_can('editor')) {
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('.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