VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: Yashko on May 30, 2013, 16:02:30 PM

Title: select custom fields from category
Post by: Yashko on May 30, 2013, 16:02:30 PM
Hello!

I have custom field - "Size" for some products.
And i can choose it only on product page.
But i need this field on category view. And user can choose it from category page, and click "add to cart" ( i have this button on category) with choosed SIZE

Joomla 2.5
Vituemart 2.0.6

ps. sorry my english.
Title: Re: select custom fields from category
Post by: Yashko on May 30, 2013, 17:36:53 PM

<?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 '<select name="menu" size="1">';
foreach (
$results as $result) {
    if(!empty(
$result->custom_value)) {

echo 
'<option value="'.$result->custom_value.'">'.$result->custom_value.'</option>';
    }
}
echo 
'</select>';

?>

Im can see custom fields in CATEGORY page, but it not addings to my ORDER:(
Title: Re: select custom fields from category
Post by: PATSXM971 on July 31, 2013, 17:45:32 PM
Hi Yashko,

you can download the modified file here :
http://virtuemart.fr/extensions/extensions-disponibles/categories/bouton-ajouter-au-panier-sur-la-page-des-categories-gratuit-14-detail.html

unzip the folder ; you will find an html folder. Paste it there : yoursite_folder/templates/your_template/

it uses template overriding.

if you already have an html folder, then merge them. If you do not have modified your category/default.php before, it is ok.

If you already have an existing modified html/com_virtuemart/category/default.php or if you have bought a virtuemart template, then, compare the 2 default.php files and add the missing lines in your default.php template file

Hope it helps
Title: Re: select custom fields from category
Post by: Maxim Pishnyak on July 31, 2013, 20:54:43 PM
Quote from: PATSXM971 on July 31, 2013, 17:45:32 PM
Hope it helps
PATSXM, did you saw sticked thread in that forum section with the name "Add To Cart From Category [Solved]"?

I think you understand that addtocart button couldn't go without custom fields, right?

Why do you recommend here solution from your forum then? Instead of recommending ours?