Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

User Friendly Credit Card Field Mod

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 11-29-2006, 11:09 AM
 
sstillwell@aerostich.com sstillwell@aerostich.com is offline
 

eXpert
  
Join Date: Jun 2004
Location: Duluth, MN
Posts: 242
 

Default User Friendly Credit Card Field Mod

In his book "Don't Make Me Think" by Steve Krug (go read it), he states things that Diminish the Good Will of our customers.

"Punishing me for not doing things your way. I should never have to think about formatting data: whether or not to put dashes in my Social Security number, spaces in my credit card number, or parentheses in my phone number. Many sites perversely insist on no spaces in credit card numbers, when the spaces actually make it much easier to get the number right. Don't make me jump through hoops just because you don't want to write a little bit of code."

So, in the default Xcart install, the credit card field has these words.

Credit card number (no spaces or dashes)

Why don't we just implement some Javascript that strips out the none numbers when they try to submit. EASY.

Obligatory Disclaimers
1. I am using Credit Card verification, I don't think this will work without enabling that.
2. I use 4.0.12, it may be fixed in a new version.
3. This could completely destroy your Xcart store (but probably not).

Ready?

Open skin1/check_cc_number_script.tpl

Change this code
Code:
function checkCCNumber(field_cc,field_accepted) { var cc=field_cc.value; var accepted=null; if(field_accepted!=null) accepted=new Array(card_types[field_accepted.value]); if (isCreditCard(cc,accepted)) return true; else { alert(txt_cc_number_invalid); field_cc.focus(); field_cc.select(); return false; } }

To this code
Code:
function checkCCNumber(field_cc,field_accepted) { var original_cc=field_cc.value; var cc=field_cc.value.replace(/[^\d]/g, ''); var accepted=null; if(field_accepted!=null) accepted=new Array(card_types[field_accepted.value]); if (isCreditCard(cc,accepted)){ field_cc.value = cc; return true; }else { alert(txt_cc_number_invalid); field_cc.focus(); field_cc.select(); return false; } }

Basically, this just strips out the none numbers from the Credit card number and then if it passes the check, writes it back to the Credit Card input field before proceeding to submit the form.

Man that was easy.
__________________
No longer using Xcart, was good while it lasted.
Reply With Quote
  #2  
Old 11-29-2006, 06:38 PM
 
ryan c. ryan c. is offline
 

Advanced Member
  
Join Date: Sep 2002
Posts: 58
 

Default Re: User Friendly Credit Card Field Mod

WOW That was easy! and works like a charm.

Thanks!@
__________________
Version 4.1.8
Reply With Quote
  #3  
Old 08-14-2007, 10:10 AM
 
ryan c. ryan c. is offline
 

Advanced Member
  
Join Date: Sep 2002
Posts: 58
 

Default Re: User Friendly Credit Card Field Mod

can this work in 4.1 seems the Open skin1/check_cc_number_script.tpl has changed
__________________
Version 4.1.8
Reply With Quote
  #4  
Old 08-18-2007, 01:24 PM
 
Sisom Sisom is offline
 

eXpert
  
Join Date: Sep 2006
Posts: 310
 

Default Re: User Friendly Credit Card Field Mod

I'd like to use this too, I have 4.1.0.
The code is now in /check_cc_number_script.js
not/check_cc_number_script.tpl

The code is as follows:

/*
Check CC number
*/
function checkCCNumber(field_cc, field_accepted) {
var cc = field_cc.value;
var accepted = (field_accepted != null) ? [card_types[field_accepted.value]] : null;

if (isCreditCard(cc, accepted))
return true;

alert(txt_cc_number_invalid);
field_cc.focus();
field_cc.select();
return false;
}



I tried this, but it didn't work:

/*
Check CC number
*/
function checkCCNumber(field_cc, field_accepted) {
var original_cc=field_cc.value;
var cc=field_cc.value.replace(/[^\d]/g, '');
var accepted = (field_accepted != null) ? [card_types[field_accepted.value]] : null;

if (isCreditCard(cc, accepted)){
field_cc.value = cc;
return true;
}else {
alert(txt_cc_number_invalid);
field_cc.focus();
field_cc.select();
return false;
}
}

If anybody could fix this it would be very useful, can anybody help?
__________________
X-Cart Gold Version 4.3.2
Reply With Quote
  #5  
Old 01-09-2008, 01:07 PM
 
jeanne jeanne is offline
 

Advanced Member
  
Join Date: Aug 2004
Posts: 85
 

Default Re: User Friendly Credit Card Field Mod

Works as posted previously in 4.1 using cc verification.
File is different - you need to change the function in

