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

Admin template, add field to Orders page

Started by EvanGR, August 07, 2018, 11:08:11 AM

Previous topic - Next topic

EvanGR

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

Orders page ?
More info is better
In front, in admin orders list. Joomla and/or Virtuemart release number ?

EvanGR

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

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
foreach ($this->orderslist as $key => $order) {
$order is the data you can acess, so inside the loop, do a
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

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

Haven´t tested this, but have You tried:

var_dump($order['details']);

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

EvanGR

Quote from: Jörgen on August 08, 2018, 10:08:25 AM
Haven´t tested this, but have You tried:

var_dump($order['details']);

Jörgen @ Kreativ Fotografi

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

var_dump($order) works fine

GJC Web Design

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 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

EvanGR

Much better output, thanks! Here's an example output (I have put  **** in sensitive information)

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

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

Ah good to know, the VM3 update is in the works, so I will try it again then. Thank you!