Skip to main content

Create a persistent counter

More
13 years 6 months ago #94134 by btbjosh
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?

:) — Josh

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

More
13 years 6 months ago #94135 by Jerome
Replied by Jerome on topic Create a persistent counter
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 & 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.

More
13 years 6 months ago #94137 by btbjosh
Replied by btbjosh on topic Create a persistent counter
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?

:) — Josh

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

More
13 years 6 months ago #94138 by Jerome
Replied by Jerome on topic Create a persistent counter
Hi

You can use the config
Code:
$config = hikaserial::config(); $currentValue = (int)$config->get('software_generator_counter', 0); $currentValue++; // Your algorithm $config->save(array( 'software_generator_counter' => $currentValue ));

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

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.

More
13 years 6 months ago #94144 by btbjosh
Replied by btbjosh on topic Create a persistent counter
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.

:) — Josh

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

More
13 years 6 months ago #94167 by Jerome
Replied by Jerome on topic Create a persistent counter
Hi,

The first part explain the structure of an HikaSerial plugin.
www.hikashop.com/en/hikashop/125-hikaser...eveloper.html#how_to

A generator plugin uses the "generate" function like explain here:
www.hikashop.com/en/hikashop/125-hikaser...er.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 & 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.

More
13 years 6 months ago - 13 years 6 months ago #94169 by btbjosh
Replied by btbjosh on topic Create a persistent counter
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.

:) — Josh
Last edit: 13 years 6 months ago by btbjosh.

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

More
13 years 6 months ago #94228 by Jerome
Replied by Jerome on topic Create a persistent counter
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

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

This last one have a XML file in the Joomla 2.5/3.0 way:
docs.joomla.org/Creating_a_profile_plugin

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.

More
13 years 6 months ago #95051 by btbjosh
Replied by btbjosh on topic Create a persistent counter
Thanks. I seem to have gotten it installed properly. Now I just need to configure/code my generator logic. Here we go!

:) — Josh

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

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