VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: EvanGR on August 07, 2018, 11:08:11 AM

Title: Admin template, add field to Orders page
Post by: EvanGR 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
Title: Re: Admin template, add field to Orders page
Post by: Studio 42 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 ?
Title: Re: Admin template, add field to Orders page
Post by: EvanGR 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

Title: Re: Admin template, add field to Orders page
Post by: Studio 42 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
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.


Title: Re: Admin template, add field to Orders page
Post by: EvanGR 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).
Title: Re: Admin template, add field to Orders page
Post by: 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
Title: Re: Admin template, add field to Orders page
Post by: EvanGR on August 08, 2018, 10:34:53 AM
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
Title: Re: Admin template, add field to Orders page
Post by: GJC Web Design 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";
Title: Re: Admin template, add field to Orders page
Post by: EvanGR on August 08, 2018, 11:36:11 AM
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] => *****
)
Title: Re: Admin template, add field to Orders page
Post by: Studio 42 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
Title: Re: Admin template, add field to Orders page
Post by: EvanGR 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!