News:

Support the VirtueMart project and become a member

Main Menu

Billing/Shipping Address Formatting in Cart

Started by chumphrey, July 17, 2015, 18:43:24 PM

Previous topic - Next topic

chumphrey

How do I change the way the Billing & Shipping addresses are displayed on the cart?  I would like them to look more like you would see on an envelope.  Suggestions?

Example:
FirstName LastName
Address 1
Address 2
City, State Zip
Country


jenkinhill

You can re-order the shopper fields (if necessary) to get the fields in the required order and then edit components/com_virtuemart/views/cart/tmpl/default_address.php to give your required layout. Then save the edited file and use as a template override.

Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

chumphrey

I have reordered the Shopper Fields to get the order they are displayed, but not sure how to modify the default_address.php.  The code within that file does not list each of the shopper fields individually - and I'm not great at PHP.  Any help would be appreciated in what to replace within the default_address file to place those fields in the layout desired.  Thanks!

chumphrey

Quote from: jenkinhill on July 18, 2015, 16:56:19 PM
You can re-order the shopper fields (if necessary) to get the fields in the required order and then edit components/com_virtuemart/views/cart/tmpl/default_address.php to give your required layout. Then save the edited file and use as a template override.


jenkinhill - Since the code in the default_address file does not list each of the shopper fields - what would the code look like to lay these fields out individually and what should be replaced?  Thanks!

AH

Something like this

templates/mytemplate/html/com_virtuemart/orders/details_order.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 print the results for the addresses


<table>
                        <tr><td colspan="2"><strong><?php echo vmText::_('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>




Also do this in

templates/mytemplate/html/com_virtuemart/invoice/mail_html_shopperaddresses.php
Regards
A

Joomla 4.4.5
php 8.1