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

#   Custom field country/state for products not saving

##

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

Less More

- Posts: 3
- Thank you received: 0
-
-

13 years 10 months ago [\#80974](#80974) by [jeanhh](/forum/user/11955-jeanhh "View jeanhh's Profile")  *[Custom field country/state for products not saving](/forum/2-general-talk-about-hikashop/76539-custom-field-country-state-for-products-not-saving#80974 "I have bought Hikashop business.  I want to add product origin as extra product description (country and states).  I have add two custom fields in the product table: product&#95;country and product&#95;state (see screenshots).  It works well, I can add a new product specifying the two extra fields, but it seems that it is not saving it. When I save the product specifying country and state, coming back to the product edit form shows the initial values. Also, the defaults state specified in the custom field is not used in the product add form.  Don't know if this is a bug or me using custom fields incorrectly... Please let me know.  JH")* was created by *[jeanhh](/forum/user/11955-jeanhh "View jeanhh's Profile")*

I have bought Hikashop business.

I want to add product origin as extra product description (country and states).

I have add two custom fields in the product table: product_country and product_state (see screenshots).

It works well, I can add a new product specifying the two extra fields, but it seems that it is not saving it. When I save the product specifying country and state, coming back to the product edit form shows the initial values. Also, the defaults state specified in the custom field is not used in the product add form.

Don't know if this is a bug or me using custom fields incorrectly... Please let me know.

JH

- [ ![Screen&#95;Shot&#95;2012-12-08&#95;at&#95;3&#95;06&#95;03&#95;PM.png](/forum/attachment/7453) ](/forum/attachment/7453 "...3&#95;06&#95;03&#95;PM.png") [ ](/forum/attachment/7453?download=1 "...3&#95;06&#95;03&#95;PM.png")
- [ ![Screen&#95;Shot&#95;2012-12-08&#95;at&#95;3&#95;04&#95;26&#95;PM.png](/forum/attachment/7454) ](/forum/attachment/7454 "...3&#95;04&#95;26&#95;PM.png") [ ](/forum/attachment/7454?download=1 "...3&#95;04&#95;26&#95;PM.png")
- [ ![Screen&#95;Shot&#95;2012-12-08&#95;at&#95;3&#95;03&#95;45&#95;PM.png](/forum/attachment/7455) ](/forum/attachment/7455 "...3&#95;03&#95;45&#95;PM.png") [ ](/forum/attachment/7455?download=1 "...3&#95;03&#95;45&#95;PM.png")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzc2NTM5LWN1c3RvbS1maWVsZC1jb3VudHJ5LXN0YXRlLWZvci1wcm9kdWN0cy1ub3Qtc2F2aW5nP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) 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?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86323
- Thank you received: 14283
-
-

13 years 10 months ago [\#81105](#81105) 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 country/state for products not saving](/forum/2-general-talk-about-hikashop/76539-custom-field-country-state-for-products-not-saving#81105 "I have bought Hikashop business.  I want to add product origin as extra product description (country and states).  I have add two custom fields in the product table: product&#95;country and product&#95;state (see screenshots).  It works well, I can add a new product specifying the two extra fields, but it seems that it is not saving it. When I save the product specifying country and state, coming back to the product edit form shows the initial values. Also, the defaults state specified in the custom field is not used in the product add form.  Don't know if this is a bug or me using custom fields incorrectly... Please let me know.  JH")*

That's a bug because zone type custom fields were not supposed to be used for product custom fields ![:)](/media/kunena/emoticons/3.png ":)")

Replace the whole function state in the file administrator/components/com_hikashop/views/field/view.html.php by that code: Code:

function state(){ $namekey = JRequest::getCmd('namekey',''); if(!empty($namekey)){ $field_namekey = JRequest::getString('field_namekey', ''); if(empty($field_namekey)) $field_namekey = 'address_state'; $field_id = JRequest::getString('field_id', ''); if(empty($field_id)) $field_id = 'address_state'; $field_type = JRequest::getString('field_type', ''); if(empty($field_type)) $field_type = 'address'; $class = hikashop_get('type.country'); echo $class-&gt;displayStateDropDown($namekey, $field_id, $field_namekey, $field_type); } exit; }

and it should work properly.

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

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzc2NTM5LWN1c3RvbS1maWVsZC1jb3VudHJ5LXN0YXRlLWZvci1wcm9kdWN0cy1ub3Qtc2F2aW5nP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

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

Less More

- Posts: 3
- Thank you received: 0
-
-

13 years 10 months ago [\#82207](#82207) by [jeanhh](/forum/user/11955-jeanhh "View jeanhh's Profile")  Replied by *[jeanhh](/forum/user/11955-jeanhh "View jeanhh's Profile")* on topic *[Custom field country/state for products not saving](/forum/2-general-talk-about-hikashop/76539-custom-field-country-state-for-products-not-saving#82207 "I have bought Hikashop business.  I want to add product origin as extra product description (country and states).  I have add two custom fields in the product table: product&#95;country and product&#95;state (see screenshots).  It works well, I can add a new product specifying the two extra fields, but it seems that it is not saving it. When I save the product specifying country and state, coming back to the product edit form shows the initial values. Also, the defaults state specified in the custom field is not used in the product add form.  Don't know if this is a bug or me using custom fields incorrectly... Please let me know.  JH")*

Thanks it works now well in the Product Add page.

Just one problem remaining: in the fronted, when I view the product, it shows the "code" of the state and not the state (see screenshot). I guess I should configure something but did not find where to do it.

Many thanks for your help.

JH

- [ ![1AF9E504-E14F-4A8B-AAB2-E15D14229B47.png](/forum/attachment/7594) ](/forum/attachment/7594 "...5D14229B47.png") [ ](/forum/attachment/7594?download=1 "...5D14229B47.png")
- [ ![Screen&#95;Shot&#95;2012-12-15&#95;at&#95;1&#95;44&#95;19&#95;PM.png](/forum/attachment/7595) ](/forum/attachment/7595 "...1&#95;44&#95;19&#95;PM.png") [ ](/forum/attachment/7595?download=1 "...1&#95;44&#95;19&#95;PM.png")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzc2NTM5LWN1c3RvbS1maWVsZC1jb3VudHJ5LXN0YXRlLWZvci1wcm9kdWN0cy1ub3Qtc2F2aW5nP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) 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?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86323
- Thank you received: 14283
-
-

13 years 10 months ago [\#82487](#82487) 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 country/state for products not saving](/forum/2-general-talk-about-hikashop/76539-custom-field-country-state-for-products-not-saving#82487 "I have bought Hikashop business.  I want to add product origin as extra product description (country and states).  I have add two custom fields in the product table: product&#95;country and product&#95;state (see screenshots).  It works well, I can add a new product specifying the two extra fields, but it seems that it is not saving it. When I save the product specifying country and state, coming back to the product edit form shows the initial values. Also, the defaults state specified in the custom field is not used in the product add form.  Don't know if this is a bug or me using custom fields incorrectly... Please let me know.  JH")*

You need to replace the code: Code:

$types[$field-&gt;field_options['zone_type']]=$field-&gt;field_options['zone_type']; }elseif($test){

by: Code:

$types[$field-&gt;field_options['zone_type']]=$field-&gt;field_options['zone_type']; }elseif(empty($field-&gt;field_value)){

and add the code: Code:

$namekey = $oneField-&gt;field_namekey; if(!empty($data-&gt;$namekey)){ $oneField-&gt;field_default = $data-&gt;$namekey; }

after the code: Code:

if($oneField-&gt;field_type=='zone' &amp;&amp; !empty($oneField-&gt;field_options['zone_type']) &amp;&amp; $oneField-&gt;field_options['zone_type']=='country'){ $zoneClass = hikashop_get('class.zone');

in the file administrator/components/com_hikashop/classes/field.php and that should do it.

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

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzc2NTM5LWN1c3RvbS1maWVsZC1jb3VudHJ5LXN0YXRlLWZvci1wcm9kdWN0cy1ub3Qtc2F2aW5nP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

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

Less More

- Posts: 3
- Thank you received: 0
-
-

13 years 10 months ago [\#83228](#83228) by [jeanhh](/forum/user/11955-jeanhh "View jeanhh's Profile")  Replied by *[jeanhh](/forum/user/11955-jeanhh "View jeanhh's Profile")* on topic *[Custom field country/state for products not saving](/forum/2-general-talk-about-hikashop/76539-custom-field-country-state-for-products-not-saving#83228 "I have bought Hikashop business.  I want to add product origin as extra product description (country and states).  I have add two custom fields in the product table: product&#95;country and product&#95;state (see screenshots).  It works well, I can add a new product specifying the two extra fields, but it seems that it is not saving it. When I save the product specifying country and state, coming back to the product edit form shows the initial values. Also, the defaults state specified in the custom field is not used in the product add form.  Don't know if this is a bug or me using custom fields incorrectly... Please let me know.  JH")*

Now it is working well!

Thanks a lot.

JH

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzc2NTM5LWN1c3RvbS1maWVsZC1jb3VudHJ5LXN0YXRlLWZvci1wcm9kdWN0cy1ub3Qtc2F2aW5nP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) 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.090 seconds

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