News:

Looking for documentation? Take a look on our wiki

Main Menu

Moving Product Description

Started by urbanj, September 12, 2019, 18:03:46 PM

Previous topic - Next topic

urbanj

Hi I am trying to move the main description from the bottom to the right of the product  image (above the add to cart button)  on the product detail page.

I have done a lot of Googling but all it is throwing up is posts for old versions of VM and a few that are for VM3 but very confusing.

Does anyone have a definitive and up to date tutorial they can link me to please?

Thank you!

jenkinhill

You don't say which VM version you use, which template or URL.

Basically, you need to edit and override components/com_virtuemart/views/productdetails/tmpl/default.php  - and maybe some of the sublayouts - to get your required layout.

But if already using overrides, as in a commercial template, then the file to edit will be templates/[yourJoomlaTemplate]/html/com_virtuemart/productdetails/default.php
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

urbanj

Thank you, I am using Helix Ultimate and VM 3 so I assume I will use the second method?

Is it just a case of finding the code the displays the description and moving it further to the top? Or is it more complicated than that. I am not hot on PHP


Jörgen

It is almost as easy as that, depends on how the template renders the product page. Could have to add a div or something similar to keep it together. If You aren´t hot on Php you can get syntax errors that will break Your site. Test on a backup copy.

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

urbanj

Thanks Jörgen, This is the code I am seeing. Do you know which bit displays the product description?  I can see where it ends (as it is labeled) but unsure where it starts.

Thanks again for your help gents

<?php
/**
 *
 * Show the product details page
 *
 * @package VirtueMart
 * @subpackage
 * @author Max Milbers, Eugen Stranz, Max Galt
 * @link https://virtuemart.net
 * @copyright Copyright (c) 2004 - 2014 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 9774 2018-03-06 20:43:19Z StefanSTS $
 */
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');

/* Let's see if we found the product */
if (empty($this->product)) {
echo vmText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND');
echo '<br /><br />  ' $this->continue_link_html;
return;
}

echo 
shopFunctionsF::renderVmSubLayout('askrecomjs',array('product'=>$this->product));



