Enforce read access on WooCommerce Categories via Parent/Child heirarchy inheritance

Hi Guys,

I’m running WooCommerce with Groups & Groups Restrict Categories. I have many streams of Product Categories (each with many children Product Categories) and I would like to set the read access ‘capabilities’ to a parent Product Category, and have the same capabilities automatically inherited by the children Product Categories of the parent Product Category. With the option to manually set the ‘capabilities’ to a child Product Category and have it override any automatic inheritance.

I anticipate there will need to some additional caveats on this, where an individual Product with its own read access capabilities can either override it’s conflicting Category read access capabilities or it can adhere to enforcement. This could be set as either a global option from within the “Options” panel and/or can be set as an option per Category for granular override control.

At present, this inheritance of capabilities across read access of Product Categories does not occur, and you must manually set the read access for every child Product Category (a reasonable work around but could be improved).

Thanks.


Comments

3 responses to “Enforce read access on WooCommerce Categories via Parent/Child heirarchy inheritance”

  1. Emma-Jane Avatar
    Emma-Jane

    Sorry, I forgot to give this context to the front-end. Let me clarify:

    Yes, I can see the capabilities are inherited, which is great – that’s working well! The issue I have is within the Sidebar widget WooCommerce Product Categories (Option: ‘Show Hierarchy’ enabled).

    Groups Restrict Categories is hiding the restricted Parent Product Category nav items, but it is not hiding the child Product Categories nav items. Do you have a function/hook/filter/action I can use it combo with WooCommerce hooks to target these child nav items?

    Thanks.

    1. antonio Avatar

      Hi Emma-Jane,
      sorry, I had misunderstood.
      Capabilities are inherited from Groups to Subgroups, but not in taxonomies. So it works as you say, you need to add the restrictions manually to the child categories.
      We will consider what you described for future updates, thanks for the suggestion.
      Regards,
      Antonio B.

  2. antonio Avatar
    antonio

    Hi,
    Capabilities are automatically inherited to the children categories.
    If you have:
    Animals
    –Dogs
    and ‘Animals’ has a capability ‘animalsCap’, then ‘Dogs’ has this inherited capacity.
    Relating to products, if we have ‘Necklace’ in the category Aninmals->Dogs with a capability ‘necklaceCap’.
    Only if the user has the capabilities ‘animalsCap’ AND ‘necklaceCap’ then he can see the ‘Necklace’ product.

    But thanks you for the suggestions.
    Regards,
    Antonio B.

Share