- Posts: 3
- Thank you received: 0
Custom field country/state for products not saving
13 years 9 months ago #80974
by jeanhh
Custom field country/state for products not saving was created by jeanhh
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
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
Please Log in or Create an account to join the conversation.
13 years 9 months ago #81105
by nicolas
Replied by nicolas on topic Custom field country/state for products not saving
That's a bug because zone type custom fields were not supposed to be used for product custom fields 
Replace the whole function state in the file administrator/components/com_hikashop/views/field/view.html.php by that code:
and it should work properly.
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->displayStateDropDown($namekey, $field_id, $field_namekey, $field_type);
}
exit;
}
The following user(s) said Thank You: jeanhh
Please Log in or Create an account to join the conversation.
13 years 9 months ago #82207
by jeanhh
Replied by jeanhh on topic Custom field country/state for products not saving
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
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
Please Log in or Create an account to join the conversation.
13 years 9 months ago #82487
by nicolas
Replied by nicolas on topic Custom field country/state for products not saving
You need to replace the code:
by:
and add the code:
after the code:
in the file administrator/components/com_hikashop/classes/field.php and that should do it.
Code:
$types[$field->field_options['zone_type']]=$field->field_options['zone_type'];
}elseif($test){
by:
Code:
$types[$field->field_options['zone_type']]=$field->field_options['zone_type'];
}elseif(empty($field->field_value)){
Code:
$namekey = $oneField->field_namekey;
if(!empty($data->$namekey)){
$oneField->field_default = $data->$namekey;
}
Code:
if($oneField->field_type=='zone' && !empty($oneField->field_options['zone_type']) && $oneField->field_options['zone_type']=='country'){
$zoneClass = hikashop_get('class.zone');
The following user(s) said Thank You: jeanhh
Please Log in or Create an account to join the conversation.
13 years 9 months ago #83228
by jeanhh
Replied by jeanhh on topic Custom field country/state for products not saving
Now it is working well!
Thanks a lot.
JH
Thanks a lot.
JH
Please Log in or Create an account to join the conversation.
Time to create page: 0.260 seconds