Custom field country/state for products not saving

  • Posts: 3
  • Thank you received: 0
11 years 5 months ago #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_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

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 81633
  • Thank you received: 13085
  • MODERATOR
11 years 4 months ago #81105

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:

	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;
	}
and it should work properly.

The following user(s) said Thank You: jeanhh

Please Log in or Create an account to join the conversation.

  • Posts: 3
  • Thank you received: 0
11 years 4 months ago #82207

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

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 81633
  • Thank you received: 13085
  • MODERATOR
11 years 4 months ago #82487

You need to replace the code:

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

by:
$types[$field->field_options['zone_type']]=$field->field_options['zone_type'];
				}elseif(empty($field->field_value)){
and add the code:
$namekey = $oneField->field_namekey;
							if(!empty($data->$namekey)){
								$oneField->field_default = $data->$namekey;
							}
after the code:
if($oneField->field_type=='zone' && !empty($oneField->field_options['zone_type']) && $oneField->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

Please Log in or Create an account to join the conversation.

  • Posts: 3
  • Thank you received: 0
11 years 4 months ago #83228

Now it is working well!

Thanks a lot.

JH

Please Log in or Create an account to join the conversation.

Time to create page: 0.069 seconds
Powered by Kunena Forum