Author Topic: Admin template, add field to Orders page  (Read 191 times)

EvanGR

  • Jr. Member
  • **
  • Posts: 84
Admin template, add field to Orders page
« on: August 07, 2018, 11:08:11 am »
Hello,

I want to include some extra information about each order, in the Orders page. This information appears in the single Order page (e.g. Phone, Country).

What would be the correct PHP code to access this data?

Thanks

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3248
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: Admin template, add field to Orders page
« Reply #1 on: August 07, 2018, 13:27:13 pm »
Orders page ?
More info is better
In front, in admin orders list. Joomla and/or Virtuemart release number ?

EvanGR

  • Jr. Member
  • **
  • Posts: 84
Re: Admin template, add field to Orders page
« Reply #2 on: August 07, 2018, 14:23:38 pm »
Control Panel -> VirtueMart -> Orders & Shoppers -> Orders

I want to include some additional information/fields in the table, it would save me time. I will edit the template, I just don't know the PHP code to access the data. The data I want appears when you view a single Order by itself (e.g. customer Phone, City etc...)

I am on Joomla 2.5/VM2.6, but I suppose it won't be much different compared to VM3.

Thank you


Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3248
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: Admin template, add field to Orders page
« Reply #3 on: August 07, 2018, 18:33:21 pm »
The file should be :
YOURSITE\administrator\components\com_virtuemart\views\orders\tmpl\orders.php
Of course an overide in template is better, so you don't lose your changes.

The loop is
Code: [Select]
foreach ($this->orderslist as $key => $order) { $order is the data you can acess, so inside the loop, do a
Code: [Select]
var_dump($order);to see all data loaded.
this is an object. So you can show the datas using :
echo $order->order_name;
For the customer Bill details, you have to use
echo $order['details']['BT']->zip;
echo $order['details']['BT']->last_name;
...
The $order['details']['BT'] field names are same as in the userfield list but some fields need in ome case more advanced codes.



EvanGR

  • Jr. Member
  • **
  • Posts: 84
Re: Admin template, add field to Orders page
« Reply #4 on: August 08, 2018, 09:07:37 am »
Thanks that was very useful and got me close.

Unfortunately there doesn't seem to be a $order['details'] sub-tree;

var_dump($order) also doesn't show 'details' or 'BT' data (or the customer Bill Details data that I am looking for).

Jörgen

  • Global Moderator
  • Full Member
  • *
  • Posts: 1608
    • Kreativ Fotografi
  • VirtueMart Version: 3.2.12
Re: Admin template, add field to Orders page
« Reply #5 on: August 08, 2018, 10:08:25 am »
Haven´t tested this, but have You tried:

Code: [Select]
var_dump($order['details']);
Jörgen @ Kreativ Fotografi
Joomla 3.8.3
Virtuemart 3.2.12
Olympiantheme Hera (customized)

EvanGR

  • Jr. Member
  • **
  • Posts: 84
Re: Admin template, add field to Orders page
« Reply #6 on: August 08, 2018, 10:34:53 am »
Haven´t tested this, but have You tried:

Code: [Select]
var_dump($order['details']);
Jörgen @ Kreativ Fotografi

I did, and it corrupts the output (possibly because the key doesn't exist?).

Code: [Select]
var_dump($order) works fine

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 7885
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 2.6.22 & 3.2.14
Re: Admin template, add field to Orders page
« Reply #7 on: August 08, 2018, 11:08:06 am »
var_dump is so ugly

try

print 'Debug Line '.__LINE__.' $order <pre>'; print_r ($order); print "</pre><br />\n";
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

EvanGR

  • Jr. Member
  • **
  • Posts: 84
Re: Admin template, add field to Orders page
« Reply #8 on: August 08, 2018, 11:36:11 am »
Much better output, thanks! Here's an example output (I have put  **** in sensitive information)

Code: [Select]
stdClass Object
(
    [customer_number] => nonreg_**************
    [order_billTax] => {"1":{"virtuemart_calc_id":1,"calc_name":"\u03a6\u03a0\u0391 23%","calc_value":"23.0000","result":8.13444553}}
    [virtuemart_order_id] => 9462
    [virtuemart_user_id] => 0
    [virtuemart_vendor_id] => 1
    [order_number] => a1c706009
    [order_pass] => p_8595d
    [order_total] => 47,90 €
    [order_salesPrice] => 43.50160
    [order_billTaxAmount] => 8.13445
    [order_billDiscountAmount] => -3.04160
    [order_discountAmount] => -3.04160
    [order_subtotal] => 38.40875
    [order_tax] => 8.13445
    [order_shipment] => 3.50
    [order_shipment_tax] => 0.00000
    [order_payment] => 0.90
    [order_payment_tax] => 0.00000
    [coupon_discount] => 0.00
    [coupon_code] =>
    [order_discount] => -3.04
    [order_currency] => 47
    [order_status] => S
    [user_currency_id] => 47
    [user_currency_rate] => 1.00000
    [virtuemart_paymentmethod_id] => 5
    [virtuemart_shipmentmethod_id] => 4
    [customer_note] => ************
    [delivery_date] => *******
    [order_language] => en-GB
    [ip_address] => ************
    [created_on] => 2018-08-07 19:00:06
    [created_by] => 0
    [modified_on] => 2018-08-08 09:27:16
    [modified_by] => 001
    [locked_on] => 0000-00-00 00:00:00
    [locked_by] => 0
    [order_name] => ***************
    [order_email] => ********
    [payment_method] => ************
    [invoiceNumber] => *****
)

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3248
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 &amp; 3.0.x.y
Re: Admin template, add field to Orders page
« Reply #9 on: August 08, 2018, 12:30:26 pm »
You use Virtumeart 2.6, it's why details do not exist.
try to migrate to Virtuemart 3.2, because you have many more code to add to get BT address

EvanGR

  • Jr. Member
  • **
  • Posts: 84
Re: Admin template, add field to Orders page
« Reply #10 on: August 08, 2018, 12:45:28 pm »
Ah good to know, the VM3 update is in the works, so I will try it again then. Thank you!