News:

Looking for documentation? Take a look on our wiki

Main Menu

SOLVED RTFM! Sublayout for Shopper Addresses - help!

Started by optmax, July 15, 2015, 20:46:45 PM

Previous topic - Next topic

optmax

VM 3.0.9.4
J! 3.4.1

I am trying to use a sublayout to format shopper billing and delivery addresses.

To start with I am trying to do this in the system emails with a view to using the same sublayout in other places eg invoices.

So this is what I have tried...

Created an override
/templates/mytemplate/html/com_virtuemart/invoice/mail_html_shopperaddresses.php
and a sublayout
/templates/mytemplate/html/com_virtuemart/sublayouts/shopperadds.php
(also  tried using the core folder /components/com_vituemart/sublayouts/shopperadds.php )

in the override mail_html_shopperaddresses.php I have replaced
<?php
    
foreach ($this->userfields['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
}
    }
 
    }
            
?>


with
<?php
shopFunctionsF
::renderVmSubLayout('shopperadds',array('shopper_address_fields'=>$this->userfields));
?>


I have left the ShipTo code alone for the time being

The sublayout shopperadds.php contains
$shopperadds =$viewData['shopper_address_fields'];
    foreach ($shopperadds['fields'] as $field) {
if (!empty($field['value'])) {
?>
        <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
}
    }
 
    }?>



But in the emails sent the Bill To address is now blank - the ShipTo remains OK as no sublayout is being used (yet).

Should this approach work?

If so any ideas as to what I am doing wrong?

optmax

#1
A case of RTFM on my part!!!

I need to echo the output from the sublayout:
<?php
echo shopFunctionsF::renderVmSubLayout('shopperadds',array('shopper_address_fields'=>$this->userfields));
?>