News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Modification in the email template to show „Same as billing” same address

Started by man.of.earth, October 16, 2019, 16:08:19 PM

Previous topic - Next topic

man.of.earth

Hello,

I want that, in case the shipping address is the same as billing address, to display this on the shipping user data as ,,Same as billing", instead of duplicating the data from the billing column (in the emails sent to customers/vendor, that is).
The lines that show the shipping address are in the mail_html_shopperaddresses.php file (lines 52 to 67):
<td valign="top" width="50%" style="border: 1px solid #CCCCCC;">
    <?php
    
foreach ($this->shipmentfields['fields'] as $field) {

if (!empty($field['value'])) {
    ?>
<!-- span class="titles"><?php echo $field['title'?></span -->
    <span class="values vm2<?php echo '-' $field['name'?>" ><?php echo $field['value'?></span>
    <?php if ($field['name'] != 'title' and $field['name'] != 'first_name' and $field['name'] != 'middle_name' and $field['name'] != 'zip') { ?>
<br class="clear" />
<?php
    }
}
    }

?>

</td>



I added the condition
if(!empty($this->orderdetails['details']['has_ST'])){
before this cycle, but, in the emails only, I still get ,,Same as billing", even if the shipping address if different from billing address:
<td valign="top" width="50%" style="border: 1px solid #CCCCCC;">
if(!empty($this->orderdetails['details']['has_ST'])){?><br/><?
foreach ($this->shipmentfields['fields'] as $field){
if (!empty($field['value'])){?><!--span class="titles"?><?#echo $field['title']?></span-->
<span class="values vm2<?echo '-' . $field['name']?>"><?echo $field['value']?></span><?
if ($field['name'] != 'title' and $field['name'] != 'first_name' and $field['name'] != 'middle_name' and $field['name'] != 'zip'){
?><br class="clear"/><?
}
}
}
}
else{
echo vmText::_('COM_VM_ST_SAME_AS_BT');
}?>
</td>


Does any of you know why or what I could try?
Thank you.

(VM 3.6.2 10159 on Joomla! 3.9.12 and PHP 7.2.9)

AH

That is part of the core system

Provided in the invoice\tmpl\invoice.order.php

If you have an override you can look at how this file does it

it determines if there is a stored ST address using     -  if(!empty($this->orderDetails['details']['has_ST']


<td valign="top" ><strong>
    <?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_SHIP_TO_LBL'?></strong><br/>
<?php if(!empty($this->orderDetails['details']['has_ST'])){
echo "<table border='0'>";
foreach ($this->shipmentfields['fields'] as $field) {
if (!empty($field['value'])) {
echo '<tr><td class="key">' $field['title'] . '</td>'
'<td>' $field['value'] . '</td></tr>';
}
}
echo "</table>";
} else {
echo "<br/>".vmText::_('COM_VM_ST_SAME_AS_BT');
}

?>

        </td>
Regards
A

Joomla 3.10.11
php 8.0

man.of.earth

Originally, I saw that done for orders in frontend (that's where I was inspired from), but in the emails sent, it does not detect $this->orderDetails['details']['has_ST'] correctly.
I echoed that value and it showed nothing.
I was wondering: should I call a model before that, or...?

man.of.earth

It works now!  :D
The difference was the ,,D" capital letter from orderDetails (I used orderdetails).

Curiously, for displaying this for orders in frontend, it works correctly only if used orderdetails (and not orderDetails with capital ,,D")  :D.

AH

yes they are different

Order FE display

$this->orderdetails['details']['has_ST']

Invoice

$this->orderDetails['details']['has_ST']


Regards
A

Joomla 3.10.11
php 8.0