Generate Serial based on Product and option

  • Posts: 90
  • Thank you received: 1
11 years 7 months ago #96368

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.


:) — Josh
Last edit: 11 years 7 months ago by btbjosh.

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

  • Posts: 90
  • Thank you received: 1
11 years 7 months ago #96381

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

if(!empty($order->cart->products)) {
	foreach($order->cart->products as $p) {
		if($p->product_id == $pack->product_id) {
			// Read the product code
			$product_code = $p->order_product_code;
			$parent_item_id = $p->order_product_id;
			break;
		}
	}
	foreach($order->cart->products as $o) {
		if($o->order_product_option_parent_id == $parent_item_id) {
			//Get the option purchased		
			$software_option = $o->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?


:) — Josh
Last edit: 11 years 7 months ago by Jerome. Reason: little modification

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
11 years 7 months ago #96384

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 :)

Regards,


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

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: btbjosh

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

  • Posts: 90
  • Thank you received: 1
11 years 7 months ago #96385

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.


:) — Josh

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

  • Posts: 90
  • Thank you received: 1
11 years 7 months ago #96397

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?


:) — Josh

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
11 years 7 months ago #96420

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 & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 90
  • Thank you received: 1
11 years 7 months ago #96684

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?


:) — Josh

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
11 years 7 months ago #96712

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 & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 90
  • Thank you received: 1
11 years 7 months ago #96713

Yep. That answers my question! Thanks.


:) — Josh

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

Moderators: Obsidev
Time to create page: 0.070 seconds
Powered by Kunena Forum