Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Setting a default payment


dreamscape

Recommended Posts

on my site I offer only 2 payment types (credit card or paypal)... since the majority of the time, customers will be paying with credit card, I would like to get CC to the default payment (meaning that when you goto the checkout_payment, it is already selected for)...

 

I want to do this for a few reasons:

 

#1 to make life easier on the customers and

 

#2 some cusomters are getting confused because they put their CC info in and just get looped through checkout_payment.php (since it really is not clear you need to select a payment type radio button)...

 

so I would like to make CC as the default, so that it is already selected for individuals...

 

I have searched and came up empty handed...

 

might anyone know how this could be accomplished.

The only thing necessary for evil to flourish is for good men to do nothing

- Edmund Burke

Link to comment
Share on other sites

i had that one on my TODO list till now...lol

 

goto ADMIN > MODULES > PAYMENT

set the payment that you want to be selected to the HIGHEST sort order

 

then goto catalog/checkout_payment.php

find

<?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 with

<?php

   if (sizeof($selection) > 1) {

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

   } else {

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

   }

?>

 

the only added thing is , 'true'

 

this is a very rough solution but it works

 

you can adjust it all to your needs this way, just play with it...

 

enjoy

 

Let me know by PM if you've found a better solution, thanks in advance ;)

Robert

 

We all need to learn it once, how hard it may seem when you look at it, also you will master it someday ;)

Link to comment
Share on other sites

If instead of 'true' you put $i==0, then the top payment method will be selected. I'm sure it will work with numbers other than 0 if you want something other than the top one selected.

 

Thanks for the tip Robert :)

In olden times the men were made of iron and the ships were made of wood; now it's the other way around. :wink:

Link to comment
Share on other sites

thanks for the tip guys...

 

also to get the payment method highlighted by default I changed:

<?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";

   }

?>

 

to:

<?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 {

 if ( (!$payment) && ($i==0) ) {

     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";

   }

   }

?>

 

now the top payment method will be highlighted (and selected thanks to your tip) by default... and if they shoose something else and go back to change it, it will highlight only the one the previously chose.

The only thing necessary for evil to flourish is for good men to do nothing

- Edmund Burke

Link to comment
Share on other sites

  • 3 months later...

This is fantastic! Just what I was looking for... (especially with the highlight and top payment choice mods) Double thanks for sharing! :)

 

I hope this gets incorporated into the base code. I easily nominate it.

Link to comment
Share on other sites

  • 1 year later...
  • 1 month later...
If instead of 'true' you put $i==0, then the top payment method will be selected.? I'm sure it will work with numbers other than 0 if you want something other than the top one selected.

Thanks for the tip Robert :)

 

I can't get this to work. For one if I set any of the options to sort as 0, none of them sort properly. So instead i set them to sort from number 1 and up. So I changed the line in checkout_payment.php to:

 

<?php

? if (sizeof($selection) > 1) {

? ? echo tep_draw_radio_field('payment', $selection[$i]['id'], '$i==1');

? } else {

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

? }

?>

 

I have two payment methods with a sort order of 1 & 2, but with the above code it always selects the second option no matter which way I sort it.

Link to comment
Share on other sites

(...)For one if I set any of the options to sort as 0, none of them sort properly.

So instead i set them to sort from number 1 and up.

(...)

    echo tep_draw_radio_field('payment', $selection[$i]['id'], '$i==1');

(...)

I have two payment methods with a sort order of 1 & 2, but with the above code it always selects the second option no matter which way I sort it.

Try sorting them as 1,2,3,...

and leaving that line as "true". <{POST_SNAPBACK}>

 

SGershon

If at first you don't succeed, you must be a programmer.

 

Tip Posted: Languageless Reviews

Link to comment
Share on other sites

  • 2 weeks later...
(...)For one if I set any of the options to sort as 0, none of them sort properly.

So instead i set them to sort from number 1 and up.

(...)

    echo tep_draw_radio_field('payment', $selection[$i]['id'], '$i==1');

(...)

I have two payment methods with a sort order of 1 & 2, but with the above code it always selects the second option no matter which way I sort it.

Oh!

I think I just understood what you meant!

 

Try: Use $i==0, without quotes, and without '1's.

 

SGershon

If at first you don't succeed, you must be a programmer.

 

Tip Posted: Languageless Reviews

Link to comment
Share on other sites

  • 4 months later...
  • 1 month later...
  • 1 year later...

I could not get it to work, the sort order was correct in admin 1,2,3 but the bottom payment method was always selected.

 

The following worked for me:

 

<?php

if (sizeof($selection) > 1) {

echo tep_draw_radio_field('payment', $selection[$i]['id'], $i==0);

 

} else {

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

}

?>

Link to comment
Share on other sites

  • 1 month later...
<?php

if (sizeof($selection) > 1) {

echo tep_draw_radio_field('payment', $selection[$i]['id'], $i==0);

 

} else {

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

}

?>

This also worked for me and I have the order set to 0, 1, 2.

Samuel Mateo, Jr.

osC 2.2 MS2

Installed Mods:

WYSIWYG HTMLArea 1.7 | Basic Template System 1.0 | osC-Affiliate | OSC-SupportTicket

Featured Products 1.3 | LoginBox 5.2 | LatestNews 1.1.3 | Extras for IE

