[Skip to main content](#vessel-content)

#   Developing a plugin

##

- **[alex01](/forum/user/31427-alex01 "View alex01's Profile")**
- [![alex01's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/31427-alex01 "View alex01's Profile") Topic Author
- [ Offline](/forum/user/31427-alex01)

Less More

- Posts: 4
- Thank you received: 0
-
-

12 years 7 months ago [\#149917](#149917) by [alex01](/forum/user/31427-alex01 "View alex01's Profile")  *[Developing a plugin](/forum/31-development/866983-developing-a-plugin#149917 "Hi I am using Akeeba Subscriptions in conjunction with Hikashop to track how many free purchases (they will be downloads) a user can have per their subscription. I want to write a plugin which: -When installed adds a field to the hikashop user table named 'download&#95;count' or something along those lines. Default value is 0. -When a user has purchased a subscription through Akeeba subs (I believe there is even a way to make this purchase through hikashop, which may make it easier?) add a value to the new field which allows them to have x amount of free downloads. -When a user uses a free purchase (which will be a downloadable audio file) I want to decrement the number in my custom field. Once it reaches 0 the user cannot make any more free purchases until their new subscription.  Is this a feasible idea? I have done some practice plugin development from a book but this is my first real undertaking in developing an actual plugin, and I know there are probably some standards I need to follow within Hikashop.  I was reading the API and was going to call the function onBeforeDownloadFile(&amp;$filename,&amp;$do,&amp;$file) when a user goes to download a file and say decrement by 1. From my knowledge, to download a file from Hikashop an email gets sent to a user with a link to download a file, so will this function get called when they click that link?  NOTE: The reason I am using Hikashop for this is because the website will also have pages which are 'Subscriber Only' pages and I couldn't think of a better way to integrate that + allowing users to have x amount of free downloads. I can think of ways to do it separately but the only way I could think of joining them together was the creation of a plugin.  Any help would be appreciated as I want to be armed with as much knowledge before I undertake this, as I know it's going to be a tricky task. If anyone has a better idea also I'd love to hear it!")* was created by *[alex01](/forum/user/31427-alex01 "View alex01's Profile")*

Hi I am using Akeeba Subscriptions in conjunction with Hikashop to track how many free purchases (they will be downloads) a user can have per their subscription.
I want to write a plugin which:
-When installed adds a field to the hikashop user table named 'download_count' or something along those lines. Default value is 0.
-When a user has purchased a subscription through Akeeba subs (I believe there is even a way to make this purchase through hikashop, which may make it easier?) add a value to the new field which allows them to have x amount of free downloads.
-When a user uses a free purchase (which will be a downloadable audio file) I want to decrement the number in my custom field. Once it reaches 0 the user cannot make any more free purchases until their new subscription.

Is this a feasible idea? I have done some practice plugin development from a book but this is my first real undertaking in developing an actual plugin, and I know there are probably some standards I need to follow within Hikashop.

I was reading the API and was going to call the function onBeforeDownloadFile(&amp;$filename,&amp;$do,&amp;$file) when a user goes to download a file and say decrement by 1.
From my knowledge, to download a file from Hikashop an email gets sent to a user with a link to download a file, so will this function get called when they click that link?

NOTE: The reason I am using Hikashop for this is because the website will also have pages which are 'Subscriber Only' pages and I couldn't think of a better way to integrate that + allowing users to have x amount of free downloads. I can think of ways to do it separately but the only way I could think of joining them together was the creation of a plugin.

Any help would be appreciated as I want to be armed with as much knowledge before I undertake this, as I know it's going to be a tricky task. If anyone has a better idea also I'd love to hear it!

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg2Njk4My1kZXZlbG9waW5nLWEtcGx1Z2luP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Xavier](/forum/user/4105-xavier "View Xavier's Profile")**
- [![Xavier's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4105.png)](/forum/user/4105-xavier "View Xavier's Profile")
- [ Offline](/forum/user/4105-xavier)

Less More

- Posts: 13201
- Thank you received: 2322
-
-
-
- [](http://www.kidiweb.fr)
-

12 years 7 months ago [\#149957](#149957) by [Xavier](/forum/user/4105-xavier "View Xavier's Profile")  Replied by *[Xavier](/forum/user/4105-xavier "View Xavier's Profile")* on topic *[Developing a plugin](/forum/31-development/866983-developing-a-plugin#149957 "Hi I am using Akeeba Subscriptions in conjunction with Hikashop to track how many free purchases (they will be downloads) a user can have per their subscription. I want to write a plugin which: -When installed adds a field to the hikashop user table named 'download&#95;count' or something along those lines. Default value is 0. -When a user has purchased a subscription through Akeeba subs (I believe there is even a way to make this purchase through hikashop, which may make it easier?) add a value to the new field which allows them to have x amount of free downloads. -When a user uses a free purchase (which will be a downloadable audio file) I want to decrement the number in my custom field. Once it reaches 0 the user cannot make any more free purchases until their new subscription.  Is this a feasible idea? I have done some practice plugin development from a book but this is my first real undertaking in developing an actual plugin, and I know there are probably some standards I need to follow within Hikashop.  I was reading the API and was going to call the function onBeforeDownloadFile(&amp;$filename,&amp;$do,&amp;$file) when a user goes to download a file and say decrement by 1. From my knowledge, to download a file from Hikashop an email gets sent to a user with a link to download a file, so will this function get called when they click that link?  NOTE: The reason I am using Hikashop for this is because the website will also have pages which are 'Subscriber Only' pages and I couldn't think of a better way to integrate that + allowing users to have x amount of free downloads. I can think of ways to do it separately but the only way I could think of joining them together was the creation of a plugin.  Any help would be appreciated as I want to be armed with as much knowledge before I undertake this, as I know it's going to be a tricky task. If anyone has a better idea also I'd love to hear it!")*

Hi,

Everything is possible, it require just more or less development ![;)](/media/kunena/emoticons/11.png ";)")

It seems to be a feasible idea, the trigger is called even if the customer click on the email link.
To buy a subscription, you can use the Akeebasub plugin in order to buy through HikaShop and add the subscription in Akeeba subscription component.
[ www.hikashop.com/support/support/documen...a-subscriptions.html](http://www.hikashop.com/support/support/documentation/109-akeeba-subscriptions.html)

In the plugin add a onAfterOrderConfrim() function to check if the subscription has been paid and is valid, if yes, add "credit" to the customer in the download_count column via a MySQL request.

Then in the function onBeforeDownloadFile() get the user id, and decrement in the table via a MySQL request too.

Regarding the 'Subscriber Only' pages you can set a user group after purchase in the subscription product edition page.
By this way the customer will be moved to another Joomla Group and will be able to see the content of the restricted area.
You will have to add another functionality in the plugin to remove the group when the subscription is not more valid.

Hope this will help you.

The following user(s) said Thank You: [alex01](/forum/user/31427-alex01 "View alex01's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg2Njk4My1kZXZlbG9waW5nLWEtcGx1Z2luP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[alex01](/forum/user/31427-alex01 "View alex01's Profile")**
- [![alex01's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/31427-alex01 "View alex01's Profile") Topic Author
- [ Offline](/forum/user/31427-alex01)

Less More

- Posts: 4
- Thank you received: 0
-
-

12 years 6 months ago [\#150051](#150051) by [alex01](/forum/user/31427-alex01 "View alex01's Profile")  Replied by *[alex01](/forum/user/31427-alex01 "View alex01's Profile")* on topic *[Developing a plugin](/forum/31-development/866983-developing-a-plugin#150051 "Hi I am using Akeeba Subscriptions in conjunction with Hikashop to track how many free purchases (they will be downloads) a user can have per their subscription. I want to write a plugin which: -When installed adds a field to the hikashop user table named 'download&#95;count' or something along those lines. Default value is 0. -When a user has purchased a subscription through Akeeba subs (I believe there is even a way to make this purchase through hikashop, which may make it easier?) add a value to the new field which allows them to have x amount of free downloads. -When a user uses a free purchase (which will be a downloadable audio file) I want to decrement the number in my custom field. Once it reaches 0 the user cannot make any more free purchases until their new subscription.  Is this a feasible idea? I have done some practice plugin development from a book but this is my first real undertaking in developing an actual plugin, and I know there are probably some standards I need to follow within Hikashop.  I was reading the API and was going to call the function onBeforeDownloadFile(&amp;$filename,&amp;$do,&amp;$file) when a user goes to download a file and say decrement by 1. From my knowledge, to download a file from Hikashop an email gets sent to a user with a link to download a file, so will this function get called when they click that link?  NOTE: The reason I am using Hikashop for this is because the website will also have pages which are 'Subscriber Only' pages and I couldn't think of a better way to integrate that + allowing users to have x amount of free downloads. I can think of ways to do it separately but the only way I could think of joining them together was the creation of a plugin.  Any help would be appreciated as I want to be armed with as much knowledge before I undertake this, as I know it's going to be a tricky task. If anyone has a better idea also I'd love to hear it!")*

Thank you so much for your explanation and assistance Xavier. I will be working on that today and try to get it working!

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg2Njk4My1kZXZlbG9waW5nLWEtcGx1Z2luP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[alex01](/forum/user/31427-alex01 "View alex01's Profile")**
- [![alex01's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/31427-alex01 "View alex01's Profile") Topic Author
- [ Offline](/forum/user/31427-alex01)

Less More

- Posts: 4
- Thank you received: 0
-
-

12 years 6 months ago -  12 years 6 months ago [\#150057](#150057) by [alex01](/forum/user/31427-alex01 "View alex01's Profile")  Replied by *[alex01](/forum/user/31427-alex01 "View alex01's Profile")* on topic *[Developing a plugin](/forum/31-development/866983-developing-a-plugin#150057 "Hi I am using Akeeba Subscriptions in conjunction with Hikashop to track how many free purchases (they will be downloads) a user can have per their subscription. I want to write a plugin which: -When installed adds a field to the hikashop user table named 'download&#95;count' or something along those lines. Default value is 0. -When a user has purchased a subscription through Akeeba subs (I believe there is even a way to make this purchase through hikashop, which may make it easier?) add a value to the new field which allows them to have x amount of free downloads. -When a user uses a free purchase (which will be a downloadable audio file) I want to decrement the number in my custom field. Once it reaches 0 the user cannot make any more free purchases until their new subscription.  Is this a feasible idea? I have done some practice plugin development from a book but this is my first real undertaking in developing an actual plugin, and I know there are probably some standards I need to follow within Hikashop.  I was reading the API and was going to call the function onBeforeDownloadFile(&amp;$filename,&amp;$do,&amp;$file) when a user goes to download a file and say decrement by 1. From my knowledge, to download a file from Hikashop an email gets sent to a user with a link to download a file, so will this function get called when they click that link?  NOTE: The reason I am using Hikashop for this is because the website will also have pages which are 'Subscriber Only' pages and I couldn't think of a better way to integrate that + allowing users to have x amount of free downloads. I can think of ways to do it separately but the only way I could think of joining them together was the creation of a plugin.  Any help would be appreciated as I want to be armed with as much knowledge before I undertake this, as I know it's going to be a tricky task. If anyone has a better idea also I'd love to hear it!")*

I've been having a look around and would I have to use the onAfterOrderUpdate function rather than the onAfterOrderConfirm, as I'd want to make sure a user has paid before giving them any credit.

Also when checking, how would I go about determining whether the order purchased has the Akeeba Subscription in it? I'm trying to figure out how to say
- if the order has been paid for AND there is an Akeeba Subscription within the order, add credits to the database.

Last edit: 12 years 6 months ago by [alex01](/forum/user/31427-alex01 "View alex01's Profile"). Reason: Ased another question

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg2Njk4My1kZXZlbG9waW5nLWEtcGx1Z2luP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86292
- Thank you received: 14271
-
-

12 years 6 months ago [\#150113](#150113) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Developing a plugin](/forum/31-development/866983-developing-a-plugin#150113 "Hi I am using Akeeba Subscriptions in conjunction with Hikashop to track how many free purchases (they will be downloads) a user can have per their subscription. I want to write a plugin which: -When installed adds a field to the hikashop user table named 'download&#95;count' or something along those lines. Default value is 0. -When a user has purchased a subscription through Akeeba subs (I believe there is even a way to make this purchase through hikashop, which may make it easier?) add a value to the new field which allows them to have x amount of free downloads. -When a user uses a free purchase (which will be a downloadable audio file) I want to decrement the number in my custom field. Once it reaches 0 the user cannot make any more free purchases until their new subscription.  Is this a feasible idea? I have done some practice plugin development from a book but this is my first real undertaking in developing an actual plugin, and I know there are probably some standards I need to follow within Hikashop.  I was reading the API and was going to call the function onBeforeDownloadFile(&amp;$filename,&amp;$do,&amp;$file) when a user goes to download a file and say decrement by 1. From my knowledge, to download a file from Hikashop an email gets sent to a user with a link to download a file, so will this function get called when they click that link?  NOTE: The reason I am using Hikashop for this is because the website will also have pages which are 'Subscriber Only' pages and I couldn't think of a better way to integrate that + allowing users to have x amount of free downloads. I can think of ways to do it separately but the only way I could think of joining them together was the creation of a plugin.  Any help would be appreciated as I want to be armed with as much knowledge before I undertake this, as I know it's going to be a tricky task. If anyone has a better idea also I'd love to hear it!")*

You'll have to load the products data from the order with a SQL query and check whether the products have a product_subscription_id set in them or not.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg2Njk4My1kZXZlbG9waW5nLWEtcGx1Z2luP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop- Install &amp; Update- Product &amp; Category Display- Content Creation- Sales and Orders- - Orders management- - Reports &amp; Statistics- Customers- Checkout- Payment Methods- Shipping Methods- Import &amp; Export (CSV, XLS…)- Specific Features- - Affilation- - Taxes- - Wishlist- - Vote- - Carousel &amp; Slider- - Mass Actions- - Filters &amp; Search- - Discount &amp; Coupon- - Feature Request- Integrations- Showcase- General Talk about HikaShop- Development- - HikaShop 3.0 Beta- Translation- Commercial Jobs HikaShop Components- HikaMarket- - Market: Feature requests- - Market: How to?- - Market: Bug Report- HikaSerial- - General talk about HikaSerial- - Serial: Bug Report- - Serial: How to?- - Support en Français de HikaSerial (French Support)- - HikaSubscription- HikaAuction- - Auction: Feature requests- - Auction: How to?- - Auction: Bug report Hikashop around the world- Support en Français (French Support)- Russian- - FAQ. Курс выживания с Hikashop. Частые вопросы и о- - Расширения Hikashop- - Наши сайты на Hikashop- 日本語版サポート(Japanese Support)- Thai- German Archives- Bug Report- How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.207 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)

[](#top)
