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

#   Generate Serial based on Product and option

##

- **[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 [\#96368](#96368) by [btbjosh](/forum/user/12727-btbjosh "View btbjosh's Profile")  Replied by *[btbjosh](/forum/user/12727-btbjosh "View btbjosh's Profile")* on topic *[Generate Serial based on Product and option](/forum/17-serial-how-to/78873-generate-serial-based-on-product-and-option?start=20#96368 "I have yet to purchase the plugin because I need to know if this is possible.  I know you can customize the generators to some extent, but I need to know if it is possible to generate a software key based on the product they choose and an option choice.  If this is possible, could you point in the direction on how to accomplish this? I know basic/intermediate javascript but very little PHP so any assistance will be greatly appreciated.")*

Sorry if that isn't clear.

I'll explain it again.

I have a software product. It has an option (this needs to be an option because it has a cost associated with it). I have the algorithm that generates the license. The license needs to do this based off of the product code and the option selected.

I don't understand why you are suggesting custom field. That's not how my product is set up or needs to be set up for purchase.

Again, my apologies for not being clear to start.

---

![:)](/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=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE3LXNlcmlhbC1ob3ctdG8vNzg4NzMtZ2VuZXJhdGUtc2VyaWFsLWJhc2VkLW9uLXByb2R1Y3QtYW5kLW9wdGlvbj9zdGFydD0yMCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) 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 [\#96381](#96381) by [btbjosh](/forum/user/12727-btbjosh "View btbjosh's Profile")  Replied by *[btbjosh](/forum/user/12727-btbjosh "View btbjosh's Profile")* on topic *[Generate Serial based on Product and option](/forum/17-serial-how-to/78873-generate-serial-based-on-product-and-option?start=20#96381 "I have yet to purchase the plugin because I need to know if this is possible.  I know you can customize the generators to some extent, but I need to know if it is possible to generate a software key based on the product they choose and an option choice.  If this is possible, could you point in the direction on how to accomplish this? I know basic/intermediate javascript but very little PHP so any assistance will be greatly appreciated.")*

I'm not sure why this code isn't working. Please forgive me, I'm a PHP noob.
Code:

if(!empty($order-&gt;cart-&gt;products)) { foreach($order-&gt;cart-&gt;products as $p) { if($p-&gt;product_id == $pack-&gt;product_id) { // Read the product code $product_code = $p-&gt;order_product_code; $parent_item_id = $p-&gt;order_product_id; break; } } foreach($order-&gt;cart-&gt;products as $o) { if($o-&gt;order_product_option_parent_id == $parent_item_id) { //Get the option purchased $software_option = $o-&gt;order_product_code; break; } } }

EDIT:
AHA! not sure what I was doing wrong, but it seems to work now. Is there any problem doing things this way?

---

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

Last edit: 13 years 7 months ago by [Jerome](/forum/user/80-jerome "View Jerome's Profile"). Reason: little modification

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE3LXNlcmlhbC1ob3ctdG8vNzg4NzMtZ2VuZXJhdGUtc2VyaWFsLWJhc2VkLW9uLXByb2R1Y3QtYW5kLW9wdGlvbj9zdGFydD0yMCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) 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: 26395
- Thank you received: 4077
-
- [](http://obsi.dev)
-

13 years 7 months ago [\#96384](#96384) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Generate Serial based on Product and option](/forum/17-serial-how-to/78873-generate-serial-based-on-product-and-option?start=20#96384 "I have yet to purchase the plugin because I need to know if this is possible.  I know you can customize the generators to some extent, but I need to know if it is possible to generate a software key based on the product they choose and an option choice.  If this is possible, could you point in the direction on how to accomplish this? I know basic/intermediate javascript but very little PHP so any assistance will be greatly appreciated.")*

Hi,

I didn't modify something "important" in your code, just a fix for the variable "$parent_item_id" for more "security".
The way to retrieve the product option is the right one.

First you look at your targeted product and after that, you look at the option of your targeted product.
It's perfect ![:)](/media/kunena/emoticons/3.png ":)")

Regards,

---

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

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

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE3LXNlcmlhbC1ob3ctdG8vNzg4NzMtZ2VuZXJhdGUtc2VyaWFsLWJhc2VkLW9uLXByb2R1Y3QtYW5kLW9wdGlvbj9zdGFydD0yMCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) 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 [\#96385](#96385) by [btbjosh](/forum/user/12727-btbjosh "View btbjosh's Profile")  Replied by *[btbjosh](/forum/user/12727-btbjosh "View btbjosh's Profile")* on topic *[Generate Serial based on Product and option](/forum/17-serial-how-to/78873-generate-serial-based-on-product-and-option?start=20#96385 "I have yet to purchase the plugin because I need to know if this is possible.  I know you can customize the generators to some extent, but I need to know if it is possible to generate a software key based on the product they choose and an option choice.  If this is possible, could you point in the direction on how to accomplish this? I know basic/intermediate javascript but very little PHP so any assistance will be greatly appreciated.")*

Ah, I see your change. Thanks.

I'll get this plugged in with my algorithm and see how things go now! Should be down hill from here.

---

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

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE3LXNlcmlhbC1ob3ctdG8vNzg4NzMtZ2VuZXJhdGUtc2VyaWFsLWJhc2VkLW9uLXByb2R1Y3QtYW5kLW9wdGlvbj9zdGFydD0yMCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) 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 [\#96397](#96397) by [btbjosh](/forum/user/12727-btbjosh "View btbjosh's Profile")  Replied by *[btbjosh](/forum/user/12727-btbjosh "View btbjosh's Profile")* on topic *[Generate Serial based on Product and option](/forum/17-serial-how-to/78873-generate-serial-based-on-product-and-option?start=20#96397 "I have yet to purchase the plugin because I need to know if this is possible.  I know you can customize the generators to some extent, but I need to know if it is possible to generate a software key based on the product they choose and an option choice.  If this is possible, could you point in the direction on how to accomplish this? I know basic/intermediate javascript but very little PHP so any assistance will be greatly appreciated.")*

Looks like everything is working for this software product and it's option, I'm not getting the right license generated for each.

Thanks for putting up with me!

One final question and I think it will wrap this up:

If I have a second option that is an add-on product that requires its own serial to be generated, do I just make a new pack and separate generator for that "product" (which is an option on this same product that gets my current license I just set up)...

Or is it better to just make it a separate product and have its own generator that way... Or is there any difference from the license generation standpoint?

---

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

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE3LXNlcmlhbC1ob3ctdG8vNzg4NzMtZ2VuZXJhdGUtc2VyaWFsLWJhc2VkLW9uLXByb2R1Y3QtYW5kLW9wdGlvbj9zdGFydD0yMCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) 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: 26395
- Thank you received: 4077
-
- [](http://obsi.dev)
-

13 years 7 months ago [\#96420](#96420) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Generate Serial based on Product and option](/forum/17-serial-how-to/78873-generate-serial-based-on-product-and-option?start=20#96420 "I have yet to purchase the plugin because I need to know if this is possible.  I know you can customize the generators to some extent, but I need to know if it is possible to generate a software key based on the product they choose and an option choice.  If this is possible, could you point in the direction on how to accomplish this? I know basic/intermediate javascript but very little PHP so any assistance will be greatly appreciated.")*

Hi,

The best solution would be the one which would be easier for you to use and to manage.

You can create different packs for your products so your serials would be separate in two different "groups", easier to have some statistics.
But if you don't want to use the HikaSerial backend for the statistics, I guess that having two different packs would not be very useful.

Regards,

---

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

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE3LXNlcmlhbC1ob3ctdG8vNzg4NzMtZ2VuZXJhdGUtc2VyaWFsLWJhc2VkLW9uLXByb2R1Y3QtYW5kLW9wdGlvbj9zdGFydD0yMCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) 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 [\#96684](#96684) by [btbjosh](/forum/user/12727-btbjosh "View btbjosh's Profile")  Replied by *[btbjosh](/forum/user/12727-btbjosh "View btbjosh's Profile")* on topic *[Generate Serial based on Product and option](/forum/17-serial-how-to/78873-generate-serial-based-on-product-and-option?start=20#96684 "I have yet to purchase the plugin because I need to know if this is possible.  I know you can customize the generators to some extent, but I need to know if it is possible to generate a software key based on the product they choose and an option choice.  If this is possible, could you point in the direction on how to accomplish this? I know basic/intermediate javascript but very little PHP so any assistance will be greatly appreciated.")*

So are you saying I can just create another pack and use the same generator and just tie that pack gen to the "option product?" That will create a separate Serial for it?

---

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

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE3LXNlcmlhbC1ob3ctdG8vNzg4NzMtZ2VuZXJhdGUtc2VyaWFsLWJhc2VkLW9uLXByb2R1Y3QtYW5kLW9wdGlvbj9zdGFydD0yMCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) 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: 26395
- Thank you received: 4077
-
- [](http://obsi.dev)
-

13 years 7 months ago [\#96712](#96712) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Generate Serial based on Product and option](/forum/17-serial-how-to/78873-generate-serial-based-on-product-and-option?start=20#96712 "I have yet to purchase the plugin because I need to know if this is possible.  I know you can customize the generators to some extent, but I need to know if it is possible to generate a software key based on the product they choose and an option choice.  If this is possible, could you point in the direction on how to accomplish this? I know basic/intermediate javascript but very little PHP so any assistance will be greatly appreciated.")*

Hi,

You can create another pack using the same generator and assign this new pack to another product.
Your algorithm would load variables from the new product (and his option) and generate a serial which would be stored in the second pack.

It is the classical way for HikaSerial configuration and all plugins works like that, I guess that your plugin would be compatible directly with this structure.

Regards,

---

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

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE3LXNlcmlhbC1ob3ctdG8vNzg4NzMtZ2VuZXJhdGUtc2VyaWFsLWJhc2VkLW9uLXByb2R1Y3QtYW5kLW9wdGlvbj9zdGFydD0yMCZ0bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) 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 [\#96713](#96713) by [btbjosh](/forum/user/12727-btbjosh "View btbjosh's Profile")  Replied by *[btbjosh](/forum/user/12727-btbjosh "View btbjosh's Profile")* on topic *[Generate Serial based on Product and option](/forum/17-serial-how-to/78873-generate-serial-based-on-product-and-option?start=20#96713 "I have yet to purchase the plugin because I need to know if this is possible.  I know you can customize the generators to some extent, but I need to know if it is possible to generate a software key based on the product they choose and an option choice.  If this is possible, could you point in the direction on how to accomplish this? I know basic/intermediate javascript but very little PHP so any assistance will be greatly appreciated.")*

Yep. That answers my question! Thanks.

---

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

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

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

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

Time to create page: 0.073 seconds

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