Hi,
If you want to build a plugin yourself, then I think the best would be to do it like this:
- create a custom item field of the type "multiple dropdown" and use the "MySQL query" mode to dynamically fill the selector with the users of your website. Also, configure the "access" setting of the custom field to a specific user group of your website so that only school managers, added to that user group, will see that selector on the products.
That way, on each product page, the school managers will be able to select the users for which they want to add the products to the cart.
- create a plugin of the group "hikashop" and implement the "onAfterOrderUpdate" trigger, as you mentioned.
However, instead of copying the order to the user, (which won't work if you have different users selected for the same order), I would recommend to just add the user groups to the users based on what product was bought. That will require having one user group for each content you want to be available. You can use the plugins/hikashop/group/ plugin as an example for some of your pieces of code. This plugin adds user groups to the current user after the purchase thanks to the "user group after purchase" setting it adds to the products.
Then, you can either restrict Joomla articles to user groups, or even restrict "free download" files you've added to products based on the user group. That way, students will directly get access to the files on the product pages, without having to go through orders they didn't create, which would confuse them.