Viewing 15 posts - 1 through 15 (of 21 total)
  • Author
    Posts
  • #2196
    shackbill
    Participant

    I have several users roles (cashiers) that can create orders in WOoCommerce. I gave them each edit_shop_orders as you suggested in this post (https://www.role-editor.com/forums/topic/woocommerce-restrict-to-view-of-orders/) so they can see all orders and process refunds.

    My problem is this… I only want them to be able to view their own orders (ideally, remove the ALL and completed options seen in the attachment). If i do this with CSS, then the admin cant see them either. Is there a way to create a capability so that i can apply it to the cashiers?

    Orders View

    #2200
    Vladimir
    Keymaster

    This module may help:

    Allow user to edit selected posts and pages only


    It does not contain ‘view own items’ option yet. But if you input this user ID to the ‘Restrict by author’ field:

    he will see his own products only.
    Development version 4.25 (beta) (available at the same download page after login) includes a fix for the orders. So if you have a test copy you may test how it will work in your case.

    #2201
    shackbill
    Participant

    OK i updated to 4.25b3. Perhaps i am looking in the wrong place but i dont see the option to check ‘with author id’ see my attachment please.

    So in the future soon you will add ‘view own items’ only option because with many users it will be difficult to add ID all the time? thanks.

    Author ID

    #2202
    Vladimir
    Keymaster

    ‘With’ author user ID’ field is currently available if user has ‘edit_others_%’ capability.

    Yes, I will add this feature definitely.
    I understand a problem and version 4.25 (currently in beta state) makes a step forward. It’s capable to set edit restrictions for roles, where it will be much easier to set in case of large quant of users to restrict.

    #2203
    shackbill
    Participant

    Ok if i understand what you mean see the images attached.

    1. I add ‘edit_others_posts’ capability to user_id 11
    2. i add ’11’ to the ‘with author user Id’

    but i still see other users when user 11 is logged in. see images attached please.

    User_id 11

    Orders View

    Thanks for your help.

    #2204
    Vladimir
    Keymaster

    Orders are filtered by product owner ID = this user ID, that is 11, not by “Ship To” field value.

    #2205
    Vladimir
    Keymaster

    It seems you need some other logic then one which was realized currently. And it’s something special.

    In general WooCommerce order could be placed by any visitor, which automatically becomes a customer. Customers don’t have access to the admin back-end.
    When we talk about ability of someone to see/edit his own orders only, I mean a user like a vendor (products owner), which sees/edits just orders placed for his products.

    #2206
    Vladimir
    Keymaster

    Yes but this is a POS CASH REGISTER orders are placed by whoever is current logged in user.

    Thanks. I will add an option via filter to restrict orders by order owner or by product owner (default).

    #2247
    Vladimir
    Keymaster

    If you have a test environment try development version (current is 4.25.b5). It’s available after login from the same download page.

    I added a filter, which allows to switch off order, which added by default according to the product owner ID. So add it to the theme’s functions.php or set up this code as the ‘must-use’ plugin.

    
    add_filter('ure_edit_posts_access_add_orders_by_product_owner','ure_add_orders_by_product_owner',10,1);
    
    function ure_add_orders_by_product_owner($value) {
    
      return false;
    }
    
    #2248
    shackbill
    Participant

    Not sure i understand completely.. i installed the Beta just now. do i ALSO need to add the code to functions.php or set ‘must-use’ i am not sure what ‘must-use’ is? thanks.

    #2249
    Vladimir
    Keymaster

    About WordPress “must-use” plugins: https://codex.wordpress.org/Must_Use_Plugins

    Yes, you need to add the code to fully exclude the order from other users. They are included by default for products, where this user is an owner.

    #2250
    shackbill
    Participant

    ok i added code to functions.php in child theme. but i still see other orders when i click ALL. Is there a capability i should check also?

    Orders View

    #2251
    Vladimir
    Keymaster

    Are the previously discussed settings (editing restricted by author ID) still active for this user?

    #2252
    shackbill
    Participant

    Yes this one here.

    User id 11

    #2253
    shackbill
    Participant

    this is just a dev site would you like me to send you admin access so you can see?

Viewing 15 posts - 1 through 15 (of 21 total)
  • You must be logged in to reply to this topic.