Link to comment
Share on other sites

  • 2 weeks later...
This also worked for me and I have the order set to 0, 1, 2.

 

The key to making this work is to drop the quotes and simply type in $i==0

 

I was having the same problem of the bottom payment option being selected, until I removed the quotes '$i==0' and replaced with just $i==0

 

Works like a charm now. Thanks all for sharing

 

- Sean

Link to comment
Share on other sites

  • 1 month later...
Hi,

 

I can´t see pay method select on user options. I´m modifing chackout_payment.php but it don´t work.

Any idea?

 

Thanks,

The code should look like this

 

<?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";

// Start Setting a default payment

} else {

 

if ( (!$payment) && ($i==0) ) {

 

echo ' <tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";

// End Setting a default payment

} else {

echo ' <tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";

} // Setting a default payment

}

?>

<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'], $i==0); // $i==0 Setting a default payment

} else {

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

}

?>

Link to comment
Share on other sites

The key to making this work is to drop the quotes and simply type in $i==0

 

I was having the same problem of the bottom payment option being selected, until I removed the quotes '$i==0' and replaced with just $i==0

 

Works like a charm now. Thanks all for sharing

 

- Sean

 

Many thanks - this is just what I was looking for - lovely.

 

Many kind regards,

 

Gwyn

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...

Hi,

 

I have tried alll the suggestions made on this page, but no matter which one I try, Credit/Debit card payment option always gets chosen/highlighted/selected

 

Its so strange.

 

I want the paypal one to be chosen, i have sorted it as 0 and creditcard to 1 and cheque to 2 but it doesnt work

Link to comment
Share on other sites

I use a differnt approach, not with the radio true/false

 

I just add in the upper part of the code, right after the payment classes are declared, a default payment. You need to use the same term as the payment class has, so it may be paypal_ipn

 

// load all enabled payment modules
 require(DIR_WS_CLASSES . 'payment.php');
 $payment_modules = new payment;

 $payment = 'paypal';

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

  • 2 weeks later...
I use a differnt approach, not with the radio true/false

 

I just add in the upper part of the code, right after the payment classes are declared, a default payment. You need to use the same term as the payment class has, so it may be paypal_ipn

 

// load all enabled payment modules
 require(DIR_WS_CLASSES . 'payment.php');
 $payment_modules = new payment;

 $payment = 'paypal';

 

 

This worked great! Thank you.... I actually searched your book for this... Should have started here.

Link to comment
Share on other sites

  • 1 month later...
This worked great! Thank you.... I actually searched your book for this... Should have started here.

 

I used "cc" for credit card default (instead of paypal) as Monika suggested... Works Great!!

THANK YOU!

define('PROJECTS', 'Something that goes on forever!');

Link to comment
Share on other sites

  • 1 month later...
I use a differnt approach, not with the radio true/false

 

I just add in the upper part of the code, right after the payment classes are declared, a default payment. You need to use the same term as the payment class has, so it may be paypal_ipn

 

// load all enabled payment modules
 require(DIR_WS_CLASSES . 'payment.php');
 $payment_modules = new payment;

 $payment = 'paypal';

 

This works very well, but I prefer the customers selection remains if they go back to the payment page. For instance, if Credit Card is selected by default, and they select PayPal, then go back, I prefer that PayPal remains selected until they change it. This is how I did it:

 

// load all enabled payment modules
 require(DIR_WS_CLASSES . 'payment.php');
 $payment_modules = new payment;

// Select Credit Card as default payment method if none selected
 if (!isset($payment)) {
$payment = 'authorizenet_aim';
 }

 

Just replace 'authorizenet_aim' with whatever you want the default payment method to be ('paypal_ipn' or whatever). If you already have RC1 installed, that's all you have to do. If not, there is a change in RC1 that I believe you need to do (I haven't tested without the change, so I'm not sure).

 

Find this:

 

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

 

 

And replace with this:

 

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

Link to comment
Share on other sites

  • 2 months later...
This works very well, but I prefer the customers selection remains if they go back to the payment page. For instance, if Credit Card is selected by default, and they select PayPal, then go back, I prefer that PayPal remains selected until they change it. This is how I did it:

 

// load all enabled payment modules
 require(DIR_WS_CLASSES . 'payment.php');
 $payment_modules = new payment;

// Select Credit Card as default payment method if none selected
 if (!isset($payment)) {
$payment = 'authorizenet_aim';
 }

 

Just replace 'authorizenet_aim' with whatever you want the default payment method to be ('paypal_ipn' or whatever). If you already have RC1 installed, that's all you have to do. If not, there is a change in RC1 that I believe you need to do (I haven't tested without the change, so I'm not sure).

 

Find this:

 

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

And replace with this:

 

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

Thank you for posting, this works on my patched RC1, the "old" stopped working.

Link to comment
Share on other sites

  • 2 months later...
If instead of 'true' you put $i==0, then the top payment method will be selected. I'm sure it will work with numbers other than 0 if you want something other than the top one selected.

 

 

If anyone is using fast easy checkout, and are trying to implement this, please note that you need to add the above code to payment_box.php (/catalog/includes/fec/) NOT checkout_payment.php to get it to work !!

 

Hope that helps someone

 

Ronnie

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...