VirtueMart Forum

VirtueMart 2 + 3 + 4 => Administration & Configuration => Topic started by: ChristerE on March 25, 2012, 23:06:52 PM

Title: Custom Fields in Category View?
Post by: ChristerE on March 25, 2012, 23:06:52 PM
I've created a custom field with some color values, it shows at the product details-page, on the module page (featured products) BUT i can't get it to work on my category page :( Any suggestions??? Been at it for 3 hours now and all my testing has failed.

Thanks for any  ideas
Title: Re: Custom Fields in Category View?
Post by: John2400 on March 28, 2012, 04:46:07 AM
ChristerE
Hi - just wondering about what you are trying to do-
* You have set up a custom field that shows up correctly on the product details page - " so when I click on  a category " it jumps to that product and you can then see the product and the small options"custom values " show up against your product.
I then pick a colour and I can buy that product?
Is that correct ?  --

Your custom values will not show up against a category ?  This you cannot do as categories are simply links to products ? - I'm just restating what you have written. I am sorry if I have misquoted your problem.

maybe - show us an example by image .
Title: Re: Custom Fields in Category View?
Post by: stuart.prevos on May 23, 2012, 10:36:56 AM
I am having the same issue
VM 2.0.6
J2.6
I have some custom fields and want to display the custom fields in the category view but it aint working for me. I have pulled some code from the /views/productdetails/default.php and put it in /views/category/default.php, here is what I have
============
<?php
               if ($this->show_prices == '1') {
                  if( $product->product_unit && VmConfig::get('vm_price_show_packaging_pricelabel')) {
                     echo "<strong>". JText::_('COM_VIRTUEMART_CART_PRICE_PER_UNIT').' ('.$product->product_unit."):</strong>";
                  }
                  if(empty($product->prices) and VmConfig::get('askprice',1) and empty($product->images[0]->file_is_downloadable) ){
                     echo JText::_('COM_VIRTUEMART_PRODUCT_ASKPRICE');
                  }
                  //todo add config settings
                  if( $this->showBasePrice){
                     echo $this->currency->createPriceDiv('basePrice','COM_VIRTUEMART_PRODUCT_BASEPRICE',$product->prices);
                     echo $this->currency->createPriceDiv('basePriceVariant','COM_VIRTUEMART_PRODUCT_BASEPRICE_VARIANT',$product->prices);
                  }
                  echo $this->currency->createPriceDiv('variantModification','COM_VIRTUEMART_PRODUCT_VARIANT_MOD',$product->prices);
                  echo $this->currency->createPriceDiv('basePriceWithTax','COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX',$product->prices);
                  echo $this->currency->createPriceDiv('discountedPriceWithoutTax','COM_VIRTUEMART_PRODUCT_DISCOUNTED_PRICE',$product->prices);
                  echo $this->currency->createPriceDiv('salesPriceWithDiscount','COM_VIRTUEMART_PRODUCT_SALESPRICE_WITH_DISCOUNT',$product->prices);
                  echo $this->currency->createPriceDiv('salesPrice','COM_VIRTUEMART_PRODUCT_SALESPRICE',$product->prices);
                  echo $this->currency->createPriceDiv('priceWithoutTax','COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_TAX',$product->prices);
                  echo $this->currency->createPriceDiv('discountAmount','COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT',$product->prices);
                  echo $this->currency->createPriceDiv('taxAmount','COM_VIRTUEMART_PRODUCT_TAX_AMOUNT',$product->prices);
               } ?>
               
                <?php
               
                // ********** custom fields *****************//
                     <?php
                         } // Product custom_fields

                         if (!empty($this->product->customfieldsSorted['normal'])) {
                     $this->position = 'normal';
                     echo $this->loadTemplate('customfields');
                      } // Product custom_fields END               
                     
                     
                      // **********end of custom fields *****************//
                   ?>
               
               </div>
==============================
Thanks
Title: Re: Custom Fields in Category View?
Post by: John2400 on May 27, 2012, 03:58:40 AM
Hi guys,

I'm not really sure what you are trying to do But I read this today with some beautiful examples

try here and write back in this forum :
http://forum.virtuemart.net/index.php?topic=102918.0
Title: Re: Custom Fields in Category View?
Post by: Peter Pillen on October 07, 2012, 18:34:44 PM
the link in the last page doesn't really work. But I needed to show the custom field in the browse pages and I've managed to solve it in my case (I did it once before in VM1). In the image below you can see the result. It shows the values (shoesizes in this case) that belong to a specific product.

