Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Make CC radio box selected by default


fatbloke

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

Link to comment
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. *

Link to comment
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. *

Link to comment
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.

Link to comment
Share on other sites

  • 2 months later...

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>

Link to comment
Share on other sites

  • 7 months later...

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) :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...