Public Ticket #3637971

Stop sales rep from editing orders

Closed
Comments
5 Tickets 2
Renan Braz started the conversation 2 years ago on April 29, 2024 at 7:58pm

Hello, 

I would like to know how can I stop the sales rep from editing any of the order informations. Specially the status. 

I already tried editing the roles of the agent on wordpress, but it doesn't make much difference. 


Best regards 

5996855159.png



Attached files:

2,762
KingsPlugins replied 2 years ago on May 3, 2024 at 11:50am

Hello Renan,

You can add the following PHP code snippet to your site to remove the various options and buttons that allow the agent to edit the order:

add_action('admin_head', function(){
    if (is_agent(get_current_user_id())){
        ?>
        <style>
            #woocommerce-order-actions, .edit_address, .add-items{
                display: none !important;
            }
        </style>
        <script>
            jQuery(document).ready(function(){
                jQuery('#woocommerce-order-actions, .edit_address, .add-items').remove();
            });
        </script>
        <?php
    }
});
function is_agent($user_id){
    $agent_group = get_user_meta($user_id,'salesking_group',true);
    if ($agent_group !== 'none' && !empty($agent_group)){
        return true;
    } else {
        return false;
    }
}

This snippet can be added to functions.php, or by following our guide here: https://b2bkingplugin.com/docs/how-to-add-a-snippet-php-or-js/

Let me know if you need anything else, any button or area there to be removed, and I can adjust the snippet for that,

Kind regards,

Stefan

Sign In