VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: chumphrey on July 17, 2015, 18:43:24 PM

Title: Billing/Shipping Address Formatting in Cart
Post by: chumphrey on July 17, 2015, 18:43:24 PM
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

Title: Re: Billing/Shipping Address Formatting in Cart
Post by: 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.

Title: Re: Billing/Shipping Address Formatting in Cart
Post by: chumphrey on July 20, 2015, 20:55:29 PM
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!
Title: Re: Billing/Shipping Address Formatting in Cart
Post by: chumphrey on July 22, 2015, 23:55:53 PM
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!
Title: Re: Billing/Shipping Address Formatting in Cart
Post by: AH on July 23, 2015, 13:45:20 PM
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