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

#   Create a persistent counter

##

- **[btbjosh](/forum/user/12727-btbjosh "View btbjosh's Profile")**
- [![btbjosh's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/gallery/splatter_hand.png)](/forum/user/12727-btbjosh "View btbjosh's Profile") Topic Author
- [ Offline](/forum/user/12727-btbjosh)

Less More

- Posts: 90
- Thank you received: 1
-
-
-

13 years 7 months ago [\#94134](#94134) by [btbjosh](/forum/user/12727-btbjosh "View btbjosh's Profile")  *[Create a persistent counter](/forum/17-serial-how-to/79218-create-a-persistent-counter#94134 "I need to generate my serial based off of a persistent counter that I use in the algorithm. Can I use a custom field in Hikashop to keep track of this number?")* was created by *[btbjosh](/forum/user/12727-btbjosh "View btbjosh's Profile")*

I need to generate my serial based off of a persistent counter that I use in the algorithm. Can I use a custom field in Hikashop to keep track of this number?

---

![:)](/media/kunena/emoticons/3.png ":)") — Josh

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE3LXNlcmlhbC1ob3ctdG8vNzkyMTgtY3JlYXRlLWEtcGVyc2lzdGVudC1jb3VudGVyP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26394
- Thank you received: 4078
-
- [](http://obsi.dev)
-

13 years 7 months ago [\#94135](#94135) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Create a persistent counter](/forum/17-serial-how-to/79218-create-a-persistent-counter#94135 "I need to generate my serial based off of a persistent counter that I use in the algorithm. Can I use a custom field in Hikashop to keep track of this number?")*

Hi,

The "series" generator is like a counter increment generator.
It uses the other serials in order to get the current counter value (the highest value for the current pack).

You can access to all product fields in the "generate" function, so you can read a custom field of a product.
But you would have to edit the value of the product custom field with a SQL query afterwards.

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE3LXNlcmlhbC1ob3ctdG8vNzkyMTgtY3JlYXRlLWEtcGVyc2lzdGVudC1jb3VudGVyP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

- **[btbjosh](/forum/user/12727-btbjosh "View btbjosh's Profile")**
- [![btbjosh's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/gallery/splatter_hand.png)](/forum/user/12727-btbjosh "View btbjosh's Profile") Topic Author
- [ Offline](/forum/user/12727-btbjosh)

Less More

- Posts: 90
- Thank you received: 1
-
-
-

13 years 7 months ago [\#94137](#94137) by [btbjosh](/forum/user/12727-btbjosh "View btbjosh's Profile")  Replied by *[btbjosh](/forum/user/12727-btbjosh "View btbjosh's Profile")* on topic *[Create a persistent counter](/forum/17-serial-how-to/79218-create-a-persistent-counter#94137 "I need to generate my serial based off of a persistent counter that I use in the algorithm. Can I use a custom field in Hikashop to keep track of this number?")*

No, I'm sorry. I need to create my own plugin.

I have an algorithm I must use as it is for our software licensing. We already use it in our contact management system. I need to adapt it to our store. This is quite an undertaking, but I need to start at square one. And that is getting a persistent counter to increment for use in my generator. I don't really want a series license. Now if I can use the series generator to keep track of my number for me then I would be all ears on how to access that value from another generator. Or if there's another way to handle it, I'd love to hear about it.

Any ideas?

---

![:)](/media/kunena/emoticons/3.png ":)") — Josh

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE3LXNlcmlhbC1ob3ctdG8vNzkyMTgtY3JlYXRlLWEtcGVyc2lzdGVudC1jb3VudGVyP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26394
- Thank you received: 4078
-
- [](http://obsi.dev)
-

13 years 7 months ago [\#94138](#94138) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Create a persistent counter](/forum/17-serial-how-to/79218-create-a-persistent-counter#94138 "I need to generate my serial based off of a persistent counter that I use in the algorithm. Can I use a custom field in Hikashop to keep track of this number?")*

Hi

You can use the config Code:

$config = hikaserial::config(); $currentValue = (int)$config-&gt;get('software_generator_counter', 0); $currentValue++; // Your algorithm $config-&gt;save(array( 'software_generator_counter' =&gt; $currentValue ));

Or the product Code:

public function generate(&amp;$pack, &amp;$order, $quantity, &amp;$serials) { // load $this-&gt;plugin_params; parent::pluginParams(0, 'mygeneratorplugin'); // Get the product object $productClass = hikaserial::get('shop.class.product'); $product = $productClass-&gt;get($pack-&gt;product_id); if(empty($product)) return; // Increment " $product-&gt;software_counter " and then, use it in your algorithm $product-&gt;software_counter++; // Update the value in the database. $this-&gt;db-&gt;setQuery('UPDATE '.hikaserial::table('shop.product') . ' SET software_counter = ' . (int)$product-&gt;software_counter . ' WHERE product_id = ' . (int)$pack-&gt;product_id); $this-&gt;db-&gt;query();

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE3LXNlcmlhbC1ob3ctdG8vNzkyMTgtY3JlYXRlLWEtcGVyc2lzdGVudC1jb3VudGVyP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

- **[btbjosh](/forum/user/12727-btbjosh "View btbjosh's Profile")**
- [![btbjosh's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/gallery/splatter_hand.png)](/forum/user/12727-btbjosh "View btbjosh's Profile") Topic Author
- [ Offline](/forum/user/12727-btbjosh)

Less More

- Posts: 90
- Thank you received: 1
-
-
-

13 years 7 months ago [\#94144](#94144) by [btbjosh](/forum/user/12727-btbjosh "View btbjosh's Profile")  Replied by *[btbjosh](/forum/user/12727-btbjosh "View btbjosh's Profile")* on topic *[Create a persistent counter](/forum/17-serial-how-to/79218-create-a-persistent-counter#94144 "I need to generate my serial based off of a persistent counter that I use in the algorithm. Can I use a custom field in Hikashop to keep track of this number?")*

I need this generated when the order is placed, based on the product, and the option chosen.

The developer documentation is not clear on how to even create my own plugin.

---

![:)](/media/kunena/emoticons/3.png ":)") — Josh

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE3LXNlcmlhbC1ob3ctdG8vNzkyMTgtY3JlYXRlLWEtcGVyc2lzdGVudC1jb3VudGVyP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26394
- Thank you received: 4078
-
- [](http://obsi.dev)
-

13 years 7 months ago [\#94167](#94167) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Create a persistent counter](/forum/17-serial-how-to/79218-create-a-persistent-counter#94167 "I need to generate my serial based off of a persistent counter that I use in the algorithm. Can I use a custom field in Hikashop to keep track of this number?")*

Hi,

The first part explain the structure of an HikaSerial plugin.
[ www.hikashop.com/en/hikashop/125-hikaser...eveloper.html#how\_to](http://www.hikashop.com/en/hikashop/125-hikaserial-developer.html#how_to)

A generator plugin uses the "generate" function like explain here:
[ www.hikashop.com/en/hikashop/125-hikaser...er.html#fct\_generate](http://www.hikashop.com/en/hikashop/125-hikaserial-developer.html#fct_generate)

You can use one of the current HikaSerial plugins, like the "randomgenerator" as an example, by copying the files (the php and the xml) in order to create your new plugin.

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE3LXNlcmlhbC1ob3ctdG8vNzkyMTgtY3JlYXRlLWEtcGVyc2lzdGVudC1jb3VudGVyP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

- **[btbjosh](/forum/user/12727-btbjosh "View btbjosh's Profile")**
- [![btbjosh's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/gallery/splatter_hand.png)](/forum/user/12727-btbjosh "View btbjosh's Profile") Topic Author
- [ Offline](/forum/user/12727-btbjosh)

Less More

- Posts: 90
- Thank you received: 1
-
-
-

13 years 7 months ago -  13 years 7 months ago [\#94169](#94169) by [btbjosh](/forum/user/12727-btbjosh "View btbjosh's Profile")  Replied by *[btbjosh](/forum/user/12727-btbjosh "View btbjosh's Profile")* on topic *[Create a persistent counter](/forum/17-serial-how-to/79218-create-a-persistent-counter#94169 "I need to generate my serial based off of a persistent counter that I use in the algorithm. Can I use a custom field in Hikashop to keep track of this number?")*

I have that much info. Thanks. But I've copied the randomgen folder and renamed the folder/ internal files to "licensegen" etc... I've uploaded it to the /plugins/hikaserial and it doesn't show as an option inside my plugins list.

Am I missing a step? This information is not presented in your documentation. How do you install your custom plugin folder?

Forgive my ignorance.

---

![:)](/media/kunena/emoticons/3.png ":)") — Josh

Last edit: 13 years 7 months ago by [btbjosh](/forum/user/12727-btbjosh "View btbjosh's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE3LXNlcmlhbC1ob3ctdG8vNzkyMTgtY3JlYXRlLWEtcGVyc2lzdGVudC1jb3VudGVyP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26394
- Thank you received: 4078
-
- [](http://obsi.dev)
-

13 years 7 months ago [\#94228](#94228) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Create a persistent counter](/forum/17-serial-how-to/79218-create-a-persistent-counter#94228 "I need to generate my serial based off of a persistent counter that I use in the algorithm. Can I use a custom field in Hikashop to keep track of this number?")*

Hi,

A plugin has to be install in Joomla. You can do it by creating a installation package (the xml+php files) or you can use the "discover" mode of Joomla.
In all cases, your XML file should be valid, with right values for your plugin.

You can read the Joomla! documentation on how creating a plugin (the plugin for Joomla 1.5 are compatible with Joomla 2.5):
[ docs.joomla.org/Creating\_a\_Plugin\_for\_Joomla\_1.5](http://docs.joomla.org/Creating_a_Plugin_for_Joomla_1.5)

The other documentation is quite complete but talk on a specific type of plugin, so the functions in the class are specific for the content plugins:
[ docs.joomla.org/Creating\_a\_content\_plugin](http://docs.joomla.org/Creating_a_content_plugin)

This last one have a XML file in the Joomla 2.5/3.0 way:
[ docs.joomla.org/Creating\_a\_profile\_plugin](http://docs.joomla.org/Creating_a_profile_plugin)

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE3LXNlcmlhbC1ob3ctdG8vNzkyMTgtY3JlYXRlLWEtcGVyc2lzdGVudC1jb3VudGVyP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

- **[btbjosh](/forum/user/12727-btbjosh "View btbjosh's Profile")**
- [![btbjosh's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/gallery/splatter_hand.png)](/forum/user/12727-btbjosh "View btbjosh's Profile") Topic Author
- [ Offline](/forum/user/12727-btbjosh)

Less More

- Posts: 90
- Thank you received: 1
-
-
-

13 years 7 months ago [\#95051](#95051) by [btbjosh](/forum/user/12727-btbjosh "View btbjosh's Profile")  Replied by *[btbjosh](/forum/user/12727-btbjosh "View btbjosh's Profile")* on topic *[Create a persistent counter](/forum/17-serial-how-to/79218-create-a-persistent-counter#95051 "I need to generate my serial based off of a persistent counter that I use in the algorithm. Can I use a custom field in Hikashop to keep track of this number?")*

Thanks. I seem to have gotten it installed properly. Now I just need to configure/code my generator logic. Here we go!

---

![:)](/media/kunena/emoticons/3.png ":)") — Josh

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE3LXNlcmlhbC1ob3ctdG8vNzkyMTgtY3JlYXRlLWEtcGVyc2lzdGVudC1jb3VudGVyP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) 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?

Moderators: [Obsidev](/forum/user/7040-obsidev "View Obsidev's Profile")

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

Time to create page: 0.285 seconds

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