Last active
August 14, 2017 04:51
-
-
Save garvs/953e5eb87405571be64710703b063ad1 to your computer and use it in GitHub Desktop.
Block WooCommerce refunds for role
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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