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

Total number of products on order

Started by 2cool, June 01, 2017, 14:49:19 PM

Previous topic - Next topic

2cool

Is it possible to add the total number of products at the order? this would help a lot for order picking.

What php code can be used and in which file?

Using vm 3.2 and joomla 3.7.2

Thanks,
Pas

K&K media production

Should be possible with a core hack or develop a vm extended plugin. Before add to cart execution check the cart quantity and return if there are to many products.

2cool

Thanks for your reply, but I guess no check is needed :)
Just the sum of articles (2 apples, 10 beans, 5 bread = 17 products)

Regards,

Pas

K&K media production

Ah OK ... this should be inside the cart object. Make a vmdebug inside one of your cart template overrides and look what is there.

2cool

Hi could you explain this a bit more detailed, what/where should this be done, and what should I look for?
Just need total products added at bottom of admin order.

Thanks,
Pas

K&K media production

mail_html_vendor.php

or

mail_html_vendor_more.php

$this->orderDetails['totalItems']

2cool

Hi, I added the code to mail_html_vendor.php but gave an error 0 ?

Guess I did it wrong

<?php
// echo vmText::_('COM_VIRTUEMART_CART_MAIL_VENDOR_TITLE').$this->vendor->vendor_name.'<br/>';
echo vmText::sprintf('COM_VIRTUEMART_MAIL_VENDOR_CONTENT',$this->vendor->vendor_store_name,$this->shopperName,$this->currency->priceDisplay($this->orderDetails['details']['BT']->order_total),$this->orderDetails['details']['BT']->order_number);

if(!empty(
$this->orderDetails['details']['BT']->customer_note)){
echo '<br /><br />'.vmText::sprintf('COM_VIRTUEMART_CART_MAIL_VENDOR_SHOPPER_QUESTION',$this->orderDetails['details']['BT']->customer_note).'<br />';
echo 
vmText::$this->orderDetails['totalItems'];
}

?>

GJC Web Design

????  echo vmText::$this->orderDetails['totalItems'];

try  echo 'Total Order Items: '.$this->orderDetails['totalItems'];
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

Jörgen

#8
Hello

I must miss something obvious, but the proposed solution does not work. There is no such item...
echo 'Total Order Items: '.$this->orderDetails['totalItems'];

I suggest this solution
<?php 
  $totalNrOfOrderItems
0;
  foreach (
$this->orderDetails['items'] as $orderItem) {
    
$totalNrOfOrderItems $totalNrOfOrderItems $orderItem->product_quantity
  }
  echo 
vmText::_('VM_TOTAL_NUMBER_OF_ORDER_ITEMS') . $totalNrOfOrderItems
?>


Hope that this will help.

regards

Jörgen @ Kreativ Fotografi

[edit] changed [items] to ['items'] [/edit]
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

GJC Web Design

Ah .. I just assumed there was cos K&K said..  ;)
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

Jörgen

I have just added my solution to the /templates/my-template/html/com_virtuemart/invoice/invoice_items.php and can see that it works as expected. As 2cool said, it is a nice feature for order picking.

Have a nice day

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

K&K media production

Quote from: Jörgen on June 04, 2017, 13:41:17 PM
Hello

I must miss something obvious, but the proposed solution does not work. There is no such item...
echo 'Total Order Items: '.$this->orderDetails['totalItems'];

oh sorry you're right, I just copy paste it from my template and forgot I've set this before on mail_html.php:


$totalItems = 0;
foreach($this->orderDetails['items'] as $item) {
$totalItems += $item->product_quantity;
}
$this->orderDetails['totalItems'] = $totalItems;

2cool

Hi and thank you,
I'm almost got this right....

But I see this on orders: VM_TOTAL_NUMBER_OF_ORDER_ITEMS5

Is this just a issue in translation file? i'm using Dutch language...

Thanks and regards,

Pas

K&K media production

Quote from: 2cool on June 06, 2017, 09:58:49 AM
But I see this on orders: VM_TOTAL_NUMBER_OF_ORDER_ITEMS5

Is this just a issue in translation file? i'm using Dutch language...

This is a custom language key and you must create it

Extensions -> Languages -> Overrides

2cool

Thanks for your help!

But I tried to do the same on a new site but can't reproduce this again :(
Get this error on mails Notice: Use of undefined constant items - assumed 'items' in /templates/mytemplate/html/com_virtuemart/invoice/invoice_items.php on line 272

Step by step:
- in /components/com_virtuemart/views/invoice/tmpl/mail_html_vendor.php add:

echo 'Total Order Items: '.$this->orderDetails['totalItems'];

- in /templates/my-template/html/com_virtuemart/invoice/invoice_items.php -> add:

<?php 
  $totalNrOfOrderItems
0;
  foreach (
$this->orderDetails[items] as $orderItem) {
    
$totalNrOfOrderItems $totalNrOfOrderItems $orderItem->product_quantity
  }
  echo 
vmText::_('VM_TOTAL_NUMBER_OF_ORDER_ITEMS') . $totalNrOfOrderItems
?>


- in /components/com_virtuemart/views/invoice/tmpl/mail_html.php -> add:

$totalItems = 0;
foreach($this->orderDetails['items'] as $item) {
$totalItems += $item->product_quantity;
}
$this->orderDetails['totalItems'] = $totalItems;


- Create a langauage override for 'VM_TOTAL_NUMBER_OF_ORDER_ITEMS'

Thanks and regards,
Pas