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

#   PHP Variable as default value for custom fields

##

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

Less More

- Posts: 25
- Thank you received: 0
-
-

10 years 4 months ago [\#244022](#244022) by [ingjjaa](/forum/user/38158-ingjjaa "View ingjjaa's Profile")  *[PHP Variable as default value for custom fields](/forum/35-orders-management/885269-php-variable-as-default-value-for-custom-fields#244022 "-- HikaShop version -- : 3.6 -- Joomla version -- : 3.5.2 -- PHP version -- : 5.4 -- Error-message(debug-mod must be tuned on) -- : Value for custom fields  HI i have create a custom field name amountofproduct which should storage the amount of items in the cart i have no problem to get thata number in a php code variable, the problem is thata i could put thata field like just disable (just read) vut how could i give the value of the php variable to the default value of the field.")* was created by *[ingjjaa](/forum/user/38158-ingjjaa "View ingjjaa's Profile")*

-- HikaShop version -- : 3.6
-- Joomla version -- : 3.5.2
-- PHP version -- : 5.4
-- Error-message(debug-mod must be tuned on) -- : Value for custom fields

HI i have create a custom field name amountofproduct which should storage the amount of items in the cart i have no problem to get thata number in a php code variable, the problem is thata i could put thata field like just disable (just read) vut how could i give the value of the php variable to the default value of the field.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50Lzg4NTI2OS1waHAtdmFyaWFibGUtYXMtZGVmYXVsdC12YWx1ZS1mb3ItY3VzdG9tLWZpZWxkcz90bXBsPW1hcmtkb3du) 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")
- [ Offline](/forum/user/63-nicolas)

Less More

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

10 years 3 months ago [\#244031](#244031) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[PHP Variable as default value for custom fields](/forum/35-orders-management/885269-php-variable-as-default-value-for-custom-fields#244031 "-- HikaShop version -- : 3.6 -- Joomla version -- : 3.5.2 -- PHP version -- : 5.4 -- Error-message(debug-mod must be tuned on) -- : Value for custom fields  HI i have create a custom field name amountofproduct which should storage the amount of items in the cart i have no problem to get thata number in a php code variable, the problem is thata i could put thata field like just disable (just read) vut how could i give the value of the php variable to the default value of the field.")*

Hi,

The way to do it will depend on how you configured your custom field.
Could you provide a screenshot of the settings of your custom field ?

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

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

Less More

- Posts: 25
- Thank you received: 0
-
-

10 years 3 months ago [\#244037](#244037) by [ingjjaa](/forum/user/38158-ingjjaa "View ingjjaa's Profile")  Replied by *[ingjjaa](/forum/user/38158-ingjjaa "View ingjjaa's Profile")* on topic *[PHP Variable as default value for custom fields](/forum/35-orders-management/885269-php-variable-as-default-value-for-custom-fields#244037 "-- HikaShop version -- : 3.6 -- Joomla version -- : 3.5.2 -- PHP version -- : 5.4 -- Error-message(debug-mod must be tuned on) -- : Value for custom fields  HI i have create a custom field name amountofproduct which should storage the amount of items in the cart i have no problem to get thata number in a php code variable, the problem is thata i could put thata field like just disable (just read) vut how could i give the value of the php variable to the default value of the field.")*

It is a normal field in the address table

- [ ![hikacustom.png](/forum/attachment/32308) ](/forum/attachment/32308 "hikacustom.png") [ ](/forum/attachment/32308?download=1 "hikacustom.png")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50Lzg4NTI2OS1waHAtdmFyaWFibGUtYXMtZGVmYXVsdC12YWx1ZS1mb3ItY3VzdG9tLWZpZWxkcz90bXBsPW1hcmtkb3du) 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")
- [ Offline](/forum/user/63-nicolas)

Less More

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

10 years 3 months ago [\#244058](#244058) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[PHP Variable as default value for custom fields](/forum/35-orders-management/885269-php-variable-as-default-value-for-custom-fields#244058 "-- HikaShop version -- : 3.6 -- Joomla version -- : 3.5.2 -- PHP version -- : 5.4 -- Error-message(debug-mod must be tuned on) -- : Value for custom fields  HI i have create a custom field name amountofproduct which should storage the amount of items in the cart i have no problem to get thata number in a php code variable, the problem is thata i could put thata field like just disable (just read) vut how could i give the value of the php variable to the default value of the field.")*

Hi,

So for the registration form, you can edit the file "custom_fields" or "custom_fields_boostrap" (based on whether the "use bootstrap design" setting is configured in the HikaShop configuration), and add such code at the top:
&lt;?php $this-&gt;address-&gt;cantidaddeproductos = $myvalue; ?&gt;

For the address edition interface, you'll want to add similar code at the top of the file "show" or "form" of the view "address" based on how you configured the "address selector" setting of the HikaShop configuration.

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

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

[](#top)
