ShipTo address module checking wrong item names?

Started by kmeyer, February 15, 2015, 00:34:21 AM

Previous topic - Next topic

kmeyer

In default_address.php, in outputting the shipto addresss, around line 88, you are checking for
$item['name'] == 'first_name' etc.,
it appears you should be checking instead for
$item['name'] == 'shipto_first_name', etc.

It's not clear to me why you are inserting class names for these particular items (first name, middle name, zip), just curious. But also, you should probably be inserting breaks using the same logic as for the bill-to address, no? Perhaps this section of code never got fully finalized.

I attach my override, which formats the address for US standards, and depends on re-ordering shopper fields.


AH

This piece of code determines whether to include a line break between items

Yes I agree that the shipto_ is missing from the base template

You can create an override for this as required:-

I choose to do this:-


if(!empty($this->cart->ST) and  !empty($this->cart->STaddress['fields'])){ ?>
<div id="output-shipto-display">
<?php
foreach ($this->cart->STaddress['fields'] as $item) {
if (!empty($item['value'])) {
?>

<!-- <span class="titles"><?php echo $item['title'?></span> -->
<?php
if ($item['name'] == 'shipto_first_name' || $item['name'] == 'shipto_middle_name') {
?>

<span
class="values<?php echo '-' $item['name'?>"><?php echo $item['value'?></span>
<?php } elseif ($item['name'] == 'shipto_address_type_name'){
//do nothing with the nickname
} else { ?>

<span class="values"><?php echo $item['value'?></span>
<br class="clear"/>
<?php
}
}
}
?>

</div>
<?php
}




Regards
A

Joomla 4.4.5
php 8.1

kmeyer

As written that conditional statement generates line breaks only if it's not the firstname, middlename, or zip, but it generates different class="..." html statements that vary depending on whether there is a line break, which seems odd unless the span included the entire line, which it doesn't. Here's the code from the original file:

<?php
if ($item['name'] == 'first_name' || $item['name'] == 'middle_name' || $item['name'] == 'zip') {
?>

<span class="values<?php echo '-' $item['name'?>"><?php echo $item['value'?></span>
<?php } else { ?>
<span class="values"><?php echo $item['value'?></span>
<br class="clear"/>
<?php
}


In any case, it appears there is a similar problem in ...\invoice\mail_html_shopperaddresses.php (missing the "shipto_" prefix).  Since my installation on localhost doesn't generate emails, I wonder if there's a simple way to test that override without having to put the changes up on a live site?  Thanks for any insight into this.

kmeyer

One more question here...

The email to the purchaser is correctly showing both the billTo and ShipTo addresses, but the email to the vendor is showing only the name and address1. The other values are all replaced with the word "Shipment".  Shouldn't the same code be generating the addresses for both emails?  If not, where is the file that generates the code for the vendor email?

And again, is there a way to test overrides for these without creating an order on a live site to generate the email?

Thanks!

AH

You should be doing all your testing and mods on a test site first

That way you can generate orders as required - never do this stuff on a live site!

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

generates the address if using HTML mail

I use this override for the email address - to sequence and created breaks where I want using the array sequence at the top of the code:-



<?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 http://www.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');
//quorvia 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}');
?>

<table class="html-email" cellspacing="0" cellpadding="0" border="0" width="100%">
    <tr  >
        <th width="50%">
            <?php echo vmText::_('COM_VIRTUEMART_USER_FORM_BILLTO_LBL'); ?>
        </th>
        <th width="50%" >
            <?php echo vmText::_('COM_VIRTUEMART_USER_FORM_SHIPTO_LBL'); ?>
        </th>
    </tr>
    <tr>
        <td valign="top" width="50%">
            <?php
            
foreach ($addressBTOrder as $fieldname) {
                
$fieldinfo explode('{',$fieldname);
                if (!empty(
$this->userfields['fields'][$fieldinfo[0]]['value'])) { ?>

                    <span class="values vm2<?php echo '-' $this->userfields['fields'][$fieldinfo[0]]['name'?>" ><?php echo $this->escape($this->userfields['fields'][$fieldinfo[0]]['value']) ?></span> <?php
                    
if (isset($fieldinfo[1]) && $fieldinfo[1] == 'br}') { ?>

                        <br class="clear" /> <?php
                    
}
                }
            }
            
?>

        </td>
        <td valign="top" width="50%">
            <?php
            
foreach ($addressSTOrder as $fieldname) {
                
$fieldinfo explode('{',$fieldname);
                if (!empty(
$this->shipmentfields['fields'][$fieldinfo[0]]['value'])) { ?>

                    <span class="values vm2<?php echo '-' $this->shipmentfields['fields'][$fieldinfo[0]]['name'?>" ><?php echo $this->escape($this->shipmentfields['fields'][$fieldinfo[0]]['value']) ?></span> <?php
                    
if (isset($fieldinfo[1]) && $fieldinfo[1] == 'br}') { ?>

                        <br class="clear" /> <?php
                    
}
                }
            }
            
?>

        </td>
    </tr>
</table>
Regards
A

Joomla 4.4.5
php 8.1

kmeyer

Thanks for the code and the file pointer Hutson. By "live site" I just meant that it is on a host server, rather than on localhost.  So the question is still: Is there a way to test the email that will be generated without having to go through the tedious process of creating an actual order on my "live test site" to cause the system to actually send me an email?

Also, can you explain why different address results are being generated for the purchaser email vs. the vendor email?

kmeyer

I'm attaching screen shots of my purchaser and vendor emails, you can see the addresses are showing up formatted OK, but in the vendor email the city/state/zip and country have all been replaced with the word "Shipment".


AH

Quoteest the email that will be generated without having to go through the tedious process of creating an actual order on my "live test site"

Just go into order status and change it from pending then save to confirmed then save = or whichever staus you have set to send an email
Regards
A

Joomla 4.4.5
php 8.1