Jump to content
Sign in to follow this  
fatbloke

Make CC radio box selected by default

Recommended Posts

Hi

 

I use the Credit Card - Postal Cheque - PayPal payment modules

 

None of the Radio Boxes are selcted by default but I want to make the Credit Card module Radio Button selected as default ..where and how do I do this ?

 

Thanks in advance

Share this post


Link to post
Share on other sites

I've done this on my site, but am not positive that this is how I accomplished it. (I'm using BeyondCompare to see the difference between the default checkout_payment.php file and mine, so this looks like the right spot.)

 

MAKE A BACKUP COPY OF YOUR /CATALOG/CHECKOUT_PAYMENT.PHP FILE BEFORE TRYING THIS!

 

In /catalog/checkout_payment.php, look for:

 

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

 

Change to:

 

<?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']);
? ?}
?>

 

See if that works for you...

 

HTH,

 

Terry (a clever DUDETTE if it works) :)

Edited by TerryK

Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Share this post


Link to post
Share on other sites

To go along with this, you might also need to ensure that Credit Card is listed as sort order #1 in your Admin -> Modules -> Payment Modules section.

 

Terry


Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Share this post


Link to post
Share on other sites

Hi Terry ( Dudette )

 

That worked fine .....and first time .... thanks a million :thumbsup:

 

I have been trying to do that for weeks

Share this post


Link to post
Share on other sites

Another simpler way using javascript is to add an onload event to the body tag in your checkout_payment.php file:

 

onload="java script:document.checkout_payment.payment[0].click();return true;"

 

Add it all including the endquotes... This is good on MS2, later CVS may need:

 

onload="java script:document.payment.payment[0].click();return true;"

 

Whether you use "checkout_payment" or just "payment" in your checkout_payment.php depends on the name of the form...

 

This assumes that the ORDER of your payment methods in Admin->Modules->Payment has the credit card module ordered FIRST.

Share this post


Link to post
Share on other sites

Would anyone know how to put the radio buttons in front of the payment types rather than the right site. part of the code for the checkout_shipping.php is below.

 

thanks for any help on this

 

><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">

<tr class="infoBoxContents">

<td><table border="0" width="100%" cellspacing="0" cellpadding="2">

<?php

$selection = $payment_modules->selection();

 

if (sizeof($selection) > 1) {

?>

<?php

} else {

?>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

<td class="main" width="100%" colspan="2"><?php echo TEXT_ENTER_PAYMENT_INFORMATION; ?></td>

<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

</tr>

<?php

}

 

$radio_buttons = 0;

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']);

} else {

echo tep_draw_hidden_field('payment', $selection[$i]['id']);

}

?>

</td>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

</tr>

<?php

if (isset($selection[$i]['error'])) {

?>

<tr>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

<td class="main" colspan="4"><?php echo $selection[$i]['error']; ?></td>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

</tr>

Share this post


Link to post
Share on other sites

Fantastic Terry, thanks so much.

 

Works a treat.

 

Matt.

 

 

 

I've done this on my site, but am not positive that this is how I accomplished it. (I'm using BeyondCompare to see the difference between the default checkout_payment.php file and mine, so this looks like the right spot.)

 

MAKE A BACKUP COPY OF YOUR /CATALOG/CHECKOUT_PAYMENT.PHP FILE BEFORE TRYING THIS!

 

In /catalog/checkout_payment.php, look for:

 

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

 

Change to:

 

<?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']);
}
?>

 

See if that works for you...

 

HTH,

 

Terry (a clever DUDETTE if it works) :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×