VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: servlet on May 31, 2017, 18:21:16 PM

Title: PHP: IF user field is NOT EMPTY display userfield value.
Post by: servlet on May 31, 2017, 18:21:16 PM
Hello
I am not good enough in PHP. Please help.

I have additional user-fields like ROOM and others...
I need to display in confirmation mail value of field ROOM from DB if value is not empty (if user is filled in some data)

How to do it?
Title: Re: PHP: IF user field is NOT EMPTY display userfield value.
Post by: GJC Web Design on June 01, 2017, 22:28:33 PM
This has been explain on here b4.. please use the search

basically the display in the email just uses a loop

you have to do a check on each value inside the loop

i.e if(!empty($value->my_value)){
echo $value->my_value;
}
Title: Re: PHP: IF user field is NOT EMPTY display userfield value.
Post by: servlet on July 24, 2017, 01:06:24 AM
After a lot of hour I found solution, but I cannot order them in my needs. They are displayed in mail in order set in VM Shopper Field List configuration

It there a way to order them?

The code and order is shown below but order is messed up in confirmation e-mail. I found this but I cannot modify it for my needs: http://forum.virtuemart.net/index.php?topic=131881.msg455400#msg455400


    <?php

    foreach (
$this->userfields['fields'] as $field) {
if (!empty($field['value'])) {

if ($field['name']=='first_name') {
echo $field['value'];
}
if ($field['name']=='middle_name') {
echo ' ' $field['value'];
}
if ($field['name']=='last_name') {
echo ' ' $field['value'] . '<br/>';
}
if ($field['name']=='phone_2') {
echo 'Телефон: ' $field['value'] . '<br/>';
}
if ($field['name']=='virtuemart_hood_id') {
echo 'кв. ' $field['value'] . ', ';
}
if ($field['name']=='virtuemart_street_id') {
echo 'ул. ' $field['value'] . ', ';
}
if ($field['name']=='virtuemart_block_id') {
echo 'бл. ' $field['value'] . ', ';
}
if ($field['name']=='virtuemart_entrance_id') {
echo 'вх. ' $field['value'] . ', ';
}
if ($field['name']=='virtuemart_floor_id') {
echo 'ет. ' $field['value'] . ', ';
}
if ($field['name']=='virtuemart_apartament_id') {
echo 'ап. ' $field['value'];
}
if ($field['name']=='zip') {
echo '<br/>' $field['value'] . ' ';
}
if ($field['name']=='city') {
echo $field['value'] . '<br/>';
}
    }
}
    ?>