Override HikaSerial on Custom checkout field

  • Posts: 62
  • Thank you received: 0
11 years 10 months ago #55130

We would like to not issue a serial based on a boolean field in the checkout workflow.

Basically we ask the end user if they are an existing customer. If they are an existing customer we would like to not issue them a new serial but rather use their existing serial. Eventually I can see us creating a generator plugin which handles issuing their existing serial and updating our license servers appropriately however as a first step I would just like to stop HikaSerial issuing new serial data when the customer indicates they are an existing customer.

How would you recommend customising this? Keeping in mind in the future HikaSerial will handle using their existing serial.

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

  • Posts: 26034
  • Thank you received: 4006
  • MODERATOR
11 years 10 months ago #55153

Hi,

HikaSerial have an pack option called "pack data".
This option has, for the moment, only one value : "SQL".
I created "pack data" in order to give the possibility to choose the source of data (internal sql, external sql, webservice, specific plugin, etc).

In your case, I think you want to use the "none pack data".

Open the file: administrator/com_hikaserial/types/pack_data.php
and add the second line

$this->values[] = JHTML::_('select.option', 'sql', JText::_('PACK_DATA_SQL'));
$this->values[] = JHTML::_('select.option', 'none', JText::_('PACK_DATA_NONE'));
(I will include it in the next version of HikaSerial).

At this moment, it won't be possible for the pack to retrieve a serial from the database.
So you can include in your plugin generator the check of the boolean field in the checkout workflow.
Using the two SQL requests from the administrator/com_hikaserial/classes/order.php file
$query = 'SELECT serial_id FROM ' . hikaserial::table('serial') . ' WHERE serial_pack_id = '.$pack->pack_id.' AND ' ...

It should have a little modification in the generator plugins in a future release so please add a "return true;" at the end of your generate function.
With a "return false;" or "return (int)$generated_quantity" (with generated_quantity minor than requested quantity) HikaSerial would be able to send an email to the website administrator, telling him that there was a problem during the generation.
So, if your plugin update serials directly in the database, you should tell that everything right even if you doesn't return any serial to add in the database.

Best 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: Devine

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

  • Posts: 62
  • Thank you received: 0
11 years 10 months ago #55393

In the serial generator plugin how will I access the custom checkout fields? Specifically the HikaShop custom order fields.

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

  • Posts: 26034
  • Thank you received: 4006
  • MODERATOR
11 years 10 months ago #55442

Hi,

Reference: www.hikashop.com/en/hikashop/125-hikaser...er.html#fct_generate

The $order object which is passed to the generate function contains all required data.
If you have an order custom field named "mycustomfield", you could access to it like this :

$order->mycustomfield
(You can access to each columns of the table "hikasho_order", custom fields included).


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: 62
  • Thank you received: 0
11 years 6 months ago #78086

I have found a bug in my generator plugin. The part which replicates if pack_data was equal to sql in the order class.

I can see where the problem is but I am not sure what the serial_order_product_id references in the hikaserial_serial table. Can you please advise what this is referencing.

It always seems to be the same as the serial_order_id, so in my generator plugin I just set it to $order->order_id. I hadn't noticed this was incorrect as it worked fine until I started selling multiple products and quantities. Therefore the Attached to product is not displaying correctly in the invoices and other views.

Can you please advise what I should be setting the serial_order_product_id to, in the UPDATE query from within a generator plugin. The order class sets it to $this->products[$pack->product_id] so I assume something like $order->cart->products[?] but I am not sure which index[?] to get in the products array.

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

  • Posts: 26034
  • Thank you received: 4006
  • MODERATOR
11 years 6 months ago #78141

Hi,

"serial_order_product_id" is the value of the "order_product_id" from the table "order_product".
This value is used to make difference between products in the same order. HikaSerial can know which serial is assigned to which product.

In generator plugin, you should not touch the value of the serial_order_product_id. This value is automatically set by the hikaserialOrderClass.
The value is read from

$this->product[$pack->product_id]['id']
which is load in the function "loadPacks" in the same class.

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: 62
  • Thank you received: 0
11 years 5 months ago #78468

Yes I understand this if I am returning $Serials however in some cases I am using the existing SQL pack data and not actually generating any serials. I am essentially replicating what occurs in the order class if($pack->pack_data == 'sql') except I have a different condition in my generator plugin. This is as per you previous instructions in this post.

My problem is when updating the database I am not sure how to get the $this->product[$pack->product_id] which is available in the order class. I assume it needs to be something like $order->cart->products[$pack->product_id] but I can't quite get it to work.

Thanks in advance.

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

  • Posts: 26034
  • Thank you received: 4006
  • MODERATOR
11 years 5 months ago #78480

Hi,

In HikaSerial "$this->product" is loaded by the function loadPacks of hikaserialOrderClass.
$this->product is an array where keys are the HikaShop product id.
Each element is an array with two values : the order_product_id (from order_product) and the order_product_quantity.

Like this:

$this->product = array(
  $product_id => array(
    'id' => $order_product_id,
    'qty' => $order_product_quantity
  )
);

All values could be found in the #__hikashop_order_product table.

Otherwise, you can access to all of these values thanks to the HikaShop Order Class.
$orderClass = hikaserial::get('shop.class.order');
$order_cart = $orderClass->loadFullOrder($order_id, false, false);

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.

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