How School manager purchase product for student

  • Posts: 168
  • Thank you received: 7
2 years 4 months ago #336745

Hi
I use hikashop for sell products as a file. For example video of course. in my website, studenta is registered in the past means they have an account in my joomla. Now school manager must be purchase each product for each appropriate student. What is the solution to implement this scenario in hikashop? Is it possible implement with hikashop?

Please Log in or Create an account to join the conversation.

  • Posts: 4486
  • Thank you received: 609
  • MODERATOR
2 years 4 months ago #336747

Hello,

From what you tell us, we are quite sure that what you requested is possible with HikaShop.
Now, in order to guide you more precisely can you detail more of your scenario please ?

Give us a concrete example, and develop each specific point like what is precisely the "School Manager", the buyer ? And this buyer have to associated each file to the required student ?...
By very specific, more you will be precise more our guidance will be complete.

Regards

Last edit: 2 years 4 months ago by Philip.
The following user(s) said Thank You: sadaf3d

Please Log in or Create an account to join the conversation.

  • Posts: 168
  • Thank you received: 7
2 years 4 months ago #336852

Thank you @Philip

Philip wrote: From what you tell us, we are quite sure that what you requested is possible with HikaShop.
Now, in order to guide you more precisely can you detail more of your scenario please ?

it is simple. there is a parent that have some child and can buy different products for him.

Philip wrote: Give us a concrete example, and develop each specific point like what is precisely the "School Manager", the buyer ?

yes. School Manager is headmaster of school, main buyer (headmaster of school) must buy each file (hikashop product) for each of his user (student of his school). then student when login to his account can see his file as a his purchase. it is similar to parent/child relational, a parent can purchase some product for his child.

Philip wrote: And this buyer have to associated each file to the required student?

yes or other each way you say. but headmaster can purchase some product for user A and other product for user B and ...

Please Log in or Create an account to join the conversation.

  • Posts: 81361
  • Thank you received: 13037
  • MODERATOR
2 years 4 months ago #336863

Hi,

Unfortunately, there is no mechanism for that in HikaShop. Only the user who made the purchase get access to the content linked with the products purchased.
There is also no user selection mechanism. That could be added quite easily with a custom field but the main problem is with giving access to the content purchased to the users after the order.

One thing you could do instead is to use HikaSerial so that products are linked to different packs of serials.
Then, when the user purchases products on the website, he would receive serial codes.
Then, the user could manually distribute the codes to the different students and then, they could use the consume interface of HikaSerial once logged in to get access to the content through them being added to user groups linked to the serial packs:
www.hikashop.com/support/documentation/2...s-groupconsumer.html
www.hikashop.com/support/documentation/1...onsume-features.html
This thus requires the school manager to manually distribute the serial codes to the students, and for the students to manually consume their serial codes on your website. But to get exactly what you want and automate everything would require a substantial custom development (problem several thousands euros of developers fees).

The following user(s) said Thank You: sadaf3d

Please Log in or Create an account to join the conversation.

  • Posts: 168
  • Thank you received: 7
2 years 4 months ago #336867

nicolas wrote: Hi,

Unfortunately, there is no mechanism for that in HikaShop. Only the user who made the purchase get access to the content linked with the products purchased.
There is also no user selection mechanism. That could be added quite easily with a custom field but the main problem is with giving access to the content purchased to the users after the order.

thank you @nicolas
i can develop my plugin for this section of your reply.
can you little more describe about what trigger and php functions must be use to add product to a user as purchased . for example i understand i must use onAfterorderupdate to get custom field but is it possible add this order to user in custom field with some simple hikashop code?

Please Log in or Create an account to join the conversation.

  • Posts: 81361
  • Thank you received: 13037
  • MODERATOR
2 years 4 months ago #336870

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.

The following user(s) said Thank You: sadaf3d

Please Log in or Create an account to join the conversation.

  • Posts: 168
  • Thank you received: 7
2 years 4 months ago #336908

nicolas wrote: 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.

Hi
1- how can i access to current user id in "MySQL query"? (i want load only child of this user. all user of my website is very huge and can not load in product page. i want school manager A can access to his 100 student and school manager B can access to his 120 students and...)
2- what Table type must be select? i select "Product" but i can't use in front-end. i select "item" type for Table. is it correct? (with "item" select the field render as a multiselect field and can see in the back and front but if i select "product" i can see only in back-end )

Last edit: 2 years 4 months ago by sadaf3d.

Please Log in or Create an account to join the conversation.

  • Posts: 81361
  • Thank you received: 13037
  • MODERATOR