if(
vRequest::getInt('print',false)){ ?>

<body onload="javascript:print();">
<?php ?>

<div class="product-container productdetails-view productdetails">

<?php
// Product Navigation
if (VmConfig::get('product_navigation'1)) {
?>

<div class="product-neighbours">
<?php
if (!empty($this->product->neighbours ['previous'][0])) {
$prev_link JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' $this->product->neighbours ['previous'][0] ['virtuemart_product_id'] . '&virtuemart_category_id=' $this->product->virtuemart_category_idFALSE);
echo JHtml::_('link'$prev_link$this->product->neighbours ['previous'][0]
['product_name'], array('rel'=>'prev''class' => 'previous-page','data-dynamic-update' => '1'));
}
if (!empty($this->product->neighbours ['next'][0])) {
$next_link JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' $this->product->neighbours ['next'][0] ['virtuemart_product_id'] . '&virtuemart_category_id=' $this->product->virtuemart_category_idFALSE);
echo JHtml::_('link'$next_link$this->product->neighbours ['next'][0] ['product_name'], array('rel'=>'next','class' => 'next-page','data-dynamic-update' => '1'));
}
?>

<div class="clear"></div>
</div>
<?php // Product Navigation END
?>


<?php // Back To Category Button
if ($this->product->virtuemart_category_id) {
$catURL =  JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$this->product->virtuemart_category_idFALSE);
$categoryName vmText::_($this->product->category_name) ;
} else {
$catURL =  JRoute::_('index.php?option=com_virtuemart');
$categoryName vmText::_('COM_VIRTUEMART_SHOP_HOME') ;
}
?>

<div class="back-to-category">
<a href="<?php echo $catURL ?>" class="product-details" title="<?php echo $categoryName ?>"><?php echo vmText::sprintf('COM_VIRTUEMART_CATEGORY_BACK_TO',$categoryName?></a>
</div>

<?php // Product Title   ?>
<h1><?php echo $this->product->product_name ?></h1>
<?php // Product Title END   ?>

<?php // afterDisplayTitle Event
echo $this->product->event->afterDisplayTitle ?>


<?php
// Product Edit Link
echo $this->edit_link;
// Product Edit Link END
?>


<?php
// PDF - Print - Email Icon
if (VmConfig::get('show_emailfriend') || VmConfig::get('show_printicon') || VmConfig::get('pdf_icon')) {
?>

<div class="icons">
<?php

$link 'index.php?tmpl=component&option=com_virtuemart&view=productdetails&virtuemart_product_id=' $this->product->virtuemart_product_id;

echo $this->linkIcon($link '&format=pdf''COM_VIRTUEMART_PDF''pdf_button''pdf_icon'false);
//echo $this->linkIcon($link . '&print=1', 'COM_VIRTUEMART_PRINT', 'printButton', 'show_printicon');
echo $this->linkIcon($link '&print=1''COM_VIRTUEMART_PRINT''printButton''show_printicon',false,true,false,'class="printModal"');
$MailLink 'index.php?option=com_virtuemart&view=productdetails&task=recommend&virtuemart_product_id=' $this->product->virtuemart_product_id '&virtuemart_category_id=' $this->product->virtuemart_category_id '&tmpl=component';
echo $this->linkIcon($MailLink'COM_VIRTUEMART_EMAIL''emailButton''show_emailfriend'false,true,false,'class="recommened-to-friend"');
?>

<div class="clear"></div>
</div>
<?php // PDF - Print - Email Icon END
?>


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

<div class="product-short-description">
<?php
/** @todo Test if content plugins modify the product description */
echo nl2br($this->product->product_s_desc);
?>

</div>
<?php
// Product Short Description END

echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'ontop'));
?>


<div class="vm-product-container">
<div class="vm-product-media-container">
<?php
echo $this->loadTemplate('images');
?>

</div>

<div class="vm-product-details-container">
<div class="spacer-buy-area">

<?php
// TODO in Multi-Vendor not needed at the moment and just would lead to confusion
/* $link = JRoute::_('index2.php?option=com_virtuemart&view=virtuemart&task=vendorinfo&virtuemart_vendor_id='.$this->product->virtuemart_vendor_id);
  $text = vmText::_('COM_VIRTUEMART_VENDOR_FORM_INFO_LBL');
  echo '<span class="bold">'. vmText::_('COM_VIRTUEMART_PRODUCT_DETAILS_VENDOR_LBL'). '</span>'; ?>
<a class="modal" href="<?php echo $link ?>"><?php echo $text ?></a><br />
*/
?>

<?php
echo shopFunctionsF::renderVmSubLayout('rating', array('showRating' => $this->showRating'product' => $this->product));

foreach ($this->productDisplayTypes as $type=>$productDisplayType) {

foreach ($productDisplayType as $productDisplay) {

foreach ($productDisplay as $virtuemart_method_id =>$productDisplayHtml) {
?>

<div class="<?php echo substr($type0, -1?> <?php echo substr($type0, -1).'-'.$virtuemart_method_id ?>">
<?php
echo $productDisplayHtml;
?>

</div>
<?php
}
}
}

//In case you are not happy using everywhere the same price display fromat, just create your own layout
//in override /html/fields and use as first parameter the name of your file
echo shopFunctionsF::renderVmSubLayout('prices',array('product'=>$this->product,'currency'=>$this->currency));
?>
<div class="clear"></div><?php
echo shopFunctionsF::renderVmSubLayout('addtocart',array('product'=>$this->product));

echo shopFunctionsF::renderVmSubLayout('stockhandle',array('product'=>$this->product));

// Ask a question about this product
if (VmConfig::get('ask_question'0) == 1) {
$askquestion_url JRoute::_('index.php?option=com_virtuemart&view=productdetails&task=askquestion&virtuemart_product_id=' $this->product->virtuemart_product_id '&virtuemart_category_id=' $this->product->virtuemart_category_id '&tmpl=component'FALSE);
?>

<div class="ask-a-question">
<a class="ask-a-question" href="<?php echo $askquestion_url ?>" rel="nofollow" ><?php echo vmText::_('COM_VIRTUEMART_PRODUCT_ENQUIRY_LBL'?></a>
</div>
<?php
}
?>


<?php
// Manufacturer of the Product
if (VmConfig::get('show_manufacturers'1) && !empty($this->product->virtuemart_manufacturer_id)) {
echo $this->loadTemplate('manufacturer');
}
?>


</div>
</div>
<div class="clear"></div>


</div>
<?php
$count_images count ($this->product->images);
if ($count_images 1) {
echo $this->loadTemplate('images_additional');
}

// event onContentBeforeDisplay
echo $this->product->event->beforeDisplayContent?>


<?php
//echo ($this->product->product_in_stock - $this->product->product_ordered);
// Product Description
if (!empty($this->product->product_desc)) {
?>

<div class="product-description" >
<?php /** @todo Test if content plugins modify the product description */ ?>
<span class="title"><?php echo vmText::_('COM_VIRTUEMART_PRODUCT_DESC_TITLE'?></span>
<?php echo $this->product->product_desc?>
</div>
<?php
// Product Description END

echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'normal'));

// Product Packaging
$product_packaging '';
if ($this->product->product_box) {
?>

<div class="product-box">
<?php
echo vmText::_('COM_VIRTUEMART_PRODUCT_UNITS_IN_BOX') .$this->product->product_box;
?>

</div>
<?php // Product Packaging END ?>

<?php
echo 
shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'onbot'));

echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'related_products','class'=> 'product-related-products','customTitle' => true ));

echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'related_categories','class'=> 'product-related-categories'));

?>


<?php // onContentAfterDisplay event
echo $this->product->event->afterDisplayContent;

echo 
$this->loadTemplate('reviews');

// Show child categories
if ($this->cat_productdetails)  {
echo $this->loadTemplate('showcategory');
}

$j 'jQuery(document).ready(function($) {
$("form.js-recalculate").each(function(){
if ($(this).find(".product-fields").length && !$(this).find(".no-vm-bind").length) {
var id= $(this).find(\'input[name="virtuemart_product_id[]"]\').val();
Virtuemart.setproducttype($(this),id);

}
});
});'
;
//vmJsApi::addJScript('recalcReady',$j);

if(VmConfig::get ('jdynupdate'TRUE)){

/** GALT
 * Notice for Template Developers!
 * Templates must set a Virtuemart.container variable as it takes part in
 * dynamic content update.
 * This variable points to a topmost element that holds other content.
 */
$j "Virtuemart.container = jQuery('.productdetails-view');
Virtuemart.containerSelector = '.productdetails-view';
//Virtuemart.recalculate = true; //Activate this line to recalculate your product after ajax
"
;

vmJsApi::addJScript('ajaxContent',$j);

$j "jQuery(document).ready(function($) {
Virtuemart.stopVmLoading();
var msg = '';
$('a[data-dynamic-update=\"1\"]').off('click', Virtuemart.startVmLoading).on('click', {msg:msg}, Virtuemart.startVmLoading);
$('[data-dynamic-update=\"1\"]').off('change', Virtuemart.startVmLoading).on('change', {msg:msg}, Virtuemart.startVmLoading);
});"
;

vmJsApi::addJScript('vmPreloader',$j);
}

echo 
vmJsApi::writeJS();

if (
$this->product->prices['salesPrice'] > 0) {
echo shopFunctionsF::renderVmSubLayout('snippets',array('product'=>$this->product'currency'=>$this->currency'showRating'=>$this->showRating));
}

?>

</div>

GJC Web Design

// Product Description
   if (!empty($this->product->product_desc)) {
      ?>
      <div class="product-description" >
   <?php /** @todo Test if content plugins modify the product description */ ?>
      <span class="title"><?php echo vmText::_('COM_VIRTUEMART_PRODUCT_DESC_TITLE') ?></span>
   <?php echo $this->product->product_desc; ?>
      </div>
   <?php
   } // Product Description END
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

urbanj

Thank you for this. it seems wherever i put it, it throws an error message - syntax error, unexpected '}', expecting end of file - when i try to place it in the php file. I am trying to get it to appear above the price area.

Am i doing anything obviously wrong?

Jörgen

This is a php syntax error. You have to match curly brackets. This goes for the <?php also. Otherwise the page breaks.
Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

urbanj

Done! thanks for your help everyone!  :)