VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: guardiano78 on June 27, 2017, 13:00:04 PM

Title: how to detect if "custom field" used
Post by: guardiano78 on June 27, 2017, 13:00:04 PM
Hello,
i need to detect if customfield in present in product detail page.

I set custom field "Plugin" like "textinput".
in productdetails\default.php i need to know if that customfield is present.

How can i do this?
Thanks!!

joomla 3.7.2 and virtuemart 3.2.2
Title: Re: how to detect if "custom field" used
Post by: guardiano78 on June 27, 2017, 15:50:12 PM
when i print $this->product->customfields, i see that:
1. if product has custom field the variable is empty
2. if product has not custom field the variable contains Array()

well, i tried with this:

if (!isset($this->product->customfields))
{
    //do something...
}
else
{
   //do something else ....
}


In you opinion this code may work fine?

Thanks
Title: Re: how to detect if "custom field" used
Post by: PRO on June 27, 2017, 17:45:27 PM


I use this, IT CHECKS BY POSITION

if (!empty($this->product->customfieldsSorted['MY-POSITION'])) {
// Do something here
}
Title: Re: how to detect if "custom field" used [SOLVED]
Post by: guardiano78 on June 27, 2017, 17:57:05 PM
very well!!
Thank you so much!