News:

Looking for documentation? Take a look on our wiki

Main Menu

Rearrange Address Layout on Order Email

Started by kvo, October 09, 2020, 14:56:14 PM

Previous topic - Next topic

kvo

Joomla 3.9.22
VM 3.8.4
I would like to rearrange the address layout on order emails to this:
Firstname Lastname
Address
City, ST ZIP
Phone

I can't find anything recent on this, maybe I am missing something or there is a better way? What is the path to the file that needs modified?
Thanks!

AH

I think this is the file you are looking for:

components/com_virtuemart/views/invoice/tmpl/mail_html_shopperaddresses.php
Regards
A

Joomla 4.4.5
php 8.1

kvo

Thanks for the prompt assistance!
I found an old thread with code I needed: http://forum.virtuemart.net/index.php?topic=117954.msg505570#msg505570
but I have a question, what would we put in place of    'key' => 'virtuemart_state_id', to get the abbreviated State instead? CA instead of California for example?

AH

The state code is held in variable:

state_2_code
Regards
A

Joomla 4.4.5
php 8.1

kvo

Thanks again, I had tried this, but it returned nothing. This is the code I replace the file mail_html_shopperaddresses.php
So I tried to replace the 'virtuemart_state_id', with 'virtuemart_state_2_code' and it returned nothing.


<?php
/**
*
* Layout for the order email
* shows the chosen adresses of the shopper
* taken from the stored order
*
* @package   VirtueMart
* @subpackage Order
* @author Max Milbers,   Valerie Isaksen
*
* @link https://virtuemart.net
* @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
*
*/
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');

$br = '<br class="clear" />';
$addressBTOrder = [[
    'key' => 'email',
    'suffix' => $br
], [
    'key' => 'company',
    'suffix' => $br
], [
    'key' => 'title',
    'suffix' => ''
], [
    'key' => 'first_name',
    'suffix' => ''
], [
    'key' => 'last_name',
    'suffix' => $br
], [
    'key' => 'address_1',
    'suffix' => $br
], [
    'key' => 'address_2',
    'suffix' => $br
], [
    'key' => 'city',
    'suffix' => ','
], [
    'key' => 'virtuemart_state_id',
    'suffix' => ''
], [
    'key' => 'zip',
    'suffix' => $br
], [
    'key' => 'virtuemart_country_id',
    'suffix' => $br
], [
    'key' => 'phone_1',
    'suffix' => $br
], [
    'key' => 'phone_2',
    'suffix' => $br
]];

$addressSTOrder = [[
    'key' => 'company',
    'suffix' => $br
], [
    'key' => 'title',
    'suffix' => ''
], [
    'key' => 'first_name',
    'suffix' => ''
], [
    'key' => 'last_name',
    'suffix' => $br
], [
    'key' => 'address_1',
    'suffix' => $br
], [
    'key' => 'address_2',
    'suffix' => $br
], [
    'key' => 'city',
    'suffix' => ','
], [
    'key' => 'virtuemart_state_id',
    'suffix' => ''
], [
    'key' => 'zip',
    'suffix' => $br
], [
    'key' => 'virtuemart_country_id',
    'suffix' => $br
], [
    'key' => 'phone_1',
    'suffix' => $br
], [
    'key' => 'phone_2',
    'suffix' => $br
]];


?>
<table class="html-email" cellspacing="0" cellpadding="5" border="0" width="100%" style="border-collapse: collapse; font-family: Arial, Helvetica, sans-serif; font-size: 12px; margin: 0 auto;">
   <tr>
   <th width="50%" bgcolor="#EEEEEE" style="border: 1px solid #CCCCCC;">
       <?php echo vmText::_('COM_VIRTUEMART_USER_FORM_BILLTO_LBL'); ?>
   </th>
   <th width="50%" bgcolor="#EEEEEE" style="border: 1px solid #CCCCCC;">
       <?php echo vmText::_('COM_VIRTUEMART_USER_FORM_SHIPTO_LBL'); ?>
   </th>
    </tr>
    <tr>
   <td valign="top" width="50%" style="border: 1px solid #CCCCCC;">

      <?php foreach ($addressBTOrder as $field) :
      $userField = $this->userfields['fields'][$field['key']];
      if (!empty($userField['value'])) : ?>
      <span class="values vm2-<?= $userField['name'] ?>">
        <?= $this->escape($userField['value']) ?><?= $field['suffix'] ?>
      </span>
      <?php endif; endforeach ?>

   </td>
   <td valign="top" width="50%" style="border: 1px solid #CCCCCC;">
       <?php if(!empty($this->orderDetails['details']['has_ST'])){
         foreach ($addressSTOrder as $field) :
      $userField = $this->shipmentfields['fields'][$field['key']];
      if (!empty($userField['value'])) : ?>
      <span class="values vm2-<?= $userField['name'] ?>">
        <?= $this->escape($userField['value']) ?><?= $field['suffix'] ?>
      </span> <?php endif; endforeach ?>
                  <br class="clear" /> <?php
                  } else {
            echo "<br/>".vmText::_('COM_VM_ST_SAME_AS_BT');
         }
      ?>
   </td>
    </tr>
      <tr><td valign="top" width="50%" style="padding:5px"></td><td valign="top" width="50%" style="padding:5px"></td></tr>
</table>
                                                                                 

AH

It may not get returned

If it does the field is named:

state_2_code

not
virtuemart_state_2_code
Regards
A

Joomla 4.4.5
php 8.1