News:

Looking for documentation? Take a look on our wiki

Main Menu

Hide a specific custom field of a related product?

Started by Picklehead, March 17, 2022, 17:44:36 PM

Previous topic - Next topic

Picklehead

Hi,
I am loading related products onto a product and only want to show 4 of the 8 custom fields of the related product.

Does anyone know if there is a way to do this, but still show all 8 Custom fields when you display the related product?


This is the code I am using to return the custom fields at the moment.


if ($customFieldParams->show_name) {
echo '<th>'.JText::_('COM_VIRTUEMART_CART_NAME').'</th>';
$columns++;
$columnsSpanLeft++;
}
if ($customFieldParams->show_customfields) {
foreach ($customColumns as $i=>$column ) {
if (isset($customSubColumns[$i]) && is_array($customSubColumns[$i])) {
echo '<th colspan="'.count($customSubColumns[$i]).'">'.$column.'</th>';
foreach ($customSubColumns[$i] as $column ) {
$columns++;
}
} else {
echo '<th>'.$column.'</th>';
$columnsSpanLeft++;
$columns++;
}
}
}


Thanks for any help!

sagaranvekar

Hide those custom fields with CSS instead?
May be using specific child selector?

Picklehead

Thanks for the reply, I will look to do this via code at some stage but the following worked out ok



#productdetailsview table tr th:nth-child(n+6){
    display: none;
}

#productdetailsview table tr td:nth-child(n+6){
    display: none;
}