skin1/check_cc_number_script.js
__________________
Jeanne
4.1.8 Gold
Reply With Quote
  #6  
Old 01-09-2008, 02:30 PM
 
sk8conz sk8conz is offline
 

Advanced Member
  
Join Date: Dec 2007
Posts: 31
 

Default Re: User Friendly Credit Card Field Mod

Works fine in 4.1.9
__________________
4.3.1
rounded white template
one page checkout
Reply With Quote
  #7  
Old 02-23-2008, 03:49 PM
 
rhu rhu is offline
 

Advanced Member
  
Join Date: Dec 2007
Posts: 63
 

Default Re: User Friendly Credit Card Field Mod

This looks like a very useful mod, but how do you enable credit card verification?
__________________
X-Cart 4.3.0 Gold
Reply With Quote
  #8  
Old 02-24-2008, 10:28 AM
  bullfrog's Avatar 
bullfrog bullfrog is offline
 

eXpert
  
Join Date: Oct 2004
Location: Oregon, USA
Posts: 366
 

Default Re: User Friendly Credit Card Field Mod

When (if?) you get a merchant account and gateway, and the gateway is properly set up in X-cart, the credit card verification will happen automatically. In Admin, go to 'Payment methods'. Look at the pulldown menu at the bottom where you select a payment gateway.

The merchant account is who charges your customers and sends the money to you. The gateway account is who verifies that the card is good and sends the authorization to charge to the merchant account. For some accounts, the merchant and gateway are the same.

If you don't have card verification, and customer can type in anything for a card number, including text and spaces, and X-cart will accept it.
__________________
Bullfrog ~~~ X-Cart Gold v4.7.2 (2) v4.7.8. ⌠If the road is easy, you're likely going the wrong way.■ ― Terry Goodkind
Reply With Quote
  #9  
Old 02-24-2008, 03:13 PM
 
rhu rhu is offline
 

Advanced Member
  
Join Date: Dec 2007
Posts: 63
 

Default Re: User Friendly Credit Card Field Mod

Thank You bullfrog!
__________________
X-Cart 4.3.0 Gold
Reply With Quote
  #10  
Old 02-24-2008, 09:35 PM
 
EN4U EN4U is offline
 

eXpert
  
Join Date: Feb 2008
Location: AZ
Posts: 379
 

Default Re: User Friendly Credit Card Field Mod

Nice..I was looking to do this to mine, yet the code you say to change, doesnt match up to what mine is now......So im unsure what to do

This what mine shows

{* $Id: check_cc_number_script.tpl,v 1.21.2.1 2007/09/12 12:21:17 ferz Exp $ *}
<script type="text/javascript" language="JavaScript 1.2">
<!--
var card_types = new Array();
var card_cvv2 = new Array();
{foreach from=$card_types item=c}
card_types["{$c.code}"] = "{$c.type}";
card_cvv2["{$c.code}"] = "{$c.cvv2}";
{/foreach}
var force_cvv2 = {if $payment_cc_data.disable_ccinfo eq "N" && ($config.General.check_cc_number eq "Y" || $smarty.get.mode eq 'checkout')}true{else}false{/if};
var txt_cc_number_invalid = "{$lng.txt_cc_number_invalid|strip_tags|escape:jav ascript}";
var current_year = parseInt(('{$smarty.now|date_format:"%Y"}').replac e(/^0/gi, ""));
var current_month = parseInt(('{$smarty.now|date_format:"%m"}').replac e(/^0/gi, ""));
var lbl_is_this_card_expired = "{$lng.lbl_is_this_card_expired|strip_tags|escape: javascript}";
var lbl_cvv2_is_empty = "{$lng.lbl_cvv2_is_empty|escape:javascript}";
var lbl_cvv2_isnt_correct = "{$lng.lbl_cvv2_isnt_correct|escape:javascript }";
var lbl_cvv2_must_be_number = "{$lng.lbl_cvv2_must_be_number|escape:javascript}" ;
-->
</script>
{include file="main/include_js.tpl" src="check_cc_number_script.js"}
__________________
Regards, Dan
X-Cart Gold Version 4.1.10

1 - One page checkout
2 - Image Generator
3 - CSDEO Pro
4 - Shop By Price
5 - Next - Previous
6 - On Sale
7 - Shop By Price

8 - Froogle & Google Base Feed
9 - Buy Together
10 - Customer Loyalty Points
11 - Customer Reward Points
Customer Reward Points Referral Add-on
12 - Product Reviews
13 - Other Custom Modifications
----------------------
http://www.townsqjewelry.com/
http://www.eroticnights4u.com/ <---- Adult Oriented - Toys
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 05:39 PM.

   

 
X-Cart forums © 2001-2020