VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: Picklehead on March 17, 2022, 17:44:36 PM

Title: Hide a specific custom field of a related product?
Post by: Picklehead on March 17, 2022, 17:44:36 PM
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!
Title: Re: Hide a specific custom field of a related product?
Post by: sagaranvekar on March 17, 2022, 22:37:10 PM
Hide those custom fields with CSS instead?
May be using specific child selector?
Title: Re: Hide a specific custom field of a related product?
Post by: Picklehead on March 18, 2022, 12:15:39 PM
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;
}