Author Topic: How to show product on its own line with quantity 2 or more  (Read 300 times)

Huubs

  • Jr. Member
  • **
  • Posts: 96
How to show products that are the same but with quantity 2 or higher on its own line?

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 26908
  • Always on vacation
    • Jenkin Hill Internet
Re: How to show product on its own line with quantity 2 or more
« Reply #1 on: July 03, 2018, 18:35:35 pm »
From that description it is not clear what you want to do.
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

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

Currently using VM.3.2.15.9866 on Joomla 3.8.10 PHP 7.0.30

Testing VM.3.2.15.9898 on J3.8.10

Jörgen

  • Global Moderator
  • Full Member
  • *
  • Posts: 1539
    • Kreativ Fotografi
  • VirtueMart Version: 3.2.12
Re: How to show product on its own line with quantity 2 or more
« Reply #2 on: July 03, 2018, 19:15:58 pm »
I guess You want to display quantity pricing. It is not standard, but some templates have this feature, for example Hera from olympian themes.
Maybe someone will share code for this, otherwise is the that template not very expensive and has a lot of features.

regards

Jörgen @ Kreativ Fotografi
Joomla 3.8.3
Virtuemart 3.2.12
Olympiantheme Hera (customized)

Huubs

  • Jr. Member
  • **
  • Posts: 96
Re: How to show product on its own line with quantity 2 or more
« Reply #3 on: July 03, 2018, 21:14:57 pm »
From that description it is not clear what you want to do.

Sorry I should've been clearer.

Right now my invoice list every product on its own line, for example:

Product - Quantity - Price

Shoe - 1 - 10,95

Now when the quantity is 2 the quantity gets that number:

Shoe - 2 - 21,90

What I want is that instead of the 2 in the quantity I just want the Shoe to get its own line on the invoice:

Shoe - 1 - 10,95
Shoe - 1 - 10,95

I want to know if that is possible and how to do that.

I guess You want to display quantity pricing. It is not standard, but some templates have this feature, for example Hera from olympian themes.
Maybe someone will share code for this, otherwise is the that template not very expensive and has a lot of features.

regards

Jörgen @ Kreativ Fotografi

No, I don't think so, but that could be, see  above what I want exactly. Thanks.

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3152
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: How to show product on its own line with quantity 2 or more
« Reply #4 on: July 03, 2018, 23:03:07 pm »
The only solution i see is to modify the PHP code in cart, but you need to do it in the order too.

Huubs

  • Jr. Member
  • **
  • Posts: 96
Re: How to show product on its own line with quantity 2 or more
« Reply #5 on: July 04, 2018, 09:44:19 am »
The only solution i see is to modify the PHP code in cart, but you need to do it in the order too.
Isn't it possible to only change the template for the invoice for example?

I only want this on my invoice, in the shop and administrator part of my website it's good how it works right now.

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3152
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: How to show product on its own line with quantity 2 or more
« Reply #6 on: July 04, 2018, 11:06:16 am »
then do a template override for virtuemart order items

Huubs

  • Jr. Member
  • **
  • Posts: 96
Re: How to show product on its own line with quantity 2 or more
« Reply #7 on: July 04, 2018, 12:44:27 pm »
then do a template override for virtuemart order items

Can you point me in where I must be, and how to do this?

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3152
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: How to show product on its own line with quantity 2 or more
« Reply #8 on: July 04, 2018, 17:23:10 pm »
override \components\com_virtuemart\views\orders\tmpl\details_items.php
See doc https://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core
The code is too long to write, so check to do it yourself

Huubs

  • Jr. Member
  • **
  • Posts: 96
Re: How to show product on its own line with quantity 2 or more
« Reply #9 on: July 05, 2018, 11:10:05 am »
override \components\com_virtuemart\views\orders\tmpl\details_items.php
See doc https://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core
The code is too long to write, so check to do it yourself
Ok, thanks for pointing me in the right direction. Funny thing is, the changes don't do anything to the PDF output. I have tried to change the PHP file above. But that didn't work. I also tried to change the /invoice/invoice_items.php but that didn't work either:

