VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: mediax on March 23, 2016, 13:41:35 PM

Title: Display value in an array | Userfields
Post by: mediax on March 23, 2016, 13:41:35 PM
Hi Guys,

I am trying to display one value in an array and keep on getting a null value. Kindly could someone help me with this.

This is the array in $this->userfields  (invoice_items template VM3)

["volume2"]=>
array(8) {
["name"]=>
string(7) "volume2"
["value"]=>
string(6) "0.08m3"
["title"]=>
string(16) "Packaging Volume"
["type"]=>
string(4) "text"
["required"]=>
string(1) "0"
["hidden"]=>
bool(false)
["formcode"]=>
string(102) " "
["description"]=>
string(0) ""
}

I want to display the volume2 value on my invoice: I have tried
$this->userfields['volume2'] but this gives me a null result as well as $this->userfields['volume2']['value']

Regards,
MediaX
Title: Re: Display value in an array | Userfields
Post by: GJC Web Design on March 23, 2016, 14:00:41 PM
r u sure volume2 is an array?

try $this->userfields->volume2['value']

use print 'Debug Line '.__LINE__.' $this->userfields <pre>'; print_r ($this->userfields); print "</pre><br />\n";

to dump -- easier to see what it is
Title: Re: Display value in an array | Userfields
Post by: mediax on March 23, 2016, 14:44:46 PM
Hi GJC,

Thanks for assistance ... $this->userfields->volume2['value'] does not give me any value.  After looking at the output from the debug line you suggested I found that:

echo $this->userfields['fields']['volume2']['value'];

gave me the value I was looking for.

Thanks man,
MediaX