News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

[SOLVED] Display Product Image in Order View

Started by Graphos Srl, June 27, 2017, 14:35:41 PM

Previous topic - Next topic

Graphos Srl

hi,
I try to edit the file in www.mysite.it/template/my_template/html/com_virtuemart/orders/details_items.php


<?php
/**
*
* Order items view
*
* @package VirtueMart
* @subpackage Orders
* @author Oscar van Eijk, Valerie Isaksen
* @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: details_items.php 8310 2014-09-21 17:51:47Z Milbo $
*/

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');

if(
$this->format == 'pdf'){
$widthTable '100';
$widthTitle '27';
} else {
$widthTable '100';
$widthTitle '49';
}

?>

<h1 class="header"><span><?php echo vmText::_('COM_VIRTUEMART_ORDER_ITEM'); ?></span></h1>

<table class="table table-striped">
<tr>
<th width="5%"><?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_SKU'?></th>
<th width="15%"><?php echo vmText::('VM_LANG_CART_IMAGE'?></th>
<th width="40%" ><?php echo vmText::_('COM_VIRTUEMART_PRODUCT_NAME_TITLE'?></th>
<th width="10%"><?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_PRODUCT_STATUS'?></th>
<th width="10%"><?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_PRICE'?></th>
<th width="5%"><?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_QTY'?></th>
<th width="10%" style="text-align: right;"><?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_PRODUCT_TAX'?></th>
<th width="10%" style="text-align: right;"><?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_SUBTOTAL_DISCOUNT_AMOUNT'?></th>
<th width="10%" style="text-align: right;"><?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_TOTAL'?></th>
</tr>
<?php
foreach(
$this->orderdetails['items'] as $item) {
$qtt $item->product_quantity ;
$_link JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id=' $item->virtuemart_category_id '&virtuemart_product_id=' $item->virtuemart_product_idFALSE);

$img $item->images[0]->file_url_thumb $base_url $item->images[0]->file_url_thumb $base_url $item->images[0]->getFileUrlThumb();
?>


<tr>
<td>
<?php echo $item->order_item_sku?>
</td>
<td>
<a href="<?php echo $_link?>">
<img src="<?php echo $img?>" alt="<?php echo $item->product_name?>" />
</a>
</td>
<td>
<div><a href="<?php echo $_link?>"><?php echo $item->order_item_name?></a></div>
<?php
if(!class_exists('VirtueMartModelCustomfields'))require(VMPATH_ADMIN.DS.'models'.DS.'customfields.php');
$product_attribute VirtueMartModelCustomfields::CustomsFieldOrderDisplay($item,'FE');
echo $product_attribute;
?>

</td>
<td>
<?php echo $this->orderstatuses[$item->order_status]; ?>
</td>
<td>
<?php
$item->product_discountedPriceWithoutTax = (float) $item->product_discountedPriceWithoutTax;
if (!empty($item->product_priceWithoutTax) && $item->product_discountedPriceWithoutTax != $item->product_priceWithoutTax) {
echo '<span class="line-through">'.$this->currency->priceDisplay($item->product_item_price$this->currency) .'</span><br />';
echo '<span >'.$this->currency->priceDisplay($item->product_discountedPriceWithoutTax$this->currency) .'</span><br />';
} else {
echo '<span >'.$this->currency->priceDisplay($item->product_item_price$this->currency) .'</span><br />'
}
?>

</td>
<td>
<?php echo $qtt?>
</td>
<td align="right">
<?php echo "<span class='priceColor2'>".$this->currency->priceDisplay($item->product_tax ,$this->currency$qtt)."</span>" ?>
</td>
<td align="right">
<?php echo  $this->currency->priceDisplay$item->product_subtotal_discount ,$this->currency);  //No quantity is already stored with it ?>
</td>
<td align="right">
<?php
$item->product_basePriceWithTax = (float) $item->product_basePriceWithTax;
$class '';
if(!empty($item->product_basePriceWithTax) && $item->product_basePriceWithTax != $item->product_final_price ) {
echo '<span class="line-through" >'.$this->currency->priceDisplay($item->product_basePriceWithTax,$this->currency,$qtt) .'</span><br />' ;
}
elseif (empty($item->product_basePriceWithTax) && $item->product_item_price != $item->product_final_price) {
echo '<span class="line-through">' $this->currency->priceDisplay($item->product_item_price,$this->currency,$qtt) . '</span><br />';
}

echo $this->currency->priceDisplay(  $item->product_subtotal_with_tax ,$this->currency); //No quantity or you must use product_final_price ?>

</td>
</tr>
<?php ?>
<tr>
<td colspan="6" align="right">
<?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_PRODUCT_PRICES_TOTAL'); ?>
</td>
<td align="right">
<?php echo "<span  class='priceColor2'>".$this->currency->priceDisplay($this->orderdetails['details']['BT']->order_tax,$this->currency)."</span>" ?>
</td>
<td align="right">
<?php echo "<span  class='priceColor2'>".$this->currency->priceDisplay($this->orderdetails['details']['BT']->order_discountAmount,$this->currency)."</span>" ?>
</td>
<td align="right">
<?php echo $this->currency->priceDisplay($this->orderdetails['details']['BT']->order_salesPrice,$this->currency?>
</td>
  </tr>
<?php
if ($this->orderdetails['details']['BT']->coupon_discount <> 0.00) {
    $coupon_code=$this->orderdetails['details']['BT']->coupon_code?' ('.$this->orderdetails['details']['BT']->coupon_code.')':'';
?>

<tr>
<td align="right" colspan="6"><?php echo vmText::_('COM_VIRTUEMART_COUPON_DISCOUNT').$coupon_code ?></td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right"><?php echo $this->currency->priceDisplay($this->orderdetails['details']['BT']->coupon_discount,$this->currency); ?></td>
</tr>
<?php  ?>
<?php
foreach($this->orderdetails['calc_rules'] as $rule){
if ($rule->calc_kind== 'DBTaxRulesBill') { ?>

<tr >
<td align="right" colspan="6">
<?php echo $rule->calc_rule_name ?>
</td>
<td align="right">
</td>
<td align="right">
<?php echo  $this->currency->priceDisplay($rule->calc_amount,$this->currency); ?>
</td>
<td align="right">
<?php echo  $this->currency->priceDisplay($rule->calc_amount,$this->currency); ?>
</td>
</tr>
<?php
} elseif ($rule->calc_kind == 'taxRulesBill') { ?>

<tr >
<td align="right" colspan="6">
<?php echo $rule->calc_rule_name ?>
</td>
<td align="right">
<?php echo $this->currency->priceDisplay($rule->calc_amount,$this->currency); ?>
</td>
<td align="right">
</td>
<td align="right">
<?php echo $this->currency->priceDisplay($rule->calc_amount,$this->currency); ?>
</td>
</tr>
<?php
 } elseif ($rule->calc_kind == 'DATaxRulesBill') { ?>

<tr >
<td align="right" colspan="6">
<?php echo $rule->calc_rule_name ?>
</td>
<td align="right">
</td>
<td align="right">
<?php  echo   $this->currency->priceDisplay($rule->calc_amount,$this->currency);  ?>
</td>
<td align="right">
<?php echo $this->currency->priceDisplay($rule->calc_amount,$this->currency);  ?>
</td>
</tr>
<?php
 }
}
?>

<tr>
<td align="right" colspan="6">
<?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_SHIPPING'?>
</td>
<td align="right">
<?php echo "<span  class='priceColor2'>".$this->currency->priceDisplay($this->orderdetails['details']['BT']->order_shipment_tax$this->currency)."</span>" ?>
</td>
<td align="right">
</td>
<td align="right">
<?php echo $this->currency->priceDisplay($this->orderdetails['details']['BT']->order_shipment$this->orderdetails['details']['BT']->order_shipment_tax$this->currency); ?>
</td>
</tr>
<tr>
<td align="right" colspan="6">
<?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_PAYMENT'?>
</td>
<td align="right">
<?php echo "<span  class='priceColor2'>".$this->currency->priceDisplay($this->orderdetails['details']['BT']->order_payment_tax$this->currency)."</span>" ?>
</td>
<td align="right">
</td>
<td align="right">
<?php echo $this->currency->priceDisplay($this->orderdetails['details']['BT']->order_payment$this->orderdetails['details']['BT']->order_payment_tax$this->currency); ?>
</td>
</tr>
<tr>
<td align="right" colspan="6">
<strong><?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_TOTAL'?></strong>
</td>
<td align="right">
<?php echo $this->currency->priceDisplay($this->orderdetails['details']['BT']->order_billTaxAmount$this->currency); ?>
</td>
<td align="right">
<?php echo $this->currency->priceDisplay($this->orderdetails['details']['BT']->order_billDiscountAmount$this->currency); ?>
</td>
<td align="right">
<strong><?php echo $this->currency->priceDisplay($this->orderdetails['details']['BT']->order_total$this->currency); ?></strong>
</td>
</tr>
</table>


i add $img variable to write the link of image but give me an error, there is a way to display the image of ordered product?

Ghost

The images are not loaded in this view. Try this:

$productModel = VmModel::getModel('Product');
$productModel->addImages($this->orderdetails['items']);

Graphos Srl


Graphos Srl

OK Solved!
The right Code!!!!


<?php
/**
*
* Order items view
*
* @package VirtueMart
* @subpackage Orders
* @author Oscar van Eijk, Valerie Isaksen
* @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: details_items.php 8310 2014-09-21 17:51:47Z Milbo $
*/

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
$productModel VmModel::getModel('Product');
$productModel->addImages($this->orderdetails['items']);

if(
$this->format == 'pdf'){
$widthTable '100';
$widthTitle '27';
} else {
$widthTable '100';
$widthTitle '49';
}

?>

<h1 class="header"><span><?php echo vmText::_('COM_VIRTUEMART_ORDER_ITEM'); ?></span></h1>

<table class="table table-striped">
<tr>
<th width="5%"><?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_SKU'?></th>
<th width="15%"><?php echo vmText::('VM_LANG_CART_IMAGE'?></th>
<th width="40%" ><?php echo vmText::_('COM_VIRTUEMART_PRODUCT_NAME_TITLE'?></th>
<th width="10%"><?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_PRODUCT_STATUS'?></th>
<th width="10%"><?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_PRICE'?></th>
<th width="5%"><?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_QTY'?></th>
<th width="10%" style="text-align: right;"><?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_PRODUCT_TAX'?></th>
<th width="10%" style="text-align: right;"><?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_SUBTOTAL_DISCOUNT_AMOUNT'?></th>
<th width="10%" style="text-align: right;"><?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_TOTAL'?></th>
</tr>
<?php
foreach(
$this->orderdetails['items'] as $item) {
$qtt $item->product_quantity ;
$_link JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id=' $item->virtuemart_category_id '&virtuemart_product_id=' $item->virtuemart_product_idFALSE);

$img $item->images[0]->file_url_thumb $base_url $item->images[0]->file_url_thumb $base_url $item->images[0]->getFileUrlThumb();
?>


<tr>
<td>
<?php echo $item->order_item_sku?>
</td>
<td>
<a href="<?php echo $_link?>">
<img src="<?php echo $img?>" alt="<?php echo $item->product_name?>" />
</a>
</td>
<td>
<div><a href="<?php echo $_link?>"><?php echo $item->order_item_name?></a></div>
<?php
if(!class_exists('VirtueMartModelCustomfields'))require(VMPATH_ADMIN.DS.'models'.DS.'customfields.php');
$product_attribute VirtueMartModelCustomfields::CustomsFieldOrderDisplay($item,'FE');
echo $product_attribute;
?>

</td>
<td>
<?php echo $this->orderstatuses[$item->order_status]; ?>
</td>
<td>
<?php
$item->product_discountedPriceWithoutTax = (float) $item->product_discountedPriceWithoutTax;
if (!empty($item->product_priceWithoutTax) && $item->product_discountedPriceWithoutTax != $item->product_priceWithoutTax) {
echo '<span class="line-through">'.$this->currency->priceDisplay($item->product_item_price$this->currency) .'</span><br />';
echo '<span >'.$this->currency->priceDisplay($item->product_discountedPriceWithoutTax$this->currency) .'</span><br />';
} else {
echo '<span >'.$this->currency->priceDisplay($item->product_item_price$this->currency) .'</span><br />'
}
?>

</td>
<td>
<?php echo $qtt?>
</td>
<td align="right">
<?php echo "<span class='priceColor2'>".$this->currency->priceDisplay($item->product_tax ,$this->currency$qtt)."</span>" ?>
</td>
<td align="right">
<?php echo  $this->currency->priceDisplay$item->product_subtotal_discount ,$this->currency);  //No quantity is already stored with it ?>
</td>
<td align="right">
<?php
$item->product_basePriceWithTax = (float) $item->product_basePriceWithTax;
$class '';
if(!empty($item->product_basePriceWithTax) && $item->product_basePriceWithTax != $item->product_final_price ) {
echo '<span class="line-through" >'.$this->currency->priceDisplay($item->product_basePriceWithTax,$this->currency,$qtt) .'</span><br />' ;
}
elseif (empty($item->product_basePriceWithTax) && $item->product_item_price != $item->product_final_price) {
echo '<span class="line-through">' $this->currency->priceDisplay($item->product_item_price,$this->currency,$qtt) . '</span><br />';
}

echo $this->currency->priceDisplay(  $item->product_subtotal_with_tax ,$this->currency); //No quantity or you must use product_final_price ?>

</td>
</tr>
<?php ?>
<tr>
<td colspan="6" align="right">
<?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_PRODUCT_PRICES_TOTAL'); ?>
</td>
<td align="right">
<?php echo "<span  class='priceColor2'>".$this->currency->priceDisplay($this->orderdetails['details']['BT']->order_tax,$this->currency)."</span>" ?>
</td>
<td align="right">
<?php echo "<span  class='priceColor2'>".$this->currency->priceDisplay($this->orderdetails['details']['BT']->order_discountAmount,$this->currency)."</span>" ?>
</td>
<td align="right">
<?php echo $this->currency->priceDisplay($this->orderdetails['details']['BT']->order_salesPrice,$this->currency?>
</td>
  </tr>
<?php
if ($this->orderdetails['details']['BT']->coupon_discount <> 0.00) {
    $coupon_code=$this->orderdetails['details']['BT']->coupon_code?' ('.$this->orderdetails['details']['BT']->coupon_code.')':'';
?>

<tr>
<td align="right" colspan="6"><?php echo vmText::_('COM_VIRTUEMART_COUPON_DISCOUNT').$coupon_code ?></td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right"><?php echo $this->currency->priceDisplay($this->orderdetails['details']['BT']->coupon_discount,$this->currency); ?></td>
</tr>
<?php  ?>
<?php
foreach($this->orderdetails['calc_rules'] as $rule){
if ($rule->calc_kind== 'DBTaxRulesBill') { ?>

<tr >
<td align="right" colspan="6">
<?php echo $rule->calc_rule_name ?>
</td>
<td align="right">
</td>
<td align="right">
<?php echo  $this->currency->priceDisplay($rule->calc_amount,$this->currency); ?>
</td>
<td align="right">
<?php echo  $this->currency->priceDisplay($rule->calc_amount,$this->currency); ?>
</td>
</tr>
<?php
} elseif ($rule->calc_kind == 'taxRulesBill') { ?>

<tr >
<td align="right" colspan="6">
<?php echo $rule->calc_rule_name ?>
</td>
<td align="right">
<?php echo $this->currency->priceDisplay($rule->calc_amount,$this->currency); ?>
</td>
<td align="right">
</td>
<td align="right">
<?php echo $this->currency->priceDisplay($rule->calc_amount,$this->currency); ?>
</td>
</tr>
<?php
 } elseif ($rule->calc_kind == 'DATaxRulesBill') { ?>

<tr >
<td align="right" colspan="6">
<?php echo $rule->calc_rule_name ?>
</td>
<td align="right">
</td>
<td align="right">
<?php  echo   $this->currency->priceDisplay($rule->calc_amount,$this->currency);  ?>
</td>
<td align="right">
<?php echo $this->currency->priceDisplay($rule->calc_amount,$this->currency);  ?>
</td>
</tr>
<?php
 }
}
?>

<tr>
<td align="right" colspan="6">
<?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_SHIPPING'?>
</td>
<td align="right">
<?php echo "<span  class='priceColor2'>".$this->currency->priceDisplay($this->orderdetails['details']['BT']->order_shipment_tax$this->currency)."</span>" ?>
</td>
<td align="right">
</td>
<td align="right">
<?php echo $this->currency->priceDisplay($this->orderdetails['details']['BT']->order_shipment$this->orderdetails['details']['BT']->order_shipment_tax$this->currency); ?>
</td>
</tr>
<tr>
<td align="right" colspan="6">
<?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_PAYMENT'?>
</td>
<td align="right">
<?php echo "<span  class='priceColor2'>".$this->currency->priceDisplay($this->orderdetails['details']['BT']->order_payment_tax$this->currency)."</span>" ?>
</td>
<td align="right">
</td>
<td align="right">
<?php echo $this->currency->priceDisplay($this->orderdetails['details']['BT']->order_payment$this->orderdetails['details']['BT']->order_payment_tax$this->currency); ?>
</td>
</tr>
<tr>
<td align="right" colspan="6">
<strong><?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_TOTAL'?></strong>
</td>
<td align="right">
<?php echo $this->currency->priceDisplay($this->orderdetails['details']['BT']->order_billTaxAmount$this->currency); ?>
</td>
<td align="right">
<?php echo $this->currency->priceDisplay($this->orderdetails['details']['BT']->order_billDiscountAmount$this->currency); ?>
</td>
<td align="right">
<strong><?php echo $this->currency->priceDisplay($this->orderdetails['details']['BT']->order_total$this->currency); ?></strong>
</td>
</tr>
</table>