VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: szmidt344 on February 04, 2015, 14:43:44 PM

Title: Custom fields hidden on Product Details [solved]
Post by: szmidt344 on February 04, 2015, 14:43:44 PM
Hey guys!

Im feeling so close to resolve my problem, but its still getting errors.

So I would like to show custom fields on product details page, but only few products have this option.
This code works only for products with custom field:

<?php
$custom_title 
null;
foreach (
$this->product->customfieldsSorted['normal'] as $field) { 
if ( 
$field->is_hidden )
continue;
if (
$field->display) {
?>

<span class="product-field-display"><?php echo $field->display; }} ?></span>


If product hasn't custom field it shows
QuoteWarning: Invalid argument supplied for foreach() in

Any idea?
Title: Re: Custom fields hidden on Product Details
Post by: GJC Web Design on February 04, 2015, 22:24:09 PM


<?php
$custom_title 
null;
if(
$this->product->customfieldsSorted['normal']){
     foreach (
$this->product->customfieldsSorted['normal'] as $field) { 
        if ( 
$field->is_hidden )
      continue;
            if (
$field->display) { ?>

                <span class="product-field-display"><?php echo $field->display; </span>
             }
        } 
    }
?>


Title: Re: Custom fields hidden on Product Details
Post by: szmidt344 on February 05, 2015, 10:42:22 AM
Quote from: GJC Web Design on February 04, 2015, 22:24:09 PM


<?php
$custom_title 
null;
if(
$this->product->customfieldsSorted['normal']){
     foreach (
$this->product->customfieldsSorted['normal'] as $field) { 
        if ( 
$field->is_hidden )
      continue;
            if (
$field->display) { ?>

                <span class="product-field-display"><?php echo $field->display; </span>
             }
        } 
    }
?>




Solved :) Thank You!