• Resolved lenamtl

    (@lenamtl)


    Hi,

    I’m using a basic role plugin, and I have set a new role for store manager to only allow the user to manage the order.
    I think this role should be added in the future as it is a good way to help store owner to start (for non tech saavy).

    What is the role permission ID that allow a user to add an existing product to an order?

    What is the role permission ID that allow to add a new order?

    Or if no specific id what does it required to have access to it without having to add-edit product?

    Also I’m looking for a snippet to hide top menu item to specific role name.

    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support lionel.a11n

    (@lioneldaniel)

    Hello @lenamtl,

    This is a pretty advanced topic! The core roles and capabilities in WooCommerce are pretty straightforward. You can also read about WooCommerce’s roles and capabilities here for an overview: https://docs.woocommerce.com/document/roles-capabilities/

    The more specific capabilities you want are largely the same as the standard capabilities for any custom post type in WordPress using the capability_type key in its registration array.

    You can view the function which lists these capabilities out to be added to the shop_manager role in the GitHub repository: https://github.com/woocommerce/woocommerce/blob/56e23e0d14f67e5828f6bf243c85353892527dad/includes/class-wc-install.php#L1184

    Filling in from that array, orders use the shop_order custom post type so the associated capabilities are as follows:

    • edit_shop_order
    • read_shop_order
    • delete_shop_order
    • edit_shop_orders
    • edit_others_shop_orders
    • publish_shop_orders
    • read_private_shop_orders
    • delete_shop_orders
    • delete_private_shop_orders
    • delete_published_shop_orders
    • delete_others_shop_orders
    • edit_private_shop_orders
    • edit_published_shop_orders

    These are very much like the similarly named capabilities for posts and pages in WordPress, which you can read about here in the WordPress codex. For products or coupons, you can replace the shop_order/shop_orders part above with product/producs and coupon/coupons.

    Let us know if that helps, or if you have further questions!

    Thread Starter lenamtl

    (@lenamtl)

    Hi,

    what does it take to allow role to add a new order, without giving access to add-edit-delete product?

    Plugin Support Shohan Hossain Nabil – a11n

    (@sohanhossain)

    Hello @lenamtl,

    what does it take to allow role to add a new order, without giving access to add-edit-delete product?

    You will need to create a custom role for this. There are many 3rd-party custom role plugins available on the internet and you can use one of them for this.

    Thanks!

    Plugin Support lionel.a11n

    (@lioneldaniel)

    Hi @lenamtl,

    Shohan is correct, a plugin can help you do this without code. A popular, free plugin that does this is User Role Editor.

    You will find instructions on the plugin page – the basic gist is this:

    1. Install the User Role Editor plugin
    2. In your WordPress Dashboard, go to Users → User Role Editor
    3. Click ‘Add role’ on the right hand side to create your role. You can copy another role as a template for yours if you want to.
    4. Check the capabilities you want for your new role and click ‘Update’. Here is how that may look: Screenshot
    5. Now, you can assign the role to users in their profiles.

    If you have any trouble with that plugin, please visit the User Roles Editor support forum. You can learn more about roles generally in the WordPress Codex.

    I hope that helps! I’m marking this topic as resolved. If you have further questions, don’t hesitate to open a new topic. Thanks!

    Thread Starter lenamtl

    (@lenamtl)

    Hi,

    I’m already using this plugin, and I already ask the question, but no answer.

    I have created a custom role but I could not find a way to add these 2 capabilities

    Woocommerce:
    – Add a coupon to an existing order (manual order modification)
    – Add a new order (manually)

    So at the moment by default only admin can add a coupon to an existing order, and the custom role cannot be an admin.

    I need to find a way to add this capability to my custom user.

    For this I need to know the name of the capability or permission ID / name in order to fix the problem.

    I’m looking for this information since a few weeks and nobody can tell …

    • This reply was modified 3 years, 8 months ago by lenamtl.
    • This reply was modified 3 years, 8 months ago by lenamtl.
    • This reply was modified 3 years, 8 months ago by lenamtl.
    Plugin Support lionel.a11n

    (@lioneldaniel)

    Hello lenamtl,

    The permissions you want are included in the following permissions. Unfortunately there is no way to tease these permissions out by themselves in default WooCommerce, to do that you would need custom development.

    Regarding your specific questions, editing an order and adding a coupon to an existing order manually will both require the edit_shop_order permissions. Try these permissions:

    • read_shop_order
    • edit_shop_order
    • edit_shop_orders
    • edit_others_shop_orders

    There are not more granular capabilities in WooCommerce for ‘add a coupon to a shop order’, so if these capabilities are too permissive for what you’re going for, you’ll need to code a solution yourself or collaborate with a developer.

    As this is a fairly complex development topic, I also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.`WooCommerce Customizations Page

    I hope you find what you’re looking for!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘role & permissions (hide menu items)’ is closed to new replies.