Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Credit Card Javascript help


tedmcdonald

Recommended Posts

I really need to get some help on this one.

 

When my customers go to checkout, no payment method is selected. Many of my customers fill out the credit card information, hit continue and are then sent back to the checkout page asking them to select payment type (via radio button).

 

Is there some way to make it so that the Credit Card payment radio button is automatically (by default) selected when they enter the checkout page?

 

Please help if you can.

 

Best Regards, Ted

Link to comment
Share on other sites

Depending on whether or not CC is the first option or not.. adding this line

 

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

 

to checkout_payment.php in the <BODY> tag should do the trick! :)

Link to comment
Share on other sites

Howdy Zilla

 

Thank you very much. You have been a big help for me today.

 

At first your code would not work, then I looked and added a " to the end; thus it should be:

 

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

 

Thanks again Zilla.

 

Best Regards, Ted

Link to comment
Share on other sites

Cool works perfect!

 

you wouldnt also know how to make the radio button on the delivery options be selected once you select a type of payment.

EG If they select COD as a payment I want a particular type of shipment to be selected and not being able to be changed.

 

Hope you understand and I didnt confuse you

Link to comment
Share on other sites

This will change as soon as the updated checkout procedure is commited to CVS.

 

But javascript allows you to do many things. For example.. if you select payment option A, then shipping options B & C turn greyed out and are "disabled".

 

I can't write out javascript code for every possible combination. Use what I have given here as well as a search on google to try and figure it out. Specifically, you will need a trigger (onLoad, onClick, onChange, etc.) and an action. See http://www.houseofscripts.com/scripts/java...s/disablebm.htm for other examples.

Link to comment
Share on other sites

I tried to add this:

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

 

in the body <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" TRIED HERE>

 

and also directly below that and it would not work. I used

<script language = "javascript">

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

</script>

 

in both areas and it did not want to. Is it because I only have one type of payment? (CC#).

 

I am running 2.2

Link to comment
Share on other sites

Not sure about the new checkout procedure.. but on the old one... if you only had one payment option.. there isn't any option!

 

So, not 100% sure what you are trying to do..

 

The <body ... TRIED HERE> is where that code belongs..

<script>

onload="CODE"

</script> Is not valid.

Link to comment
Share on other sites

  • 1 year later...

I added the following to checkout_payment.php, and got it to work:

 

Before:

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">

 

After:

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" onload="java script:document.checkout_payment.payment[0].click();return true;">

Link to comment
Share on other sites

  • 1 year later...
I added the following to checkout_payment.php, and got it to work:

 

Before:

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">

 

After:

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" onload="java script:document.checkout_payment.payment[0].click();return true;">

 

 

This is an post for an older version of Osc (and did not work when we tried on 2.2) - does anyone know how to mod the checkout_payment.php to get the credit card radio button auto-selected if a customer starts typing in any of the credit card fields?

 

Even if I could get the first radio button checked by default (which is the credit card choice), that would eliminate some senseless errors presented to customers.

 

Thanks!

 

Derek-Paul

Edited by ModManOSC
Link to comment
Share on other sites

  • 2 months later...

If you are using BTS you can do the following:

 

In main_page.tpl.php

 

find

 

<body>

 

and

 

replace with

 

<?php
// Added to auto select first payment option - usually credit card
if ($PHP_SELF == "/checkout_payment.php"){
  echo '<body onload="javascript:document.checkout_payment.payment[0].click();return true;">';
} else {
  echo '<body>';
}
?>

 

Hope this can help someone.

Link to comment
Share on other sites

  • 2 months later...

Hi All,

I have a number of customers who are entering their cc details into the cc feild but accidentely selecting another form of payment therefore we never receive their CC details.

I am wondering if anyone can help me put a piece of javascript which will automatically select the CC payment option when they enter the cc number.

I am using MS1 loaded. Please let me know what code you need to see to help if needed

 

Thanks heaps!!

 

Wing

Link to comment
Share on other sites

This is an post for an older version of Osc (and did not work when we tried on 2.2) - does anyone know how to mod the checkout_payment.php to get the credit card radio button auto-selected if a customer starts typing in any of the credit card fields?

 

Even if I could get the first radio button checked by default (which is the credit card choice), that would eliminate some senseless errors presented to customers.

 

Thanks!

 

Derek-Paul

 

Sorry for bringing up a old thread but does anyone know how to make it auto select the credit card if the customer enters details into the cc field.

I already have the auto cc select on load but some customers accidentely select other payment options and then decide to enter cc details which results in no cc details being received.

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...