News:

Looking for documentation? Take a look on our wiki

Main Menu

how to echo only needed custom fields ?

Started by 2dmaster, June 23, 2018, 22:56:22 PM

Previous topic - Next topic

2dmaster

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.

Jörgen

Try this:

print_r( $field);

To see what $field holds

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Jörgen

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
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Studio 42

Why not using a new position "my-position"
And render it with :
   echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'my-position'));