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

#   Generate Serial based on account email address

##

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

Less More

- Posts: 6
- Thank you received: 0
-
-

14 years 5 months ago [\#50349](#50349) by [cwm33](/forum/user/7460-cwm33 "View cwm33's Profile")  *[Generate Serial based on account email address](/forum/17-serial-how-to/50349-generate-serial-based-on-account-email-address#50349 "I'm trying to use hikaserial to generate a serial number for a software license that will be based off of a bit of PHP code that I have for generating the serial numbers. I've looked over the...")* was created by *[cwm33](/forum/user/7460-cwm33 "View cwm33's Profile")*

I'm trying to use hikaserial to generate a serial number for a software license that will be based off of a bit of PHP code that I have for generating the serial numbers. I've looked over the documentation and I'm at a bit of a loss on how to use generated serials on products. I created a Pack that uses Random - HikaSerial Generator plugin for the generator just as a test case, assigned that pack to my product, "purchased" the product via paypal sandbox and it didn't generate a serial number and assign it to the order. It doesn't look like it generated a serial period. Am I missing a configuration step for using the random serial feature?

I would also like a bit of a push in the right direction for where to look to generate the serial number appropriate to my location. I THINK I found the right spot in the randomgen.php file, but I've never dabbled in Joomla Plugin writing before (plus I'm a C# programmer, haven't looked at PHP in probably a year). So any help with that would be greatly appreciated, as this is one of the final things I need to get working before I can launch my product. ![:)](/media/kunena/emoticons/3.png ":)")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE3LXNlcmlhbC1ob3ctdG8vNTAzNDktZ2VuZXJhdGUtc2VyaWFsLWJhc2VkLW9uLWFjY291bnQtZW1haWwtYWRkcmVzcz90bXBsPW1hcmtkb3du) 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)
-

14 years 5 months ago [\#50350](#50350) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Re: Generate Serial based on account email address](/forum/17-serial-how-to/50349-generate-serial-based-on-account-email-address#50350 "I'm trying to use hikaserial to generate a serial number for a software license that will be based off of a bit of PHP code that I have for generating the serial numbers. I've looked over the...")*

Hi,

The most important function in a generator plugin is the "generate" one. Code:

/** * @param object $pack * @param object $order * @param int $quantity * @param array $serials */ public function generate(&amp;$pack, &amp;$order, $quantity, &amp;$serials) { if(!isset($pack-&gt;randomgen)) // replace "randomgen" by your plugin name return; // load $this-&gt;plugin_params; parent::pluginParams($pack-&gt;randomgen); // replace "randomgen" by your plugin name for($q = 0; $q &lt; $quantity; $q++) { $serial = ''; // Generate your serial here $serials[] = $serial; } }

When the "generate" function is called, a variable with the name of the plugin (randomgen in my example) is set.
This variable contains the id of the plugin generator.

Thanks to "$order" you can retrieve a lot of information about the current order or the user account.
The "$serial" variable is for output. It is an array which would contains all generated serials.

About HikaSerial configuration, you have to set up all HikaShop order statuses which allow to attach a serial to the order (and to the user).
When an order is validated by PayPal, the order would have another status (generally "confirmed") and HikaSerial would retrieve a serial from the pack.
If the pack is empty, HikaSerial would call the associated generator to create new serials. It is at this moment that the "generate" function is called.
In the pack configuration, you have to select your plugin generator and save. The associated generator is display in the listing so you can easily check if the configuration is right.

Hope it help you !

Regards,

---

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

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

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

Less More

- Posts: 6
- Thank you received: 0
-
-

14 years 5 months ago -  14 years 5 months ago [\#50351](#50351) by [cwm33](/forum/user/7460-cwm33 "View cwm33's Profile")  Replied by *[cwm33](/forum/user/7460-cwm33 "View cwm33's Profile")* on topic *[Re: Generate Serial based on account email address](/forum/17-serial-how-to/50349-generate-serial-based-on-account-email-address#50351 "I'm trying to use hikaserial to generate a serial number for a software license that will be based off of a bit of PHP code that I have for generating the serial numbers. I've looked over the...")*

> Jerome wrote: About HikaSerial configuration, you have to set up all HikaShop order statuses which allow to attach a serial to the order (and to the user).
> When an order is validated by PayPal, the order would have another status (generally "confirmed") and HikaSerial would retrieve a serial from the pack.
> If the pack is empty, HikaSerial would call the associated generator to create new serials. It is at this moment that the "generate" function is called.
> In the pack configuration, you have to select your plugin generator and save. The associated generator is display in the listing so you can easily check if the configuration is right.
>
> Hope it help you !
>
> Regards,

That's the exact spot I was looking at for putting in my own serial number generation code, the existing serial number generating code just kinda threw me off a bit as it looked rather strange. :blink:
I'm having a hard time accessing the user email out of the $order variable though, I've tried doing a var_dump and it gave me NULL NULL NULL NULL NULL instead of something useful. ![:(](/media/kunena/emoticons/22.png ":(")
I also did some poking around through code, and arrived at trying out $order-&gt;customer-&gt;user_email; but that didn't give me anything either. :S

I've managed to get it to assign a random serial from the 'pack' so far, but the serial only shows up after I go into the order and hit "Refresh Associations". I have "Assignable Order Statuses" set to confirmed, shipped in the HikaSerial configuration.

[ ![hikaserial-config.jpg](/forum/attachment/3864) ](/forum/attachment/3864 "...ial-config.jpg")

Am I missing something in the HikaShop configuration so that the serial generation code gets called when the payment is confirmed? or could this be related to me still using the PayPal sandbox environment?

- [ ![hikaserial-config.jpg](/forum/attachment/3864) ](/forum/attachment/3864 "...ial-config.jpg") [ ](/forum/attachment/3864?download=1 "...ial-config.jpg")

Last edit: 14 years 5 months ago by [cwm33](/forum/user/7460-cwm33 "View cwm33's Profile"). Reason: more details

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE3LXNlcmlhbC1ob3ctdG8vNTAzNDktZ2VuZXJhdGUtc2VyaWFsLWJhc2VkLW9uLWFjY291bnQtZW1haWwtYWRkcmVzcz90bXBsPW1hcmtkb3du) 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)
-

14 years 5 months ago [\#50401](#50401) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Re: Generate Serial based on account email address](/forum/17-serial-how-to/50349-generate-serial-based-on-account-email-address#50401 "I'm trying to use hikaserial to generate a serial number for a software license that will be based off of a bit of PHP code that I have for generating the serial numbers. I've looked over the...")*

Hi,

When an HikaShop order is updated (when the PayPal notification validate the order for example), HikaSerial is called.
But when a plugin update an order, it does not update every fields of the order so HikaSerial load the full order information and store them into " $order-&gt;cart ".

So you should access to the information by this variables.
$order-&gt;cart-&gt;order_user_id
$order-&gt;cart-&gt;products

I will investigate more about your assignation problem.
An access to your backend might be required (or I can send you a preview version of HikaSerial with some modifications).

Regards,

---

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

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

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE3LXNlcmlhbC1ob3ctdG8vNTAzNDktZ2VuZXJhdGUtc2VyaWFsLWJhc2VkLW9uLWFjY291bnQtZW1haWwtYWRkcmVzcz90bXBsPW1hcmtkb3du) 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)
-

14 years 5 months ago [\#50411](#50411) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Re: Generate Serial based on account email address](/forum/17-serial-how-to/50349-generate-serial-based-on-account-email-address#50411 "I'm trying to use hikaserial to generate a serial number for a software license that will be based off of a bit of PHP code that I have for generating the serial numbers. I've looked over the...")*

Hi,

file: administrator/com_hikaserial/classes/order.php
line: 31-34

Replace: Code:

if(!isset($p-&gt;order_product_id)) { $orderClass = hikaserial::get('shop.class.order'); $order-&gt;cart = $orderClass-&gt;loadFullOrder($order-&gt;order_id); }

By: Code:

if(!isset($p-&gt;order_product_id)) { $orderClass = hikaserial::get('shop.class.order'); $order-&gt;cart = $orderClass-&gt;loadFullOrder($order-&gt;order_id, false, false); }

And it would fix the problem with payment notifications.
I will update the HikaSerial package right now, so you would be able to download HikaSerial 1.1.0 with the fix in several minutes.

Regards,

---

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

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

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

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

Less More

- Posts: 6
- Thank you received: 0
-
-

14 years 5 months ago [\#50428](#50428) by [cwm33](/forum/user/7460-cwm33 "View cwm33's Profile")  Replied by *[cwm33](/forum/user/7460-cwm33 "View cwm33's Profile")* on topic *[Re: Generate Serial based on account email address](/forum/17-serial-how-to/50349-generate-serial-based-on-account-email-address#50428 "I'm trying to use hikaserial to generate a serial number for a software license that will be based off of a bit of PHP code that I have for generating the serial numbers. I've looked over the...")*

Well how about that, I actually found a bug. Here and I thought I was just being a moron, now I don't feel so bad for not being able to figure it out! ![:D](/media/kunena/emoticons/1.png ":D")

I'm heading to work soon, and will try out that fix and let you know how it works. Thanks for your help!

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

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

Less More

- Posts: 6
- Thank you received: 0
-
-

14 years 5 months ago [\#50457](#50457) by [cwm33](/forum/user/7460-cwm33 "View cwm33's Profile")  Replied by *[cwm33](/forum/user/7460-cwm33 "View cwm33's Profile")* on topic *[Re: Generate Serial based on account email address](/forum/17-serial-how-to/50349-generate-serial-based-on-account-email-address#50457 "I'm trying to use hikaserial to generate a serial number for a software license that will be based off of a bit of PHP code that I have for generating the serial numbers. I've looked over the...")*

Just wanted to post back and say that I got everything working. Now I should probably take my serial generation code and put it into my own plugin instead of hacking up the randomgen one. ![:D](/media/kunena/emoticons/1.png ":D")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE3LXNlcmlhbC1ob3ctdG8vNTAzNDktZ2VuZXJhdGUtc2VyaWFsLWJhc2VkLW9uLWFjY291bnQtZW1haWwtYWRkcmVzcz90bXBsPW1hcmtkb3du) 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)
-

14 years 5 months ago [\#50460](#50460) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Re: Generate Serial based on account email address](/forum/17-serial-how-to/50349-generate-serial-based-on-account-email-address#50460 "I'm trying to use hikaserial to generate a serial number for a software license that will be based off of a bit of PHP code that I have for generating the serial numbers. I've looked over the...")*

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

Randomgen plugin has been integrated in HikaSerial to be used as example.
If you want to create a new plugin, you just have to rename files, rename the class (and two or three variables/const values) and modify the XML.
Code:

&lt;name&gt;Random - HikaSerial Generator plugin&lt;/name&gt; &lt;files&gt; &lt;filename plugin="randomgen"&gt;randomgen.php&lt;/filename&gt; &lt;filename&gt;randomgen_configuration.php&lt;/filename&gt; &lt;/files&gt;

randomgen is used for filenames and in the first file to indicate which is the plugin main file (and the internal name of the plugin).

Class names in HikaShop and HikaSerial have some rules : plgHikaserialRandomgen
**plg** : a plugin class
**Hikaserial** : for HikaSerial (upercase for the first letter, lowercase otherwise)
**Randomgen** : name of the plugin (upercase for the first letter, lowercase otherwise)

Regards,

---

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

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

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

Less More

- Posts: 83
- Thank you received: 1
-
-
-

14 years 4 weeks ago [\#68869](#68869) by [manjeshmohan](/forum/user/9480-manjeshmohan "View manjeshmohan's Profile")  Replied by *[manjeshmohan](/forum/user/9480-manjeshmohan "View manjeshmohan's Profile")* on topic *[Re: Generate Serial based on account email address](/forum/17-serial-how-to/50349-generate-serial-based-on-account-email-address#68869 "I'm trying to use hikaserial to generate a serial number for a software license that will be based off of a bit of PHP code that I have for generating the serial numbers. I've looked over the...")*

Have you created a plugin of your own? If yes, could you guide me how to create one?

Thanks.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE3LXNlcmlhbC1ob3ctdG8vNTAzNDktZ2VuZXJhdGUtc2VyaWFsLWJhc2VkLW9uLWFjY291bnQtZW1haWwtYWRkcmVzcz90bXBsPW1hcmtkb3du) 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.085 seconds

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