VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: djgorandj on February 25, 2021, 12:12:39 PM

Title: How to add custom html in product detalis to all product in category
Post by: djgorandj on February 25, 2021, 12:12:39 PM
Need me insert popup images in product details like this picture, and add to all product in selected category? Any solution, tax have this options to assign to all product in category.

ps
my solution working bt need insert separatly custom fields to all product, lost time to add this.
Title: Re: How to add custom html in product detalis to all product in category
Post by: Jörgen on February 25, 2021, 12:25:36 PM
Create hidden parent product, insert the neccessary custum fields in parent. Child products inherit custom fileds etc from parent.

Add simply parent id in child product, connnection done.

Jörgen
Title: Re: How to add custom html in product detalis to all product in category
Post by: djgorandj on February 25, 2021, 12:56:53 PM
Good idea, any another solution like tax add to specific group?
Title: Re: How to add custom html in product detalis to all product in category
Post by: pinochico on February 25, 2021, 13:08:32 PM
Quotereate hidden parent product, insert the neccessary custum fields in parent. Child products inherit custom fileds etc from parent.

is it practical?


For add table for product detail from exactly category we use little change in PHP for product detail template in template override:
- first check category ID
- second - if category id is exactly from the list of defined categories == I will display my own html

something like

// #14663 - Condition for displaying tabs for category Wheels - https://crm.minion.cz/issues/14663
// HACK START - Ruda : for web kolo-park.cz
$category_tmp = '';
$class_tmp = '';
$category_kola = '742';
$category_elektrokola = '746';

$active_product_id = JRequest::getInt('virtuemart_product_id', 0);
$active_category_id = JRequest::getInt('virtuemart_category_id', 0);

$query = "SELECT virtuemart_category_id, virtuemart_product_id FROM #__virtuemart_product_categories WHERE virtuemart_product_id = " . $active_product_id;
//$db->setQuery($query);
$db = JFactory::getDBO();
$db->setQuery($query);
$categories = $db->loadObjectList();

foreach ($categories as $category) {
    if (($category->virtuemart_category_id == $category_kola) || ($category->virtuemart_category_id == $category_elektrokola)) {
        $category_tmp = $category->virtuemart_category_id;
        $class_tmp = " kola-tabs";
    }
}
// HACK END - Ruda : for web kolo-park.cz


if (($category_tmp == $category_kola) || ($category_tmp == $category_elektrokola)) {
   XXXXX - your html table
}