News:

Support the VirtueMart project and become a member

Main Menu

Shoper fields from the invoice

Started by MihaiDumitrele, June 24, 2014, 17:55:08 PM

Previous topic - Next topic

MihaiDumitrele

I want to use the invoice generated by virtuemart attached to the confirmation e-mail sent to the buyer, but i came across of a legislative problem from my country.
More precise on the invoice i must have the following fields:

- if the buyer is a company i need:
    - the company name
    - VAT number
    - the adress

- if it's a person i need:
   - name
   - adress

The problem is that when a company sends an order, besides the listed fields i also need to put down on the invoice the company's representative name, but separated from the columns from above.
Basically i have created new fields for the company dates, but the fields with the name and surname remains "necessary".
In this case if the buyer is a person it's ok, but if the buyer is a company along with the company info appears the representative name which i don't want.

My request is to help me with a script so that when the company fields are filled, the name of the representative to appear on the bottom of the invoice( the delegated person field).
The law obligates me not to put the representative person's name on the company info column, but only on the delegated field, as i said before.

I have attached 2 pictures to show you what i need exactly. 
   

[attachment cleanup by admin]

MihaiDumitrele

Someone please help me with this problem !!!

AH

Create an override for the invoice order

templates/yourtemplate/html/com_virtuemart/invoice/invoice_order.php

Create a sequence for the elements of the address a bit like this


<?php
// sequence of address that may differ from the input fields
$addressBTOrder = array('first_name''last_name{br}''email{br}''company{br}','address_1{br}''address_2{br}''city{br}''county{br}''zip{br}''virtuemart_country_id{br}''phone_1{br}');
$addressSTOrder = array('first_name''last_name{br}''company{br}','address_1{br}''address_2{br}''city{br}''county{br}''zip{br}''virtuemart_country_id{br}''phone_1{br}');
?>




Then manage them in the code adjusting the display based on the value of the array field [company]as required

This is a sample of code that delivers the fields for the BT details ignoring empty values:-

  <table>
                        <tr><td colspan="2"><strong><?php echo JText::_('COM_VIRTUEMART_ORDER_PRINT_BILL_TO_LBL'?></strong></td></tr>
                        <?php
                        
foreach ($addressBTOrder as $fieldname) {
                            
$fieldinfo explode('{',$fieldname);
                            if (!empty(
$this->userfields['fields'][$fieldinfo[0]]['value'])) {
                                echo 
'<tr><td class="key">' $this->userfields['fields'][$fieldinfo[0]]['title'] . '</td>'
                                    
'<td>' $this->escape($this->userfields['fields'][$fieldinfo[0]]['value']) . '</td></tr>';
                                if (isset(
$fieldinfo[1]) && $fieldinfo[1] == 'br}') { ?>

                                    <?php
                                
}
                            }
                        }
                        
?>

                    </table>

Regards
A

Joomla 4.4.5
php 8.1

MihaiDumitrele

Thanks for the help but I still have a problem:
- when a shopper fill the company field and his name and last name fields (because these are necessary fields), these informations appear on the invoice together.

For me is important to appear in this case only the company name. First and last names of the shopper I need them only when he want the invoice on his name and he dont fill the company field.
Is strange, I know, but this is the law in our country.
Firs and last name is still important for me to put them on the representative area on the invoice (somewhare on the bottom of the invoice - is marked on the picture that I have attached in first post)

AH

The example is just that, an example.

It shows you how to get the BT and ST data into an array and then a possible way of using it.

I have left it up to you to develop the specific solution to meet your needs

You may wish to include additional fields in the array, as well as develop the decisioning aspect to cater for Company data filled vs no Company data


I am not trying to solve your specific problem, I have left that up to you.  If you cannot code or do not have anyone to help you, then maybe you need to subscribe to the VM supporter membership

http://extensions.virtuemart.net/support/virtuemart-supporter-membership-detail

Regards
A

Joomla 4.4.5
php 8.1