Page 1 of 1

Hide Custom field

Posted: 01 Aug 2025, 11:32
by Nidzo
I'm curious how to hide a custom field if there are no records in it? E.g. The custom field "How to use" is not required for all products.

Also, in the multilingual version of Phoca Cart, how to translate the content of Custom fields?

In the screenshot, custom field Användning has no content and it is displayed anyway. Also in Serbian version of shop it is displayed in Swedish.
Image

Re: Hide Custom field

Posted: 04 Aug 2025, 12:16
by Nidzo
Managed to hide field when it is empty with override but still remains problem with translating the content of Custom fields?

Code: Select all

$cFG = [];
$fields = PhocacartFields::getProductFields($x);
foreach ($fields as $fieldsGroup) {
	$hasValue = false;

	// Provera da li postoji barem jedno popunjeno polje u grupi
	foreach ($fieldsGroup->fields as $fieldCheck) {
		if (!empty($fieldCheck->value)) {
			$hasValue = true;
			break;
		}
	}

	if (!$hasValue) {
		continue; // preskoči grupu ako nema popunjenih polja
	}

	// Ako je došlo dovde, onda grupa ima nešto i možemo je prikazati
	$alias = 'field-' . $fieldsGroup->id;
	$title = $fieldsGroup->title ?: Text::_('COM_PHOCACART_PRODUCT_CUSTOM_FIELDS');

	$tabLiO .= '<li class="' . $this->s['c']['nav-item'] . ' ' . $activeTab.'"><a href="#' . $alias . '" data-bs-toggle="tab" class="' . $this->s['c']['nav-link'] . ' ' . $active . '">' . $title . '</a></li>';
	$tabO 	.= '<div class="' . $this->s['c']['tabpane'] . ' ph-tab-pane ' . $active . '" id="' . $alias . '">';
	$tabO	.= '<div class="' . $this->s['c']['row'] . '">';

	foreach ($fieldsGroup->fields as $field) {
		if (!empty($field->value)) {
			$tabO .= '<div class="' . $this->s['c']['col.xs12.sm4.md4'] . ' ph-cf-title">';
			$tabO .= isset($field->title) ? $field->title : '';
			$tabO .= '</div>';

			$tabO .= '<div class="' . $this->s['c']['col.xs12.sm6.md6'] . ' ph-cf-value">';
			$tabO .= $field->value;
			$tabO .= '</div>';
		}
	}

	$tabO	.= '</div>';
	$tabO	.= '</div>';
	$active = $activeTab = '';
}

Re: Hide Custom field

Posted: 04 Aug 2025, 12:54
by Jan
Hi, the problem with custom fields is, it is not a part of Phoca Cart, but Joomla part, so I can think about two ways:

- to find some way to translate it in Joomla (but really no idea if this can be supported by Phoca Cart)
- or use similar feature but Phoca Cart built-in - Parameters and Parameter values :idea:

Jan

Re: Hide Custom field

Posted: 06 Aug 2025, 01:05
by Nidzo
Thanks Jan. Parameters could be decent workaround. Not ideal so I disabled Phoca Cart multilingual option and used classic Joomla multilingual option with associations.

Anyhow Phoca Cart multilingual option is fantastic feature and experience.

Re: Hide Custom field

Posted: 06 Aug 2025, 12:28
by Jan
OK