Hi,
The most important function in a generator plugin is the "generate" one.
/**
* @param object $pack
* @param object $order
* @param int $quantity
* @param array $serials
*/
public function generate(&$pack, &$order, $quantity, &$serials) {
if(!isset($pack->randomgen)) // replace "randomgen" by your plugin name
return;
// load $this->plugin_params;
parent::pluginParams($pack->randomgen); // replace "randomgen" by your plugin name
for($q = 0; $q < $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,