skip to Main Content

I’m using How can I remove product link from order details page? answer code

However, I’ve tried this code and placed it on functions.php, but it does not work, and this is not for backend.

Is there any specific custom code to be placed in functions.php? for only shop manager to disable the order item’s link? It can be non-clickable or it will redirect to the page like ‘no access’ for shop manager. Because I do not want shop manager have the access to the product page and edit the details of product which they can only view the items.

For better reference the item order is at here: https://snipboard.io/uK28js.jpg
enter image description here

2

Answers


  1. Chosen as BEST ANSWER

    An update on the alternative solution using User Role Editor plugin.

    To specify for a user role, may untick all 'Posts' (refer to the image below), to prevent a role (backend) to access the link to edit the product. This applies to the user role who doesn't want the user role to have complete access to the product page. Where they only can see the product name with SKU (if have) without access to edit product page.

    enter image description here

    After update the role, and under woocommerce > orders > click on order item enter image description here

    It will shows 'Sorry, you are not allowed to edit this item'

    enter image description here

    Feel free to add answer asides from this.


  2. If you want you can do it by editing plugin file

    woocommerceincludesadminmeta-boxesviewshtml-order-item.php
    

    here you’ll see the hyperlink
    change this line:

    echo $product_link ? '<a href="' . esc_url( $product_link ) . '" class="wc-order-item-name">' . wp_kses_post( $item->get_name() ) . '</a>' : '<div class="wc-order-item-name">' . wp_kses_post( $item->get_name() ) . '</div>';
    

    Just remove the tag

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search