(http://desmond.imageshack.us/Himg9/scaled.php?server=9&filename=20121007175239.png&res=landing)

It requires some knowledge of php and mysql to transform the custom field in the final result you want, but maybe this can help you on the right way. I'm sorry for my messy programming and such... but it works :)

to show the custom fields in your category browse page edit this file /templates/"your template"/html/com_virtuemart/category/default.php  (depending on which template you are using this file location could be different) and place this code where you want to show the custom field. In my case I placed under the product short description.


<?php // Product Short Description
     
if(!empty($product->product_s_desc)) { ?>

     <p class="product_s_desc">
     <?php echo shopFunctionsF::limitStringByWord($product->product_s_desc40'...'?>
     </p>
     <?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"
     
$db->setQuery("SELECT custom_param FROM VM2_virtuemart_product_customfields WHERE virtuemart_product_id=".$product->virtuemart_product_id.";");
     
$db->query();
     
$result $db->loadResult();
 
//$result is the custom field output
// if you just need the custom field, you're done. I'll show how I did it to change the custom field to what I have

//check to see if there is a customfield mentioned
     
if(!empty($result)){
          
//remove all unwanted symbols (waste) from the string
          
$waste=array('{','}','"',':');
          
$clean_result=str_replace($waste,"",$result);
          
          
//detect and prepare the language label ... you can skip this if you don't need it
                    
$lang =& JFactory::getLanguage();
                    if(
$lang->getName()=="Dutch (NL)"){ $my_lang="nl"; }
                    if(
$lang->getName()=="French (fr-FR)"){ $my_lang="fr"; }
                    if(
$lang->getName()=="English (United Kingdom)"){ $my_lang="nl"; }
                    
$ta_nl="Maten: ";
                    
$ta_fr="Pointures: ";
                    
$ta_en="Sizes: ";
          
//language done
          
          //now make an array from the clean result: I have left the komma's in the string. This was not waste and i'm gonna use it now
          
$pieces explode(","$clean_result);
          
// make a p-tag for your custom field
          
echo "<p class=\"product_s_desc\">".${ta_.$my_lang};
          
// now echo all values from the clean result that we exploded into pieces and check if they are numeric... because these are the shoesizes
          
foreach($pieces as $size){
                    
$final_result=explode('[',$size);
                    if(
is_numeric($final_result[0])){
                              echo 
$final_result[0]." ";
                    }
          }
          unset(
$size);
          echo 
"</p>";
   }
?>


I have succesfully placed this code in a few files such as templates/"your template"/html/mod_virtuemart_product/default.php so that the custom fields are also seen on modules such as: latest products, featured products and so on.

I hope this helps
Title: Re: Custom Fields in Category View?
Post by: be on October 30, 2012, 20:21:15 PM
Hi,
I have done it like you but on my site there will not puplish but the enclosing span.


<?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"
$db->setQuery('SELECT custom_param FROM mzoex_virtuemart_product_customfields WHERE virtuemart_product_id='.$product->virtuemart_product_id.';');
$db->query();
$result $db->loadResult();
//$result is the custom field output
//check to see if there is a customfield mentioned
echo "<span class=\"product_s_desc\">".$result."</span>";  
?>


Normally it should be enough to call the variable $result to display the table content, or?
Is there another table who called similar like xxx_virtuemart_product_customfields?

BR

PS: Joomla 2.5.7 and Virtuemart 2.0.12f
Title: Re: Custom Fields in Category View?
Post by: Peter Pillen on October 30, 2012, 20:25:59 PM
Yep. $result should be enough to show the content of the custom parameters of that product. You should get the same value as you see in the database.

Are you sure that your database name is correct and that there is a custom parameter set for the product?
Title: Re: Custom Fields in Category View?
Post by: wanderschaft on November 02, 2012, 06:58:46 AM
The solution from Peter works great for me! Thanks.

some additional Information that may help. I found this when I tried your solution:

1. in first row of your code edit use "<? php {" instead of "<? php }", but I guess you wont need the brackets at all when you use just the first part

2. instead of hardcoded prefix in Database Name xxxx_virtuemart... use the general way #__virtuemart... (note 2 underscores)
3. I have more than one custom field per product. So maybe someone want to use a specific product custom field
a) find out the custom_field_id (simply by looking in phpMyAdmin in the custom field table or by looking in the Joomla backend in components>virtuemart>product>custom fields>ID Value at the last column) Note also that many custom field (like Strings oder HTML text fields use the custom_value (not param) to store the specific custom field information for a product like in my case a normal string wiht an additional Product ID/EAN Code. So I also changed the Query from custom_param to custom_value
             <?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 custom_value FROM #__virtuemart_product_customfields WHERE virtuemart_product_id=".$product->virtuemart_product_id." and virtuemart_custom_id=6 ;");  
     
$db->query();
     
$result $db->loadResult();
 echo "<span class=\"YourClass\">".$result."</span>";
?>


4. you may also use a div with a class to style the output via css, in this case I left the span, just put this or similar in your template css
.YourClass {
color: #ff0000;
}


Title: Re: Custom Fields in Category View?
Post by: be on November 02, 2012, 15:25:25 PM
Hi,
a big fat thankyou to you!
Now it works and the best is the part with the itemid this solves my problem.
What is the comparable var for the titleoutput of this itemid?
... virtuemart_product_id=".$product->virtuemart_product_id."

Best regard
Title: Re: Custom Fields in Category View?
Post by: amorino on December 09, 2012, 17:26:41 PM
Hello,
Thank you very much it solved me so many problem and worked like a charm every where ;)
Best regards
Amorino
Title: Re: Custom Fields in Category View?
Post by: Peter Pillen on December 09, 2012, 17:45:36 PM
A very good addition from wanderschaft.  ;)
Title: Re: Custom Fields in Category View?
Post by: squat on December 19, 2012, 15:35:42 PM

$db = JFactory::getDBO();

$query = $db->getQuery(true);
$query->select('custom_value');
$query->from('#__virtuemart_product_customfields');
$query->where('virtuemart_product_id="' . (int) $db->escape($product->virtuemart_product_id) . '"');
$query->where('virtuemart_custom_id="6"');

$db->setQuery($query);
$result = $db->loadResult();

echo "<span class=\"YourClass\">".$result."</span>";

Title: Re: Custom Fields in Category View?
Post by: PRO on December 19, 2012, 18:47:23 PM
I wrote a snippet of code to use my "internal notes" field as a category custom field

https://forum.virtuemart.net/index.php?topic=109549.0

Title: Re: Custom Fields in Category View?
Post by: Abigail Ritchie on February 01, 2013, 12:45:52 PM
Hi,
I'm brand new to virtuemart and have been trying to get this working for a few days with no joy at all,
really could do with some help please because I've run out of options.

virtuemart.2.0.12b
joomla 2.5.7

This is the code I'm using (same as above)
    $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 custom_value FROM #__virtuemart_product_customfields WHERE virtuemart_product_id=".$product->virtuemart_product_id." and virtuemart_custom_id=17 ;"); 
     $db->query();
     $result = $db->loadResult();
echo "<span class=\"YourClass\">".$result."</span>";
?>


Not sure If I should be adding anything else? I've checked the database out and everything corresponds.

Could it be that this no longer works with my current version of VM?

Abby
Title: Re: Custom Fields in Category View?
Post by: Peter Pillen on February 01, 2013, 13:10:13 PM
i'm not completely sure how to fix this for you. Your syntax seems correct...

1. are you 100% sure that you want to call the the custom_value and not the custom_param field?
2. i have joomla 2.5.8 and VM 2.018a and it still works
Title: Re: Custom Fields in Category View?
Post by: Abigail Ritchie on February 01, 2013, 15:14:03 PM
Thank you for replying Peter.

I'm using a string so assuming that value is correct according to your previous post's.

So I'm stumped and have no idea why it won't work??
Could it be where I'm placing the code in default.php(about line 120)?
Also, I have not moved the files to the joomla template folder yet, I planned on doing this later as I thought this was
only to avoid being overwritten on updates.... could this possibly be the reason?

Many thanks
Abby
Title: Re: Custom Fields in Category View?
Post by: Peter Pillen on February 01, 2013, 15:30:38 PM
maybe it is best to start from scratch

1. turn off your cache and clean it (system and others) so all changes are immediately visible.

2. always make a copy of the files you intend to change in that case, you can just put the old one back

3. If your not sure where to put the code or which file to use... use something like <? echo "I want it here"; ?> to locate the correct position in your file. If you see it popping up in the front-end where you want it to appear, then you already solved that problem.

There are 2 and more files that could need to be adapted
\templates\*your own template*\html\com_virtuemart\category\default.php --> for the vm category view in your own template
or
/components/com_virtuemart/views/category/tmpl/default.php --> if you use the default vm category template

same issue for your modules like "latest" products modules that you place elswhere
\modules\mod_virtuemart_category\tmpl\default.php --> if you are using the default module view from VM2

I think you need to locate the lines which creates the prices... look for the line if ($this->show_prices == '1') {. It is inside a <div>. Above that div, create a div like so

<div>
<? echo "I want it here"; ?>
</div>


And if you see it popping up above your price, you're good to go.

4. then try the database call again for your custom_value on that same location
Title: Re: Custom Fields in Category View?
Post by: Abigail Ritchie on February 01, 2013, 18:01:46 PM
Thanks Peter

I did everything you recommended, the <div><? echo "I want it here"; ?></div> did show in the correct place,
then I added the code, but nothing changed.
I've tried using the db prefix instead of "#__", and also creating different types of custom fields and using "param".
Just can't see where I'm going wrong???? Its driving me crazy!

Abby
Title: Re: Custom Fields in Category View?
Post by: Peter Pillen on February 01, 2013, 18:05:57 PM
can you try this exact code? it is extracted from my own file that works.

$db = JFactory::getDBO();
$db->setQuery("SELECT custom_param FROM #__virtuemart_product_customfields WHERE virtuemart_product_id=".$product->virtuemart_product_id.";");
$db->query();
$result = $db->loadResult();
echo $result;


don't go crazy!  ;D
Title: Re: Custom Fields in Category View?
Post by: Peter Pillen on February 03, 2013, 22:49:00 PM
The curious case of Abigail Ritchie  ;D

did you solve it?
Title: Re: Custom Fields in Category View?
Post by: Abigail Ritchie on February 04, 2013, 11:21:36 AM
Hi Peter,

ha ha, yes this is a very curious case!!! I had to take myself away from it for the weekend.
I did try the code you sent (thank you), but it didn't seem to make any difference at all.
I was wondering if.... maybe I PM you some login details maybe you could take a look, and I would
gladly make a donation to you through paypal for your time?
I just know I've tried everything, but probably through my lack of knowledge, have missed something stupid.

Abby
Title: Re: Custom Fields in Category View?
Post by: Abigail Ritchie on February 05, 2013, 13:45:53 PM
Can anyone help me?
Title: Re: Custom Fields in Category View?
Post by: Peter Pillen on February 05, 2013, 13:54:45 PM
i've sent you a personal message yesterday ;)

check the inbox on this forum
Title: Re: Custom Fields in Category View?
Post by: Peter Pillen on February 05, 2013, 16:33:14 PM
I think I solved your problem ;)

(https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcRGKOiBNj7DzF_cGyRwy9Q6sdrbz_NCPtIU1gALCMy9O8rgKQJavw)
Title: Re: Custom Fields in Category View?
Post by: AbsoluteVM on February 13, 2013, 12:53:35 PM
I found better results using the documentation:

http://docs.joomla.org/Accessing_the_database_using_JDatabase/2.5
http://docs.joomla.org/JDatabase::loadObjectList/11.1

<?php
// Get a db connection.
$db JFactory::getDbo();
 
// Create a new query object.
$query $db->getQuery(true);
 
// Select all records from the user profile table where key begins with "custom.".
// Order it by the ordering field.
$query->select(array('custom_value'));
$query->from('#__virtuemart_product_customfields');
$query->where('virtuemart_product_id='.$product->virtuemart_product_id);
$query->order('ordering ASC');
 
// Reset the query using our newly populated query object.
$db->setQuery($query);
 
// Load the results as a list of stdClass objects.
$results $db->loadObjectList();
// print_r($results);
echo '<ul>';
foreach (
$results as $result) {
    if(!empty(
$result->custom_value)) {
echo '<li>'.$result->custom_value.'</li>';
    }
}
echo 
'</ul>';
?>
Title: Re: Custom Fields in Category View?
Post by: AbsoluteVM on February 13, 2013, 13:55:08 PM
Hello,

I wanted to grab the custom_title aswell, so I modified my query with a LEFT join.


$query
    ->select(array('a.custom_value', 'a.virtuemart_custom_id','b.virtuemart_custom_id', 'b.custom_title'))
    ->from('#__virtuemart_product_customfields AS a')
    ->join('INNER', '#__virtuemart_customs AS b ON (a.virtuemart_custom_id = b.virtuemart_custom_id)')
->where('a.virtuemart_product_id='.$product->virtuemart_product_id)
    ->order('a.custom_value DESC');

// Reset the query using our newly populated query object.
$db->setQuery($query);

// Load the results as a list of stdClass objects.
$results = $db->loadObjectList();

// print_r($results);

echo '<ul>';
foreach ($results as $result) {
if(!empty($result->custom_value)) {
echo '<li><span>'.$result->custom_title.': </span>'.$result->custom_value.'</li>';
}
}
echo '</ul>';
?>
Title: Re: Custom Fields in Category View?
Post by: bakefrank on March 12, 2013, 19:58:35 PM
Hello I'm developing a site here:
You will need to login
UN: tester
pw: tester1!

http://gruverscafeandcatering.com/index.php/sandwiches

I'm trying to get the category display to show the custom fields I have created.

I have followed the instructions and code in this thread and have added the code:

$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 custom_value FROM #__virtuemart_product_customfields WHERE virtuemart_product_id=".$product->virtuemart_product_id." and virtuemart_custom_id=5 ;"); 
     $db->query();
     $result = $db->loadResult();
echo "<span class=\"YourClass\">".$result."</span>";
?>


to line 287 under Product Short description.

My problem is
It only shows one selection from the custom fields I have created.
So if you look under the product Subs it should have A custom field name Choose your sub and a drop down for custom fields for (american, Italian, Ham, turkey)

http://gruverscafeandcatering.com/index.php/sandwiches/sub-8-detail

However it does not show a drop selection as it does on the product page, it is only showing one field American:

THanks for all the help.


Title: Re: Custom Fields in Category View?
Post by: master_dk on March 22, 2013, 22:51:05 PM
I am trying to add custom fields and make them orderable from category view which i have edited. Tried this and many other suggestions and could not get it to work. Anyone have an idea of how to do it? This is my file in views/category/tmpl/default.php


<?php
/**
*
* Show the products in a category
*
* @package VirtueMart
* @subpackage
* @author RolandD
* @author Max Milbers
* @todo add pagination
* @link http://www.virtuemart.net
* @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* @version $Id: default.php 6053 2012-06-05 12:36:21Z Milbo $
*/

//vmdebug('$this->category',$this->category);
vmdebug('$this->category '.$this->category->category_name);
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
JHTML::_'behavior.modal' );
/* javascript for list Slide
  Only here for the order list
  can be changed by the template maker
*/
$js "
jQuery(document).ready(function () {
jQuery('.orderlistcontainer').hover(
function() { jQuery(this).find('.orderlist').stop().show()},
function() { jQuery(this).find('.orderlist').stop().hide()}
)
});
"
;