2 years 4 months ago #336912

Hi,

1. There is no mechanism for that with the "MySQL query" system of custom fields.
In that case, what you can do is to implement the Fields API in your HikaShop plugin in order to create your own type of custom field:
www.hikashop.com/support/documentation/6...entation.html#fields
You can see an example of such a plugin with the files in the folder plugins/hikashop/datepickerfield/ of your website which add the "advanced date picker" type of custom fields to the system. In your case, you would extend the single dropdown class from administrator/components/com_hikashop/classes/field.php so that you would just have to inject the values manually in the display function of your custom field type class before calling the display function of the parent class. That way, you can use all the PHP you want and thus you can easily retrieve the current user id with something like this:

$user = JFactory::getUser(); echo $user->id;
before running your MySQL query on the joomla users table so that you can load only the users of a particular user group (and you could have a hard coded table to match the user id of the current user with the id of the user group or something like that).
- Yes, you want to use "item", not "product".

The following user(s) said Thank You: sadaf3d

Please Log in or Create an account to join the conversation.

  • Posts: 168
  • Thank you received: 7
2 years 4 months ago #336955

Thank you @nicolas.

nicolas wrote: Hi,

In your case, you would extend the single dropdown class from administrator/components/com_hikashop/classes/field.php

1- i am in trying to implement what you say. are you sure it is better to use single dropdown? is there any multidropdown Class to use?

2- i have an other question. how can i increase product price when i select the users from dropdown list? for example when a school manager add more user, the price of that product must be increase. if school manager select 2 user for this product price must *2 if he select 5 users then total price= product price *5.
2.1 what is your suggestion : if add more user increase product price or increase quantity of product?
2.2 if you suggest second way (increase quantity) maybe i need some validation to check quantity is equal to number of selected users in my custom field. which .php i must implement that validation? in the onafterorderupdate plugin or in the my field plugin or where?

Please Log in or Create an account to join the conversation.

  • Posts: 81361
  • Thank you received: 13037
  • MODERATOR
2 years 4 months ago #336957

Hi,

1. Ah yes, I meant to say multiple dropdown class. It's in the same file.

2. Here, you can see a plugin which multiply the price of the product in the cart by the number entered in a custom item field:
www.hikashop.com/marketplace/product/221...quantity-plugin.html
So you could base yourself on this plugin's code so that instead of directly multiplying the price by the value in the custom field, you would count the number of selected values in it and multiply the price by that calculated number.

You could alternatively add javascript to change the value in the quantity input field. However, as you say, you would need a server-side check to make sure that this quantity is correct. It's possible too. You could for example implement the onAfterCartProductsLoad(&$cart) trigger when the cart is being loaded to check that the quantity is correct and modify it if not.

However, I think the solution based on the custom quantity plugin is a simpler approach.

Please Log in or Create an account to join the conversation.

  • Posts: 168
  • Thank you received: 7
2 years 4 months ago #337265

Thank you @nicolas
Successfully I could did it, but I have a little question:
how can I prevent from Installing this plugin where hikashop is not installed? can you give me sample code?

Please Log in or Create an account to join the conversation.

  • Posts: 81361
  • Thank you received: 13037
  • MODERATOR
2 years 4 months ago #337283

Hi,

You want to use the preflight hook of the joomla installer:
docs.joomla.org/Extension_Installer/Installer_Hooks
docs.joomla.org/J3.x:Creating_a_simple_m...pdate_script_file/en
And in it, you want to check if the file administrator/components/com_hikashop/helpers/helper.php is there.
If not you can stop the installation process.
Looking a bit online they recommend either returning false or throwing an exception:
joomla.stackexchange.com/questions/22273...stalling-a-component
joomla.stackexchange.com/questions/20982...antain-actual-folder

The following user(s) said Thank You: sadaf3d

Please Log in or Create an account to join the conversation.

  • Posts: 168
  • Thank you received: 7
1 year 7 months ago #343846

Hi again nicolas.
I create a component for relation ship between users in joomla. And also create this custom field and it is work for some month. Is it possible put in hikashop marketplace?

Please Log in or Create an account to join the conversation.

  • Posts: 81361
  • Thank you received: 13037
  • MODERATOR
1 year 7 months ago #343850

Hi,

Yes. We can discuss the details in private. Please go through our contact form and provide more information on what you're thinking about (paid or free, GPL or not, self hosted or hosted by us, etc ) :
www.hikashop.com/support/contact-us.html

Please Log in or Create an account to join the conversation.

Time to create page: 0.082 seconds
Powered by Kunena Forum