Author Topic: Custom Fields in Category View?  (Read 44355 times)

dcsupp

  • Beginner
  • *
  • Posts: 7
Re: Custom Fields in Category View?
« Reply #30 on: November 25, 2013, 17:22:45 pm »
I've used this code and works perfect adding a little change for logged-in users !

Code: [Select]
<div>
<?php 
  
//MY EDIT STARTS HERE
 //make a database connection and find the field record that contains the customfield string
 $db JFactory::getDBO();
     
//please do check in php myadmin how your database table is called and replace it instead of "VM2_virtuemart_product_customfields" replace the "6" with your ID of Custom field you want to output
     
$db->setQuery("SELECT concat('TEXT',' ',custom_value) FROM #__virtuemart_product_customfields WHERE virtuemart_product_id=".$product->virtuemart_product_id." and virtuemart_custom_id=6 ;");  
     
$db->query();
     
$result $db->loadResult();

  $user JFactory::getUser();
$status $user->guest;
if (!$status == 1){
        echo 
"<div class=\"YOUR_CLASS_HERE\">".$result."</div>";
                 }
else
        {
        echo 
"<div></div>";
        }
 
 
?>

</div>

Can someone please tell me how can I make this work on the Product page ?
Thanks

Maxim Pishnyak

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 2664
Re: Custom Fields in Category View?
« Reply #31 on: December 01, 2013, 15:14:32 pm »
Custom fields already show on product page unless you use template overrides.
You can support Community by voting for Project on the JED
https://extensions.joomla.org/extension/virtuemart/#reviews
Join us at
https://twitter.com/virtuemart