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

#   Override HikaSerial on Custom checkout field

##

- **[Devine](/forum/user/2915-devine "View Devine's Profile")**
- [![Devine's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/2915-devine "View Devine's Profile") Topic Author
- [ Offline](/forum/user/2915-devine)

Less More

- Posts: 62
- Thank you received: 0
-
-

14 years 4 months ago [\#55130](#55130) by [Devine](/forum/user/2915-devine "View Devine's Profile")  *[Override HikaSerial on Custom checkout field](/forum/17-serial-how-to/55130-override-hikaserial-on-custom-checkout-field#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.")* was created by *[Devine](/forum/user/2915-devine "View Devine's Profile")*

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](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE3LXNlcmlhbC1ob3ctdG8vNTUxMzAtb3ZlcnJpZGUtaGlrYXNlcmlhbC1vbi1jdXN0b20tY2hlY2tvdXQtZmllbGQ/dG1wbD1tYXJrZG93bg==) 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: 26401
- Thank you received: 4081
-
- [](http://obsi.dev)
-

14 years 4 months ago [\#55153](#55153) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Re: Override HikaSerial on Custom checkout field](/forum/17-serial-how-to/55130-override-hikaserial-on-custom-checkout-field#55153 "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.")*

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

$this-&gt;values[] = JHTML::_('select.option', 'sql', JText::_('PACK_DATA_SQL')); $this-&gt;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 Code:

$query = 'SELECT serial_id FROM ' . hikaserial::table('serial') . ' WHERE serial_pack_id = '.$pack-&gt;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 &amp; HikaSerial developer / HikaShop core dev team.

The following user(s) said Thank You: [Devine](/forum/user/2915-devine "View Devine's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE3LXNlcmlhbC1ob3ctdG8vNTUxMzAtb3ZlcnJpZGUtaGlrYXNlcmlhbC1vbi1jdXN0b20tY2hlY2tvdXQtZmllbGQ/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Devine](/forum/user/2915-devine "View Devine's Profile")**
- [![Devine's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/2915-devine "View Devine's Profile") Topic Author
- [ Offline](/forum/user/2915-devine)

Less More

- Posts: 62
- Thank you received: 0
-
-

14 years 4 months ago [\#55393](#55393) by [Devine](/forum/user/2915-devine "View Devine's Profile")  Replied by *[Devine](/forum/user/2915-devine "View Devine's Profile")* on topic *[Re: Override HikaSerial on Custom checkout field](/forum/17-serial-how-to/55130-override-hikaserial-on-custom-checkout-field#55393 "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.")*

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

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE3LXNlcmlhbC1ob3ctdG8vNTUxMzAtb3ZlcnJpZGUtaGlrYXNlcmlhbC1vbi1jdXN0b20tY2hlY2tvdXQtZmllbGQ/dG1wbD1tYXJrZG93bg==) 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: 26401
- Thank you received: 4081
-
- [](http://obsi.dev)
-

14 years 4 months ago [\#55442](#55442) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Re: Override HikaSerial on Custom checkout field](/forum/17-serial-how-to/55130-override-hikaserial-on-custom-checkout-field#55442 "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.")*

Hi,

Reference: [ www.hikashop.com/en/hikashop/125-hikaser...er.html#fct\_generate](http://www.hikashop.com/en/hikashop/125-hikaserial-developer.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 : Code:

$order-&gt;mycustomfield

(You can access to each columns of the table "hikasho_order", custom fields included).

---

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

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE3LXNlcmlhbC1ob3ctdG8vNTUxMzAtb3ZlcnJpZGUtaGlrYXNlcmlhbC1vbi1jdXN0b20tY2hlY2tvdXQtZmllbGQ/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Devine](/forum/user/2915-devine "View Devine's Profile")**
- [![Devine's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/2915-devine "View Devine's Profile") Topic Author
- [ Offline](/forum/user/2915-devine)

Less More

- Posts: 62
- Thank you received: 0
-
-

14 years 1 day ago [\#78086](#78086) by [Devine](/forum/user/2915-devine "View Devine's Profile")  Replied by *[Devine](/forum/user/2915-devine "View Devine's Profile")* on topic *[Override HikaSerial on Custom checkout field](/forum/17-serial-how-to/55130-override-hikaserial-on-custom-checkout-field#78086 "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.")*

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-&gt;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-&gt;products[$pack-&gt;product_id] so I assume something like $order-&gt;cart-&gt;products[?] but I am not sure which index[?] to get in the products array.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE3LXNlcmlhbC1ob3ctdG8vNTUxMzAtb3ZlcnJpZGUtaGlrYXNlcmlhbC1vbi1jdXN0b20tY2hlY2tvdXQtZmllbGQ/dG1wbD1tYXJrZG93bg==) 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: 26401
- Thank you received: 4081
-
- [](http://obsi.dev)
-

14 years 1 day ago [\#78141](#78141) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Override HikaSerial on Custom checkout field](/forum/17-serial-how-to/55130-override-hikaserial-on-custom-checkout-field#78141 "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.")*

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

$this-&gt;product[$pack-&gt;product_id]['id']

which is load in the function "loadPacks" in the same class.

Regards,

---

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

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE3LXNlcmlhbC1ob3ctdG8vNTUxMzAtb3ZlcnJpZGUtaGlrYXNlcmlhbC1vbi1jdXN0b20tY2hlY2tvdXQtZmllbGQ/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Devine](/forum/user/2915-devine "View Devine's Profile")**
- [![Devine's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/2915-devine "View Devine's Profile") Topic Author
- [ Offline](/forum/user/2915-devine)

Less More

- Posts: 62
- Thank you received: 0
-
-

13 years 11 months ago [\#78468](#78468) by [Devine](/forum/user/2915-devine "View Devine's Profile")  Replied by *[Devine](/forum/user/2915-devine "View Devine's Profile")* on topic *[Override HikaSerial on Custom checkout field](/forum/17-serial-how-to/55130-override-hikaserial-on-custom-checkout-field#78468 "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.")*

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-&gt;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-&gt;product[$pack-&gt;product_id] which is available in the order class. I assume it needs to be something like $order-&gt;cart-&gt;products[$pack-&gt;product_id] but I can't quite get it to work.

Thanks in advance.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE3LXNlcmlhbC1ob3ctdG8vNTUxMzAtb3ZlcnJpZGUtaGlrYXNlcmlhbC1vbi1jdXN0b20tY2hlY2tvdXQtZmllbGQ/dG1wbD1tYXJrZG93bg==) 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: 26401
- Thank you received: 4081
-
- [](http://obsi.dev)
-

13 years 11 months ago [\#78480](#78480) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Override HikaSerial on Custom checkout field](/forum/17-serial-how-to/55130-override-hikaserial-on-custom-checkout-field#78480 "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.")*

Hi,

In HikaSerial "$this-&gt;product" is loaded by the function loadPacks of hikaserialOrderClass.
$this-&gt;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: Code:

$this-&gt;product = array( $product_id =&gt; array( 'id' =&gt; $order_product_id, 'qty' =&gt; $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. Code:

$orderClass = hikaserial::get('shop.class.order'); $order_cart = $orderClass-&gt;loadFullOrder($order_id, false, false);

Regards,

---

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

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzE3LXNlcmlhbC1ob3ctdG8vNTUxMzAtb3ZlcnJpZGUtaGlrYXNlcmlhbC1vbi1jdXN0b20tY2hlY2tvdXQtZmllbGQ/dG1wbD1tYXJrZG93bg==) 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.067 seconds

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