Add total quantity of products in invoice

  • Posts: 157
  • Thank you received: 2
10 years 5 months ago #158370

-- url of the page with the problem -- : mywebsite.com/mypage
-- HikaShop version -- :2.3.0
-- Joomla version -- : 2.5.20
Hello again :)

My client wants that the invoice that is sent to the customer shows in the subtotal row the quantity of products that is sent.
Is that possible?
So the customer can see in the subtotal row the quantity of products that is sent to him.
Thank you.
(attached view)

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
10 years 5 months ago #158373

Hello,

My client wants that the invoice that is sent to the customer shows in the subtotal row the quantity of products that is sent.

If you want to show the quantity of products in your order in the subtotal row, you'll have to edit the ''Invoice" file of the "order" view of your back-end template through "Hikashop->Display->Views" and change this line :
foreach($this->order->products as $product){
By :
$total_quantity = 0;
foreach($this->order->products as $product){
$total_quantity += $product->order_product_quantity;

And these lines :
<?php
                  if($this->config->get('price_with_tax')){
                    echo $this->currencyHelper->format($this->order->order_subtotal,$this->order->order_currency_id);
                  }else{
                    echo $this->currencyHelper->format($this->order->order_subtotal_no_vat,$this->order->order_currency_id);
                  } ?>
By :
  <?php
                  if($this->config->get('price_with_tax')){
                    echo $this->currencyHelper->format($this->order->order_subtotal,$this->order->order_currency_id);
                  }else{
                    echo $this->currencyHelper->format($this->order->order_subtotal_no_vat,$this->order->order_currency_id);
                  } 
                  echo 'for '.$total_quantity.' product(s)';
                  ?>

Please Log in or Create an account to join the conversation.

  • Posts: 157
  • Thank you received: 2
10 years 5 months ago #158489

Thanks. I' made the changes but nothing happened. :dry:
Do you have an idea why?

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
10 years 5 months ago #158590

My bad, I thought that you were talking about the invoice, but regarding the screenshot that you sent, you were talking about your email.
The solution will be directly edit the code of the "preload version" of your email through "Hikashop->System->Emails->Your emails"

Please Log in or Create an account to join the conversation.

  • Posts: 157
  • Thank you received: 2
10 years 5 months ago #158616

Ok, I edited it but not so good. I don't know what is the code for this. I write something like this:

<tr>
    <td colspan="3" style="text-align:right;color:#1c8faf !important;font-size:12px;font-weight:bold;">{LINEVAR:NAME}</td>
   <td style="text-align:right">{LINEVAR:TOTAL_QUANTITY}</td>
    <td style="text-align:right">{LINEVAR:VALUE}</td>
  </tr>
I attached what I got. I need the total of product to be only in the first row of the order footer. Can you please help me with this row?
Thanks!

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
10 years 5 months ago #158803

Hello,
The solution will just be to edit the "preload version" of your email and change these lines :

	foreach($data->cart->products as $item) {
		if($group && $item->order_product_option_parent_id)
			continue;

		$product = $productClass->products[$item->product_id];

		$cartProduct = array(
			'PRODUCT_CODE' => $item->order_product_code,
			'PRODUCT_QUANTIY' => $item->order_product_quantity,
			'PRODUCT_IMG' => '',
			'item' => $item,
			'product' => $product,
		);
By :
	$total_quantity = 0;
	foreach($data->cart->products as $item) {
		if($group && $item->order_product_option_parent_id)
			continue;

		$product = $productClass->products[$item->product_id];

		$cartProduct = array(
			'PRODUCT_CODE' => $item->order_product_code,
			'PRODUCT_QUANTIY' => $item->order_product_quantity,
			'PRODUCT_IMG' => '',
			'item' => $item,
			'product' => $product,
		);
		$total_quantity += $item->order_product_quantity;

And these lines :
	if(bccomp($data->cart->order_discount_price,0,5) || bccomp($data->cart->order_shipping_price,0,5) || bccomp($data->cart->order_payment_price,0,5) || ($data->cart->full_total->prices[0]->price_value!=$data->cart->full_total->prices[0]->price_value_with_tax) || !empty($data->cart->additional)){
		$cartFooters[] = array(
			'NAME' => JText::_('SUBTOTAL'),
			'VALUE' => $currencyHelper->format($subtotal,$data->cart->order_currency_id)
		);
	}
By :
	if(bccomp($data->cart->order_discount_price,0,5) || bccomp($data->cart->order_shipping_price,0,5) || bccomp($data->cart->order_payment_price,0,5) || ($data->cart->full_total->prices[0]->price_value!=$data->cart->full_total->prices[0]->price_value_with_tax) || !empty($data->cart->additional)){
		$cartFooters[] = array(
			'NAME' => JText::_('SUBTOTAL'),
			'VALUE' => $currencyHelper->format($subtotal,$data->cart->order_currency_id) . ' for '.$total_quantity.' product(s)'
		);
	}

The following user(s) said Thank You: Carolek

Please Log in or Create an account to join the conversation.

  • Posts: 14
  • Thank you received: 1
  • Hikashop Business
1 year 11 months ago #347152

Hi Mohamed

I should do the same thing for my customer but could't find these lines anywhere in the «preload version».

It is also a rather old post so maybe this isn't done the same way anymore.

The idea is to show the total quantity of products in the mails to admin and customer.

Is there a way to do that?

regards

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
1 year 11 months ago #347154

Hi,

While the code changed, it's still roughly the same. If you look carefully in the preload, you'll see the pieces of code, with slight differences and you can apply the changes.
For example, for the first piece of code, it is now:

foreach($data->cart->products as $item) {
		if($group && $item->order_product_option_parent_id)
			continue;

		$product = @$productClass->all_products[$item->product_id];

		$cartProduct = array(
			'PRODUCT_CODE' => $item->order_product_code,
			'PRODUCT_QUANTITY' => $item->order_product_quantity,
			'PRODUCT_IMG' => '',
			'item' => $item,
			'product' => $product,
		);
As you can see, there is only the line
$product = @$productClass->all_products[$item->product_id];
which is different.
So you can apply the same changes and you'll get:
	$total_quantity = 0;
	foreach($data->cart->products as $item) {
		if($group && $item->order_product_option_parent_id)
			continue;

		$product = @$productClass->all_products[$item->product_id];

		$cartProduct = array(
			'PRODUCT_CODE' => $item->order_product_code,
			'PRODUCT_QUANTITY' => $item->order_product_quantity,
			'PRODUCT_IMG' => '',
			'item' => $item,
			'product' => $product,
		);
		$total_quantity += $item->order_product_quantity;

And it's the same for the second code. It is now:
if(bccomp(sprintf('%F',$data->cart->order_discount_price),0,5) != 0 || bccomp(sprintf('%F',$data->cart->order_shipping_price),0,5) != 0 || bccomp(sprintf('%F',$data->cart->order_payment_price),0,5) != 0 || ($data->cart->full_total->prices[0]->price_value!=$data->cart->full_total->prices[0]->price_value_with_tax) || !empty($data->cart->additional)){
		$cartFooters[] = array(
			'CLASS' => 'subtotal',
			'NAME' => JText::_('SUBTOTAL'),
			'VALUE' => $currencyHelper->format($subtotal,$data->cart->order_currency_id)
		);
	}
as you can see, it's only the first line which change and thus you can still change the line:
'VALUE' => $currencyHelper->format($subtotal,$data->cart->order_currency_id)
to:
'VALUE' => $currencyHelper->format($subtotal,$data->cart->order_currency_id) . ' for '.$total_quantity.' product(s)'

Please Log in or Create an account to join the conversation.

  • Posts: 14
  • Thank you received: 1
  • Hikashop Business
1 year 11 months ago #347175

Hi Mohamed

Thank you.

I got this to work with your code and it calculates the total quantity of ordered items correctly.

However, it puts the value in the Discount (Rabatt), and it is also labeled Discount (Rabatt).

Is it not possible to make a separate line for this: i.e. Total Items 25

The customer gets the mail correctly with the proper discount.

regards


Attachments:
Last edit: 1 year 11 months ago by deboni.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
1 year 11 months ago #347176

Hi,

If you have it added to the discount it means that you didn't do the last change properly.
So revert that last change.
Instead, you can add:

$cartFooters[] = array(
			'CLASS' => 'quantity',
			'NAME' => 'Total quantity',
			'VALUE' =>$total_quantity
		);
before the code:
$cartFooters[] = array(
			'CLASS' => 'subtotal',
			'NAME' => JText::_('SUBTOTAL'),
			'VALUE' => $currencyHelper->format($subtotal,$data->cart->order_currency_id)
		);
and it will be added as an extra line before the subtotal.

Please Log in or Create an account to join the conversation.

  • Posts: 14
  • Thank you received: 1
  • Hikashop Business
1 year 11 months ago #347511

Hi Mohamed

thanks! That worked now.

The customer would like to show that value somewhere near the top. Is it even possible to show it somewhere else or can that only be done in the footer?

regards

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
1 year 11 months ago #347514

Hi,

It would be great if you could explain precisely what you want from the start next time.

It can be done yes.
Before the line:

$cartFooters[] = array(
add the code:
$vars['TOTAL_QUANTITY'] = $total_quantity;
Then, you can use the tag {VAR:TOTAL_QUANTITY} in the HTML area to place the total quantity wherever you want in the email.

Please Log in or Create an account to join the conversation.

  • Posts: 14
  • Thank you received: 1
  • Hikashop Business
1 year 11 months ago #347532

Thank you very much and sorry for the inconvenience.

I'm trying to avoid this with my customers and in this case I couldn't avoid it.

It works great now!

regards

Please Log in or Create an account to join the conversation.

Time to create page: 0.126 seconds
Powered by Kunena Forum