Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Default payment method pre-selected in checkout


Guest

Recommended Posts

If you use more than one payment module, you can have one of them pre-selected for use when the customer goes thru checkout. This may be advantageous in 'steering' customers to use the payment method that you would prefer they use. And, if your buyers typically use this method of payment the most anyway...they'll never have to select it again.

 

Firstly, login to the Admin side of your website and look at your Payment Modules. Select the one you would like to use as the default method and set the sort order of it to zero. Set the other payment modules in use to higher values.

 

Now...go to catalog>checkout_payment.php

 

Find this piece of code:

 

<?php
if (sizeof($selection) > 1) {
  echo tep_draw_radio_field('payment', $selection[$i]['id']);
} else {
  echo tep_draw_hidden_field('payment', $selection[$i]['id']);
}
?>

 

Replace it with this:

 

<?php
  if (sizeof($selection) > 1) {
  if ($i == 0) { 
	$checked = true;	  
	} else {  
   $checked = false;	  
   }	 
	echo tep_draw_radio_field('payment', $selection[$i]['id'], $checked);
   } else { 
	echo tep_draw_hidden_field('payment', $selection[$i]['id']);
   }
?>

 

If you use Fast Easy Checkout, apply the same change to catalog>includes>fec>payment_box.php

 

Now, your preferred payment method should be selected by default when customers check out.

 

- Andrea

Link to comment
Share on other sites

Slight variation from the code above:

 

(this adds the ability to have different colored background for the default payment type verses the others, also added a blinking gif arrow)

 

 

 

Find:

  for ($i=0, $n=sizeof($selection); $i<$n; $i++) {
?>
		  <tr>
			<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
			<td colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<?php
if ( ($selection[$i]['id'] == $payment) || ($n == 1) ) {
  echo '				  <tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
} else {
  echo '				  <tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
}
?>
				<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
				<td class="main" colspan="3"><b><?php echo $selection[$i]['module']; ?></b></td>
				<td class="main" align="right">
<?php
if (sizeof($selection) > 1) {
  echo tep_draw_radio_field('payment', $selection[$i]['id'], ($selection[$i]['id'] == $payment));
} else {
  echo tep_draw_hidden_field('payment', $selection[$i]['id']);
}
?>

 

 

 

Change To:

  for ($i=0, $n=sizeof($selection); $i<$n; $i++) {


// this will make the first payment selection the  default one

	  if ($i == 0) {
			   $bgclass = 'mainSelected';
			   $checked = true;
					 } else {
							  $bgclass = 'mainNotSelected';
							  $checked = false;	 }

?>

		  <tr>
			<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
			<td class="<?php echo $bgclass; ?>" colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<?php
if ( ($selection[$i]['id'] == $payment) || ($n == 1) ) {
  echo '				  <tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
} else {
  echo '				  <tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
}
?>
				<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
				<td class="main" colspan="3"><b><?php echo $selection[$i]['module']; ?></b></td>
				<td class="main" align="right">

<?php
if (sizeof($selection) > 1) {
  echo tep_draw_radio_field('payment', $selection[$i]['id'], $checked);
} else {
  echo tep_draw_hidden_field('payment', $selection[$i]['id']);
}
?>

 

 

 

 

Add this to your stylesheet.css file to control the background color

.mainSelected {background: #004000;}
.mainNotSelected {background: #336666;}

 

 

Here is a blinking arrow gif

arrow_east_south.gif

Link to comment
Share on other sites

  • 3 months later...
  • 1 month later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...