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

#   custom field in custom module

##

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

Less More

- Posts: 23
- Thank you received: 5
-
-

1 year 7 months ago [\#366203](#366203) by [mizso676](/forum/user/82243-mizso676 "View mizso676's Profile")  *[custom field in custom module](/forum/32-content-creation/909253-custom-field-in-custom-module#366203 "-- HikaShop version -- : 5.1.0 -- Joomla version -- : 5.2.2 -- PHP version -- : 8.1.28 -- Browser(s) name and version -- : chrome latest, firefox, etc.  Hi guys!  I think I have a simple question: how can I call custom fields from a custom module (made by me, not joomla custom html module)?  For example: I want to display a custom field with an external stock quantity (extstore field name) through my custom module, so that it appears on the product page within the show&#95;default.php file. I want to place it after the 'Add to cart button'.  Inserting it as module id (with regular labs) to show&#95;default.php causes the page to crash due to this-&gt;element.  Thanks for your help!")* was created by *[mizso676](/forum/user/82243-mizso676 "View mizso676's Profile")*

-- HikaShop version -- : 5.1.0
-- Joomla version -- : 5.2.2
-- PHP version -- : 8.1.28
-- Browser(s) name and version -- : chrome latest, firefox, etc.

Hi guys!

I think I have a simple question: how can I call custom fields from a custom module (made by me, not joomla custom html module)?

For example: I want to display a custom field with an external stock quantity (extstore field name) through my custom module, so that it appears on the product page within the show_default.php file. I want to place it after the 'Add to cart button'.

Inserting it as module id (with regular labs) to show_default.php causes the page to crash due to this-&gt;element.

Thanks for your help!

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

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86290
- Thank you received: 14268
-
-

1 year 7 months ago [\#366207](#366207) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[custom field in custom module](/forum/32-content-creation/909253-custom-field-in-custom-module#366207 "-- HikaShop version -- : 5.1.0 -- Joomla version -- : 5.2.2 -- PHP version -- : 8.1.28 -- Browser(s) name and version -- : chrome latest, firefox, etc.  Hi guys!  I think I have a simple question: how can I call custom fields from a custom module (made by me, not joomla custom html module)?  For example: I want to display a custom field with an external stock quantity (extstore field name) through my custom module, so that it appears on the product page within the show&#95;default.php file. I want to place it after the 'Add to cart button'.  Inserting it as module id (with regular labs) to show&#95;default.php causes the page to crash due to this-&gt;element.  Thanks for your help!")*

Hi,

Why display the custom field via a module ?
Can't you create a custom field of the table "item" via the Display&gt;Custom fields menu and use the display options to just have HikaShop display it before the add to cart button for you ?
Why is that not possible ?
Where does this "external stock quantity" comes from ? Why do you want to add it to the product page ? What is its purpose ?
If you can provide more explanation on what you're trying to achieve, we should be able to tell you what to do.

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

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

Less More

- Posts: 23
- Thank you received: 5
-
-

1 year 7 months ago [\#366210](#366210) by [mizso676](/forum/user/82243-mizso676 "View mizso676's Profile")  Replied by *[mizso676](/forum/user/82243-mizso676 "View mizso676's Profile")* on topic *[custom field in custom module](/forum/32-content-creation/909253-custom-field-in-custom-module#366210 "-- HikaShop version -- : 5.1.0 -- Joomla version -- : 5.2.2 -- PHP version -- : 8.1.28 -- Browser(s) name and version -- : chrome latest, firefox, etc.  Hi guys!  I think I have a simple question: how can I call custom fields from a custom module (made by me, not joomla custom html module)?  For example: I want to display a custom field with an external stock quantity (extstore field name) through my custom module, so that it appears on the product page within the show&#95;default.php file. I want to place it after the 'Add to cart button'.  Inserting it as module id (with regular labs) to show&#95;default.php causes the page to crash due to this-&gt;element.  Thanks for your help!")*

Ok, I'll try to explain ![:)](/media/kunena/emoticons/8.png ":)")

I would like to create an interface similar to the current shopping cart block, where the quantity of an external stock would be displayed.

If the visitor doesn't have the right quantity in the internal stock, he could use the external stock control to select the extra quantity that suits him and I would send this in an email to the email address set in the admin interface (e.g. using rsform).

So the basic add to cart button would do the usual hikashop procedure, while the second block would do the external warehouse enquiry.

Visitor selects a quantity, adds to list, goes to next product, adds to list. Then at the end he sends this information (e.g. by clicking on a button in a modal) and I can contact him based on this

We have a lot of types of products, few in internal stock, more in external stock.

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

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86290
- Thank you received: 14268
-
-

1 year 7 months ago [\#366217](#366217) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[custom field in custom module](/forum/32-content-creation/909253-custom-field-in-custom-module#366217 "-- HikaShop version -- : 5.1.0 -- Joomla version -- : 5.2.2 -- PHP version -- : 8.1.28 -- Browser(s) name and version -- : chrome latest, firefox, etc.  Hi guys!  I think I have a simple question: how can I call custom fields from a custom module (made by me, not joomla custom html module)?  For example: I want to display a custom field with an external stock quantity (extstore field name) through my custom module, so that it appears on the product page within the show&#95;default.php file. I want to place it after the 'Add to cart button'.  Inserting it as module id (with regular labs) to show&#95;default.php causes the page to crash due to this-&gt;element.  Thanks for your help!")*

Hi,

Ok. Thanks for the details.
I think it's a good idea to add your interface to the product details page to handle that.

Adding it in product / show_default can probably be done. One thing you need to be wary off is that the whole product / show_default is inside form tags from the product / show view file. And in HTML, you can't have a form element inside another form element. That's invalid, and it will create erratic problems with the forms. So you might have to move the ending tag of the form from product / show to product / show_default as to encompass the default quantity area of HikaShop, without encompassing your own form.

Also, you can directly put your custom form inside product / show_default. You don't have to create module with your code inside and insert it in the view with another extension. That should simplify work for you.

Finally, if you have an error when you add the tag from modules anywhere in product / show_default, it probably means that you've added it at the wrong place in the code.

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

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

Less More

- Posts: 23
- Thank you received: 5
-
-

1 year 7 months ago -  1 year 7 months ago [\#366255](#366255) by [mizso676](/forum/user/82243-mizso676 "View mizso676's Profile")  Replied by *[mizso676](/forum/user/82243-mizso676 "View mizso676's Profile")* on topic *[custom field in custom module](/forum/32-content-creation/909253-custom-field-in-custom-module#366255 "-- HikaShop version -- : 5.1.0 -- Joomla version -- : 5.2.2 -- PHP version -- : 8.1.28 -- Browser(s) name and version -- : chrome latest, firefox, etc.  Hi guys!  I think I have a simple question: how can I call custom fields from a custom module (made by me, not joomla custom html module)?  For example: I want to display a custom field with an external stock quantity (extstore field name) through my custom module, so that it appears on the product page within the show&#95;default.php file. I want to place it after the 'Add to cart button'.  Inserting it as module id (with regular labs) to show&#95;default.php causes the page to crash due to this-&gt;element.  Thanks for your help!")*

Following your information, I am now working directly in show_default.php. Let me ask you how do I get the data for the variants? Do you have any description how to call the custom fields between product and variant? My current code looks like this: Code:

&lt;script&gt; document.addEventListener("DOMContentLoaded", function() { function getVariantData() { let productNameMain = document.querySelector("#hikashop_product_name_main"); let variantSubName = document.querySelector(".hikashop_product_variant_subname"); let fullProductName = productNameMain ? productNameMain.textContent.trim() : "N/A"; let variantName = variantSubName ? variantSubName.textContent.trim() : ""; let productIdElement = document.querySelector("#hikashop_product_id_main input[name='product_id']"); let productId = productIdElement ? productIdElement.value : "N/A"; let extstoreElement = document.querySelector(".hikashop_product_custom_value"); let extstoreValue = extstoreElement ? extstoreElement.textContent.trim() : "N/A"; document.getElementById('variant-name-display').textContent = fullProductName + ' ' + variantName; document.getElementById('extstore-value-display').textContent = extstoreValue; } getVariantData(); document.addEventListener("click", function(event) { if (event.target.closest(".hikashop_product_characteristic")) { setTimeout(getVariantData, 1000); // Frissítés az AJAX miatt } }); document.addEventListener("change", function(event) { if (event.target.matches("select[name='product_id']")) { getVariantData(); } }); }); &lt;/script&gt; &lt;div id="variant-data-display"&gt; &lt;p id="product-name-display"&gt;Termék Név: &lt;span id="variant-name-display"&gt;&lt;/span&gt;&lt;/p&gt; &lt;p id="extstore-display"&gt;Extstore érték: &lt;span id="extstore-value-display"&gt;&lt;/span&gt;&lt;/p&gt; &lt;/div&gt;

Last edit: 1 year 7 months ago by [nicolas](/forum/user/63-nicolas "View nicolas's Profile").

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

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86290
- Thank you received: 14268
-
-

1 year 7 months ago [\#366257](#366257) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[custom field in custom module](/forum/32-content-creation/909253-custom-field-in-custom-module#366257 "-- HikaShop version -- : 5.1.0 -- Joomla version -- : 5.2.2 -- PHP version -- : 8.1.28 -- Browser(s) name and version -- : chrome latest, firefox, etc.  Hi guys!  I think I have a simple question: how can I call custom fields from a custom module (made by me, not joomla custom html module)?  For example: I want to display a custom field with an external stock quantity (extstore field name) through my custom module, so that it appears on the product page within the show&#95;default.php file. I want to place it after the 'Add to cart button'.  Inserting it as module id (with regular labs) to show&#95;default.php causes the page to crash due to this-&gt;element.  Thanks for your help!")*

Hi,

If you want to have your javascript code triggered when the currently selected variant is changed, you can use the event system of HikaShop and register for hkContentChanged:
[ www.hikashop.com/support/documentation/6...tml#hkContentChanged](https://www.hikashop.com/support/documentation/62-hikashop-developer-documentation.html#hkContentChanged)
The full product name, with the main product name + the variant name will be in the div with the id hikashop_product_name_main
So you can directly take it from there without any processing.
Something like this: Code:

let productNameMain = document.querySelector("#hikashop_product_name_main").innerHTML;

For example: Code:

if(window.Oby) { window.Oby.registerAjax(["cart.updated","wishlist.updated"],function(params){ let productNameMain = document.querySelector("#hikashop_product_name_main").innerHTML; document.getElementById('variant-name-display').innerHTML = productNameMain; }); }

The following user(s) said Thank You: [mizso676](/forum/user/82243-mizso676 "View mizso676's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2NvbnRlbnQtY3JlYXRpb24vOTA5MjUzLWN1c3RvbS1maWVsZC1pbi1jdXN0b20tbW9kdWxlP3RtcGw9bWFya2Rvd24=) 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?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.191 seconds

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

[](#top)
