Page 1 of 1

How to show address on checkout confirm page? - SOLVED

Posted: Tue Oct 18, 2011 8:02 pm
by easyaspie
Hi.

How do I show the payment and shipping address (firstname, lastname, address, e-mail etc.) on the checkout confirm page, formatted according to the "address format" settings related to the selected country?


Thank's a lot
Morten

Re: How to show address on checkout confirm page?

Posted: Fri Oct 21, 2011 3:11 pm
by Jeremy Fisk
if i have read your question right, it should just be another php echo...

but if you want to make it easier... please post a picture of what you want done and i'll have a look

Thanks

Jem

Re: How to show address on checkout confirm page?

Posted: Fri Oct 21, 2011 3:43 pm
by easyaspie
I figured it out by using code from one of the other controllers.

In the confirm controller, I added this (same for shipping):

...
$data['shipping_country'] = $shipping_address['country'];
$data['shipping_country_id'] = $shipping_address['country_id'];
$data['shipping_address_format'] = $shipping_address['address_format'];


//CUSTOM format shipping address
if ($data['shipping_address_format']) {
$format = $data['shipping_address_format'];
} else {
$format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}';
}

$find = array(
'{firstname}',
'{lastname}',
'{company}',
'{address_1}',
'{address_2}',
'{city}',
'{postcode}',
'{zone}',
'{zone_code}',
'{country}'
);

$replace = array(
'firstname' => $data['shipping_firstname'],
'lastname' => $data['shipping_lastname'],
'company' => $data['shipping_company'],
'address_1' => $data['shipping_address_1'],
'address_2' => $data['shipping_address_2'],
'city' => $data['shipping_city'],
'postcode' => $data['shipping_postcode'],
'zone' => $data['shipping_zone'],
'zone_code' => $data['shipping_zone_code'],
'country' => $data['shipping_country']
);

$this->data['shipping_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));


In the confirm template I show the addresses with:

<div class="left">
<h2><?php echo $text_checkout_payment_address; ?></h2>
<?php echo $payment_address; ?>
</div>
<div class="right">
<h2><?php echo $text_checkout_shipping_address; ?></h2>
<?php echo $shipping_address; ?>
</div>
<div style="clear:both"></div>

Re: How to show address on checkout confirm page? - SOLVED

Posted: Fri Oct 21, 2011 3:51 pm
by Jeremy Fisk
it looks great...