VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: 2dmaster on June 23, 2018, 22:56:22 PM

Title: how to echo only needed custom fields ?
Post by: 2dmaster on June 23, 2018, 22:56:22 PM
I need to print only like 1,3,5 values of foreach. I have foreach in my template (joomla - virtuemart)

foreach($product->customfields as $field){
    echo $field->virtuemart_custom_id;
    echo $field->custom_title;
    echo $field->customfield_value;
    echo "<br>";
}
Why this code in foreach not works ? ↓↓↓

if($field->virtuemart_custom_id == 1) {echo "get 1<br>";}
if($field->virtuemart_custom_id == 3) {echo "get 3";}

How get only 1,3,5,8,20 $customfield ?? in foreach.
Title: Re: how to echo only needed custom fields ?
Post by: Jörgen on June 24, 2018, 00:44:07 AM
Try this:

print_r( $field);

To see what $field holds

Jörgen @ Kreativ Fotografi
Title: Re: how to echo only needed custom fields ?
Post by: Jörgen on June 24, 2018, 14:23:04 PM
You will have to put some effort into this yourself. Try my suggestion and examine the output. Then You will see what to echo or print.

regards

Jörgen @ Kreativ Fotografi
Title: Re: how to echo only needed custom fields ?
Post by: Studio 42 on June 24, 2018, 23:41:54 PM
Why not using a new position "my-position"
And render it with :
   echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'my-position'));