Author Topic: Total number of products on order  (Read 4009 times)

2cool

  • Jr. Member
  • **
  • Posts: 236
Total number of products on order
« on: June 01, 2017, 14:49:19 pm »
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

  • VirtueMart Developer Team
  • Global Moderator
  • Full Member
  • *
  • Posts: 838
  • VirtueMart Version: VM3 on J3
Re: Total number of products on order
« Reply #1 on: June 01, 2017, 21:32:08 pm »
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

  • Jr. Member
  • **
  • Posts: 236
Re: Total number of products on order
« Reply #2 on: June 01, 2017, 21:53:38 pm »
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

  • VirtueMart Developer Team
  • Global Moderator
  • Full Member
  • *
  • Posts: 838
  • VirtueMart Version: VM3 on J3
Re: Total number of products on order
« Reply #3 on: June 01, 2017, 22:18:33 pm »
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

  • Jr. Member
  • **
  • Posts: 236
Re: Total number of products on order
« Reply #4 on: June 02, 2017, 13:28:00 pm »
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

  • VirtueMart Developer Team
  • Global Moderator
  • Full Member
  • *
  • Posts: 838
  • VirtueMart Version: VM3 on J3
Re: Total number of products on order
« Reply #5 on: June 02, 2017, 19:03:03 pm »
mail_html_vendor.php

or

mail_html_vendor_more.php

Code: [Select]
$this->orderDetails['totalItems']

2cool

  • Jr. Member
  • **
  • Posts: 236
Re: Total number of products on order
« Reply #6 on: June 03, 2017, 13:15:38 pm »
Hi, I added the code to mail_html_vendor.php but gave an error 0 ?

Guess I did it wrong
Code: [Select]
<?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

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 9729
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: Total number of products on order
« Reply #7 on: June 03, 2017, 13:32:17 pm »
????  echo vmText::$this->orderDetails['totalItems'];

try  echo 'Total Order Items: '.$this->orderDetails['totalItems'];
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Jörgen

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 2857
    • Kreativ Fotografi
  • VirtueMart Version: 3.4.x
Re: Total number of products on order
« Reply #8 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...
Code: [Select]
echo 'Total Order Items: '.$this->orderDetails['totalItems'];
I suggest this solution
Code: [Select]
<?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)

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 9729
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: Total number of products on order
« Reply #9 on: June 04, 2017, 13:56:03 pm »
Ah .. I just assumed there was cos K&K said..  ;)
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Jörgen

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 2857
    • Kreativ Fotografi
  • VirtueMart Version: 3.4.x
Re: Total number of products on order
« Reply #10 on: June 04, 2017, 15:05:57 pm »
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)

K&K media production

  • VirtueMart Developer Team
  • Global Moderator
  • Full Member
  • *
  • Posts: 838
  • VirtueMart Version: VM3 on J3
Re: Total number of products on order
« Reply #11 on: June 04, 2017, 17:06:36 pm »
Hello

I must miss something obvious, but the proposed solution does not work. There is no such item...
Code: [Select]
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:

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

2cool

  • Jr. Member
  • **
  • Posts: 236
Re: Total number of products on order
« Reply #12 on: June 06, 2017, 09:58:49 am »
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

  • VirtueMart Developer Team
  • Global Moderator
  • Full Member
  • *
  • Posts: 838
  • VirtueMart Version: VM3 on J3
Re: Total number of products on order
« Reply #13 on: June 06, 2017, 14:49:37 pm »
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

  • Jr. Member
  • **
  • Posts: 236
Re: Total number of products on order
« Reply #14 on: June 09, 2017, 01:29:57 am »
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:

Code: [Select]
echo 'Total Order Items: '.$this->orderDetails['totalItems'];
- in /templates/my-template/html/com_virtuemart/invoice/invoice_items.php -> add:

Code: [Select]
<?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:

Code: [Select]
$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