Hide Custom field

Phoca Cart - complex e-commerce extension
User avatar
Nidzo
Phoca Professional
Phoca Professional
Posts: 478
Joined: 07 Nov 2018, 14:55

Hide Custom field

Post 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
User avatar
Nidzo
Phoca Professional
Phoca Professional
Posts: 478
Joined: 07 Nov 2018, 14:55

Re: Hide Custom field

Post 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 = '';
}
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49125
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Hide Custom field

Post 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
If you find Phoca extensions useful, please support the project
User avatar
Nidzo
Phoca Professional
Phoca Professional
Posts: 478
Joined: 07 Nov 2018, 14:55

Re: Hide Custom field

Post 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.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49125
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Hide Custom field

Post by Jan »

OK
If you find Phoca extensions useful, please support the project
Post Reply