VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: Milada on October 09, 2016, 11:50:24 AM

Title: How to display separate fields in invoice
Post by: Milada on October 09, 2016, 11:50:24 AM
Hello,
how can i display separate fields in invoice?

I checked invoice_order.php file:

Display userfields:

<?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_BILL_TO_LBL'?></strong> <br/>
    <table border="0"><?php
    foreach (
$this->userfields['fields'] as $field) {
if (!empty($field['value'])) {
    echo '<tr><td class="key">' $field['title'] . '</td>'
    . '<td>' $field['value'] . '</td></tr>';
}
    }
    ?>


Display shipmentfields:

<?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_SHIP_TO_LBL'?></strong><br/>
    <table border="0"><?php
    foreach (
$this->shipmentfields['fields'] as $field) {
if (!empty($field['value'])) {
    echo '<tr><td class="key">' $field['title'] . '</td>'
    . '<td>' $field['value'] . '</td></tr>';
}
    }
    ?>


This part of code display ALL shipment- or userfields, i don't need it. I need to display certain fields, which i want. Is it possible to output separate fields?
Thanks!
Title: Re: How to display separate fields in invoice
Post by: GJC Web Design on October 09, 2016, 11:52:39 AM
in the loop use
if($field['title'] == 'xxx') { // display it }
statements to display only what u want
Title: Re: How to display separate fields in invoice
Post by: Milada on October 09, 2016, 12:55:31 PM
Quote from: GJC Web Design on October 09, 2016, 11:52:39 AM
in the loop use
if($field['title'] == 'xxx') { // display it }
statements to display only what u want

Could you please help with full peace of code for one field? I'm just new at php.
For example, display field with fieldname "patientfirstname" (screenshot: http://joxi.ru/v29QZ6piKEaJ2G)

Many thanks!  :)
Title: Re: How to display separate fields in invoice
Post by: GJC Web Design on October 09, 2016, 13:08:36 PM


<?php
    foreach (
$this->userfields['fields'] as $field) {
if ($field['name'] == 'patientfirstname') {
    echo '<tr><td class="key">' $field['title'] . '</td>'
    . '<td>' $field['value'] . '</td></tr>';
}elseif($field['name'] == 'xxxxxx'){
                      
// keep going
                
// add more if needed
    }
    ?>


Title: Re: How to display separate fields in invoice
Post by: Milada on October 09, 2016, 14:47:52 PM
Quote from: GJC Web Design on October 09, 2016, 13:08:36 PM


<?php
    foreach (
$this->userfields['fields'] as $field) {
if ($field['name'] == 'patientfirstname') {
    echo '<tr><td class="key">' $field['title'] . '</td>'
    . '<td>' $field['value'] . '</td></tr>';
}elseif($field['name'] == 'xxxxxx'){
                      
// keep going
                
// add more if needed
    }
    ?>




It works, GREAT! Many thanks  :)