OSCOMMERCE SUPPORT CALL 702-453-3332

 

Help - Search - Members - Calendar
Full Version: Displaying Zip/postal Code On New Line
osCommerce Community Support Forums > osCommerce Online Merchant v2.x > Installation and Configuration
crazihouse
Hi!

I'm trying to figure out how to display the zip or postal code on a new in checkout_shipping.php and checkout_payment.php.

It's showing on 2 lines because of the smaller size of my layout. I included a screenshot to demonstrate what I mean. Any ideas?

crazihouse
bump.
germ
Before making any edits - MAKE BACKUPS!!!

In checkout_shipping.php look for this line:

CODE
<td class="main" valign="top"><?php echo tep_address_label($customer_id, $sendto, true, ' ', '<br>'); ?></td>


Replace it with this:

CODE
<td class="main" valign="top">
<?php
$str = tep_address_label($customer_id, $sendto, true, ' ', '<br>');
$pieces = explode("<br>", $str);
$alen = count($pieces);
$retval = '';
for ($ii=0; $ii<$alen; $ii++) {
  if ( strstr($pieces[$ii], ',' ) ) {
    $parts = explode(",", $pieces[$ii]);
    $retval .= $parts[0];
    $retval .= ',<br>';
    $retval .= $parts[1];
    $retval .= '<br>';
  }
  else {
    $retval .= $pieces[$ii];
    $retval .= '<br>';
  }
}
echo $retval;
?></td>


In checkout_payment.php look for this line:

CODE
<td class="main" valign="top"><?php echo tep_address_label($customer_id, $billto, true, ' ', '<br>'); ?></td>


Replace it with this:

CODE
<td class="main" valign="top">
<?php
$str = tep_address_label($customer_id, $billto, true, ' ', '<br>');
$pieces = explode("<br>", $str);
$alen = count($pieces);
$retval = '';
for ($ii=0; $ii<$alen; $ii++) {
  if ( strstr($pieces[$ii], ',' ) ) {
    $parts = explode(",", $pieces[$ii]);
    $retval .= $parts[0];
    $retval .= ',<br>';
    $retval .= $parts[1];
    $retval .= '<br>';
  }
  else {
    $retval .= $pieces[$ii];
    $retval .= '<br>';
  }
}
echo $retval;
?></td>


Does that work for you?
unsure.gif
crazihouse
Wow........ that's some deep coding!

Thanks for your help. It looks great, however, the state/province is displayed on a different line from the country like the following:

First Last
123 Niceroad
Somecity,
A1B 2C3
QC,
Canada

Is there any way to make it finally look like:

First Last
123 Niceroad
Somecity,
A1B 2C3
QC, Canada

Thanks again for your time!
germ
What the code does is split any line it finds a "," (comma) in into two lines.

It looks as if (at least in your example) we only need to do that the first time it finds a "," then stop splitting lines there.

Do you think that will work in all instances for your application?
unsure.gif

If so, I'll modify the code to do that.
thumbsup.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.