News:

Looking for documentation? Take a look on our wiki

Main Menu

select custom fields from category

Started by Yashko, May 30, 2013, 16:02:30 PM

Previous topic - Next topic

Yashko

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.

Yashko


<?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:(

PATSXM971

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

Maxim Pishnyak

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?
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