$document JFactory::getDocument();
$document->addScriptDeclaration($js);

/*$edit_link = '';
if(!class_exists('Permissions')) require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'permissions.php');
if (Permissions::getInstance()->check("admin,storeadmin")) {
$edit_link = '<a href="'.JURI::root().'index.php?option=com_virtuemart&tmpl=component&view=category&task=edit&virtuemart_category_id='.$this->category->virtuemart_category_id.'">
'.JHTML::_('image', 'images/M_images/edit.png', JText::_('COM_VIRTUEMART_PRODUCT_FORM_EDIT_PRODUCT'), array('width' => 16, 'height' => 16, 'border' => 0)).'</a>';
}

echo $edit_link; */

/* Show child categories */

if ( VmConfig::get('showCategory',1) and empty($this->keyword)) {
if ($this->category->haschildren) {

// Category and Columns Counter
$iCol 1;
$iCategory 1;

// Calculating Categories Per Row
$categories_per_row VmConfig::get 'categories_per_row');
$category_cellwidth ' width'.floor 100 $categories_per_row );

// Separator
$verticalseparator " vertical-separator";
?>




<?php }
}
?>

<div class="browse-view">
    <?php
if (!empty($this->keyword)) {
?>

<h3><?php echo $this->keyword?></h3>
<?php
?>

<?php if ($this->search !==null ) { ?>
    <form action="<?php echo JRoute::_('index.php?option=com_virtuemart&view=category&limitstart=0&virtuemart_category_id='.$this->category->virtuemart_category_id ); ?>" method="get">

    <!--BEGIN Search Box --><div class="virtuemart_search">
    <?php echo $this->searchcustom ?>
    <br />
    <?php echo $this->searchcustomvalues ?>
    <input name="keyword" class="inputbox" type="text" size="20" value="<?php echo $this->keyword ?>" />
    <input type="submit" value="<?php echo JText::_('COM_VIRTUEMART_SEARCH'?>" class="button" onclick="this.form.keyword.focus();"/>
    </div>
    <input type="hidden" name="search" value="true" />
    <input type="hidden" name="view" value="category" />

    </form>
<!-- End Search Box -->
<?php ?>

<?php // Show child categories
if (!empty($this->products)) {
?>



<h2><?php echo $this->category->category_name?></h2>

<?php
// Category and Columns Counter
$iBrowseCol 1;
$iBrowseProduct 1;

// Calculating Products Per Row
$BrowseProducts_per_row $this->perRow;
$Browsecellwidth ' width'.floor 100 $BrowseProducts_per_row );

// Separator
$verticalseparator " vertical-separator";

// Count products
$BrowseTotalProducts 0;
foreach ( 
$this->products as $product ) {
   
$BrowseTotalProducts ++;
}
?>


<table class="products">
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>

<?php
// Start the Output
foreach ( $this->products as $product ) {

// Show the horizontal seperator
if ($iBrowseCol == && $iBrowseProduct $BrowseProducts_per_row) { ?>

<div class="horizontal-separator"></div>
<?php }
?>



<tr>
<td align="left" width="20%"><?php  echo JHTML::link($product->link$product->product_name); ?></td>
<td align="left" width="60%"><?php // Product Short Description

     echo shopFunctionsF::limitStringByWord($product->product_s_desc100'...'?>

</td>
<td align="center" width="15%"><?php echo $this->currency->createPriceDiv('salesprice','COM_VIRTUEMART_PRODUCT_PRICE',$product->prices['salesPrice']); ?> </td>


<td align="right" width="5%">

<form method="post" class="product" action="index.php" id="addtocartproduct<?php echo $product->virtuemart_product_id ?>">


<div class="addtocart-bar">

<?php echo $this->product->virtuemart_product_id;?>
<span class="quantity-box">
<input type="text" class="quantity-input" name="quantity[]" value="1" />
</span>

<?php // Display the quantity box END ?>

<?php // Add the button
$button_lbl JText::_('COM_VIRTUEMART_CART_ADD_TO');
$button_cls ''//$button_cls = 'addtocart_button';
if (VmConfig::get('check_stock') == '1' && !$this->product->product_in_stock) {
$button_lbl JText::_('COM_VIRTUEMART_CART_NOTIFY');
$button_cls 'notify-button';
?>


<?php // Display the add to cart button ?>
<span class="addtocart-button">
<input type="submit" name="addtocart"  class="addtocart-button" value="<?php echo $button_lbl ?>" title="<?php echo $button_lbl ?>" />
</span>


</div>

<?php // Display the add to cart button END ?>
<input type="hidden" class="pname" value="<?php echo $product->product_name ?>">
<input type="hidden" name="option" value="com_virtuemart" />
<input type="hidden" name="view" value="cart" />
<noscript><input type="hidden" name="task" value="add" /></noscript>
<input type="hidden" name="virtuemart_product_id[]" value="<?php echo $product->virtuemart_product_id ?>" />
<?php /** @todo Handle the manufacturer view */ ?>
<input type="hidden" name="virtuemart_manufacturer_id" value="<?php echo $product->virtuemart_manufacturer_id ?>" />
<input type="hidden" name="virtuemart_category_id[]" value="<?php echo $product->virtuemart_category_id ?>" />
</form>
</td>


</tr>

<?php }
// end of foreach ( $this->products as $product )
?>




</table></div><!-- end browse-view -->
Title: Re: Custom Fields in Category View?
Post by: jloeza1818 on April 24, 2013, 20:49:17 PM
I'm Having the exact same issue as bakefrank it shows the customfields but is not showing the dropdown menu to select it. does anyone know how to fix this? Thank you.
Title: Re: Custom Fields in Category View?
Post by: PATSXM971 on July 31, 2013, 17:49:08 PM
Hi there,

for future user being able to find a more recent and reliable solution, see this topic
https://forum.virtuemart.net/index.php?topic=116058.msg397587#msg397587
Title: Re: Custom Fields in Category View?
Post by: dcsupp on November 25, 2013, 17:22:45 PM
I've used this code and works perfect adding a little change for logged-in users !

<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
Title: Re: Custom Fields in Category View?
Post by: Maxim Pishnyak on December 01, 2013, 15:14:32 PM
Custom fields already show on product page unless you use template overrides.