Code: [Select]
foreach($this->orderDetails['items'] as $item) {
$qtt = $item->product_quantity ;
$product_link = JURI::root().'index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id=' . $item->virtuemart_category_id .
'&virtuemart_product_id=' . $item->virtuemart_product_id . '&Itemid=' . $menuItemID;

if($qtt > 1){

for($i = 0; $i < $qtt; $i++){ ?>
<tr valign="top">
<td align="left">
<?php echo $item->order_item_sku?>
</td>
<td align="left" colspan="2" >
<div float="right" ><a href="<?php echo $product_link?>"><?php echo $item->order_item_name?></a></div>
<?php
//if (!empty($item->product_attribute)) {
if(!class_exists('VirtueMartModelCustomfields'))require(VMPATH_ADMIN.DS.'models'.DS.'customfields.php');
$product_attribute VirtueMartModelCustomfields::CustomsFieldOrderDisplay($item,'FE');
echo $product_attribute;
//}
?>

</td>
<td align="center">
<?php echo $this->orderstatuses[$item->order_status]; ?>
</td>
<?php if ($this->doctype == 'invoice') { ?>
<td align="right"   class="priceCol" >
<?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>
<?php ?>
<td align="right" >
<?php echo "1"?>
</td>
<?php if ($this->doctype == 'invoice') { ?>
<?php if ( VmConfig::get('show_tax')) { ?>
<td align="right" class="priceCol"><?php echo "<span  class='priceColor2'>".$this->currency->priceDisplay($item->product_tax ,$this->currency$qtt)."</span>" ?></td>
                                <?php ?>

<td align="right"  class="priceCol">
<?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>
<?php ?>
</tr> <?
}

} else { ?>

<tr valign="top">
<td align="left">
<?php echo $item->order_item_sku?>
</td>
<td align="left" colspan="2" >
<div float="right" ><a href="<?php echo $product_link?>"><?php echo $item->order_item_name?></a></div>
<?php
//if (!empty($item->product_attribute)) {
if(!class_exists('VirtueMartModelCustomfields'))require(VMPATH_ADMIN.DS.'models'.DS.'customfields.php');
$product_attribute VirtueMartModelCustomfields::CustomsFieldOrderDisplay($item,'FE');
echo $product_attribute;
//}
?>

</td>
<td align="center">
<?php echo $this->orderstatuses[$item->order_status]; ?>
</td>
<?php if ($this->doctype == 'invoice') { ?>
<td align="right"   class="priceCol" >
<?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>
<?php ?>
<td align="right" >
<?php echo $qtt?>
</td>
<?php if ($this->doctype == 'invoice') { ?>
<?php if ( VmConfig::get('show_tax')) { ?>
<td align="right" class="priceCol"><?php echo "<span  class='priceColor2'>".$this->currency->priceDisplay($item->product_tax ,$this->currency$qtt)."</span>" ?></td>
                                <?php ?>

<td align="right"  class="priceCol">
<?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>
<?php ?>
</tr>

<? }



?>

What am I doing wrong or forgetting for that matter?

EDIT: So I checked the Delivery Note, and that is now displaying every product on its own line! Now only the invoice needs to be changed. Looks like the Delivery Note is the only thing that gets the code from the file i changed, that means the actual PDF code is generated elsewhere. I cannot find where though.

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3152
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 &amp; 3.0.x.y
Re: How to show product on its own line with quantity 2 or more
« Reply #10 on: July 05, 2018, 11:29:52 am »
You don't spoke about PDF
See \components\com_virtuemart\views\invoice\tmpl\invoice_items.php, this should be the file to render the PDF and print view items

Huubs

  • Jr. Member
  • **
  • Posts: 96
Re: How to show product on its own line with quantity 2 or more
« Reply #11 on: July 05, 2018, 11:43:41 am »
You don't spoke about PDF
See \components\com_virtuemart\views\invoice\tmpl\invoice_items.php, this should be the file to render the PDF and print view items

I did change that part as well, but the PDF is still being made as is.

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3152
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 &amp; 3.0.x.y
Re: How to show product on its own line with quantity 2 or more
« Reply #12 on: July 05, 2018, 12:08:46 pm »
A simple question.
Do you delete the original file each time you do a new test ?
If not the rendered PDF is from the file saved in your secured folder

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3152
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 &amp; 3.0.x.y
Re: How to show product on its own line with quantity 2 or more
« Reply #13 on: July 05, 2018, 12:13:55 pm »
I checked exactly.
This is the function called in admin
   public function callInvoiceView(){

      if(!class_exists( 'VirtueMartControllerInvoice' )) require(VMPATH_SITE.DS.'controllers'.DS.'invoice.php');
      $controller = new VirtueMartControllerInvoice();
      $controller->display();

   }
So the used view is invoice
In invoice controller display, it load invoice layout and invoice_items is the part redenring the items(products)

Huubs

  • Jr. Member
  • **
  • Posts: 96
Re: How to show product on its own line with quantity 2 or more
« Reply #14 on: July 18, 2018, 10:06:42 am »
Got it working. Already generated invoices are not touched, but new invoices are rightly generated now.