VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: Marttyn on November 11, 2014, 18:28:01 PM

Title: PHP code to know if product has childs or custom fields?
Post by: Marttyn on November 11, 2014, 18:28:01 PM
Hi!
Ive modified my views so the products can be added to cart from virtuemart and category views.
But i would like that products with child products, or with custom fields to display "Details" button instead of "Add to cart".

Ive tried with

if($product->customsChilds){
    echo "<p>has child</p>";
}
else{
    echo "<p>no child</p>";
}


and


if($product->customfieldsCart){
    echo "<p>has custom fields</p>";
}
else{
    echo "<p>no custom fields</p>";
}


With no luck, as some of my products has childs or custom fields but this still show no child/custom fields  :(
Is there any other way to check if product has custom fields of childs?

Thanks!
Title: Re: PHP code to know if product has childs or custom fields?
Post by: Marttyn on November 17, 2014, 14:44:33 PM
Any ideas?
Title: Re: PHP code to know if product has childs or custom fields?
Post by: GJC Web Design on November 17, 2014, 16:32:05 PM
No mention of any versions.....
Title: Re: PHP code to know if product has childs or custom fields?
Post by: Marttyn on November 20, 2014, 01:37:21 AM
It works with code from first post, although i was having some strange problem. I deleted the item and created again and now works fine.
It was using stockable variant.