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

Splitting credit card number on invoice

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 02-03-2005, 08:19 AM
 
DanUK DanUK is offline
 

X-Adept
  
Join Date: Dec 2003
Location: UK
Posts: 800
 

Default Splitting credit card number on invoice

Is there a way to make the credit card more readable on the invoice?

At the moment it is outputted as one long number and this can cause delays in offline processing -usually the admin staff manually put a space in after each group of 4 numbers after they've decrypted and pasted into the text editor, ready for inputting into the PDQ. What I'm looking for is a bit of code that will take the cc number and split or put a space in after every 4 digts until it reaches the end e.g. xxxx xxxx xxxx xxxx

Can it be done?

Thanks

Dan
__________________
4.4.2

and

4.6.1
Reply With Quote
  #2  
Old 02-04-2005, 04:23 AM
 
DanUK DanUK is offline
 

X-Adept
  
Join Date: Dec 2003
Location: UK
Posts: 800
 

Default

OK, so far I know the CC info is pulled from the encrypted "details" field in the orders table. It looks a bit too complex for me to extract that information and then try to format the cc number. Instead I was thinking of pulling the cc number itself, maybe from the customers table but :

Code:
{$customers.credit_card}

in the orcer_invoice.tpl file doesn't work. My plan was to extract the number and use some smarty code to split the number and display it on screen...make sense? Can the cc number be displayed in a template on it's own?

Thanks

Dan
__________________
4.4.2

and

4.6.1
Reply With Quote
  #3  
Old 09-01-2005, 06:06 AM
 
markjkaufman markjkaufman is offline
 

Newbie
  
Join Date: Aug 2005
Posts: 8
 

Default

Man, I SO want to do this too.

My wife complains bitterly about the single long credit card number .

Anyone with a little time on their hands figured this one out?
__________________
Mark J Kaufman
X-Cart Gold 4.0.13
Linux, Apache, PHP 4.4.0, Perl 5.006001
LisaKaufmanDesigns.com
Reply With Quote
  #4  
Old 09-01-2005, 06:37 AM
 
DanUK DanUK is offline
 

X-Adept
  
Join Date: Dec 2003
Location: UK
Posts: 800
 

Default

This is what I got from X-Cart -this works for me and I use offline processing -you may want to give it a go after backing up first!

"Changing of credit card number customization" INSTRUCTIONS

1. The file you need to modify is following:
%PATH_TO_YOUR_XCART%/include/func.php

2. Insert two functions at end of file

Code:
########################################################## # # <Task 6621: Changing of credit card number> # function func_expand_string ($s, $count = 4) { # # comment: in PHP 5 str_split($s, $count) can be used # $s = preg_replace("/ /","", $s) ; if(!$s) return "" ; if(!is_numeric($count) || $count <= 0 ) $count = 4 ; $arr = preg_split("//",$s, -1, PREG_SPLIT_NO_EMPTY) ; if($arr && is_array($arr)) { $tmp = array() ; $i = 0 ; foreach($arr as $k=>$v) { $tmp[$i] .= $v ; if((($k+1)%$count) == 0 ) $i++ ; } } $return = implode(" ", $tmp) ; return $return ; } function func_get_modified_details ($details) { preg_match_all("/\\nCard number: (.*)\\n/",$details,$cc) ; $cc = func_expand_string ($cc[1][0],4) ; $return = preg_replace("/\\nCard number: (.*)\\n/","\nCard number: ".$cc."\n",$details) ; return $return ; } # / <Task 6621: Changing of credit card number> #############################################################

3. You should find following function: "func_select_order"

and change following lines

Code:
###### BEFORE #################### $order["details"]=text_decrypt($order["details"]); $order["details"]=stripslashes($order["details"]); $order["notes"]=stripslashes($order["notes"]); ##################################
to

Code:
###### AFTER #################### $order["details"]=text_decrypt($order["details"]); $order["details"]=stripslashes($order["details"]); # # <Task 6621: Changing of credit card number> # $order["details"] = func_get_modified_details ($order["details"]) ; # / <Task 6621: Changing of credit card number> $order["notes"]=stripslashes($order["notes"]); ##################################
That is all.

Important note.
In new function:

Code:
function func_get_modified_details ($details) { preg_match_all("/\\nCard number: (.*)\\n/",$details,$cc) ; $cc = func_expand_string ($cc[1][0],4) ; <----------------------------------------------------------- $return = preg_replace("/\\nCard number: (.*)\\n/","\nCard number: ".$cc."\n",$details) ; return $return ; }

Turn your attention on second parameter of this function.
This argument shows how many symbols must be in group.
As example if you set it to 5 - output string will be something like: "XXXXX XXXXX XXXXX XXX" without quotes
If you set it to 2 - output string will be: "XX XX XX XX XX XX XX XX"

So, if you want to break the number on another groups - just change this value.

Hope that does the trick, as I say it works for me.

Dan
__________________
4.4.2

and

4.6.1
Reply With Quote
  #5  
Old 09-03-2005, 07:45 PM
 
markjkaufman markjkaufman is offline
 

Newbie
  
Join Date: Aug 2005
Posts: 8
 

Default

How cool are YOU! How did you "get" this from X-Cart?

We have very similar versions of X-Cart, so this should apply pretty directly to me, too. How exciting!

I'll back up func.php and try this sometime when it's quiet in the next couple of days. I'll follow up here once it's working.

We do offline processing, so that's nice too.
__________________
Mark J Kaufman
X-Cart Gold 4.0.13
Linux, Apache, PHP 4.4.0, Perl 5.006001
LisaKaufmanDesigns.com
Reply With Quote
  #6  
Old 09-03-2005, 08:07 PM
 
markjkaufman markjkaufman is offline
 

Newbie
  
Join Date: Aug 2005
Posts: 8
 

Default

Just took a quick look at func.php. Looks like they added a small enhancement between our two versions of X-Cart. The BEFORE code is now:

Code:
$order["details"]=text_decrypt($order["details"]); if($order["details"] === false) { $order["details"] = func_get_langvar_by_name("txt_this_data_encrypted"); } $order["details"]=stripslashes($order["details"]); $order["notes"]=stripslashes($order["notes"]);

It's clear how to deal with this very minor change, so I'll try it real soon!

Thanks again. You rock!
__________________
Mark J Kaufman
X-Cart Gold 4.0.13
Linux, Apache, PHP 4.4.0, Perl 5.006001
LisaKaufmanDesigns.com
Reply With Quote
  #7  
Old 09-24-2005, 02:03 PM
  ShishaPipeUK's Avatar 
ShishaPipeUK ShishaPipeUK is offline
 

Senior Member
  
Join Date: Jul 2005
Location: London, England.
Posts: 118
 

Default Works Great, thanks

Just to say this mod works great on 4.0.16, well done.

Our sales team are very happy with the spaces between 4 digits of the credit card numbers, makes life much easier.

Thanks again.
__________________
Apache/2.0.55 (Red Hat) & MYSQL Server: 5.0.24
PERL: 5.008005 / PHP: 4.4.4 - 4.3.1 X-CART

Shop carts at
http://www.nightscene.co.uk/shop/home.php
http://www.theshisha.net/shopcart/home.php
http://www.system-maintenance.com/maint/home.php
http://www.tabac4u.com
Reply With Quote
  #8  
Old 09-25-2005, 11:21 PM
 
markjkaufman markjkaufman is offline
 

Newbie
  
Join Date: Aug 2005
Posts: 8
 

Default

HEY, just verified the code I quoted above from my X-Cart is what's really on my site. I'm no expert, but the three equals signs should be just two, right? So I should fix that when I add the recommended code, eh?


Quote:
Originally Posted by markjkaufman
Just took a quick look at func.php. Looks like they added a small enhancement between our two versions of X-Cart. The BEFORE code is now:

Code:
$order["details"]=text_decrypt($order["details"]); if($order["details"] === false) { $order["details"] = func_get_langvar_by_name("txt_this_data_encrypted"); } $order["details"]=stripslashes($order["details"]); $order["notes"]=stripslashes($order["notes"]);

It's clear how to deal with this very minor change, so I'll try it real soon!

Thanks again. You rock!
__________________
Mark J Kaufman
X-Cart Gold 4.0.13
Linux, Apache, PHP 4.4.0, Perl 5.006001
LisaKaufmanDesigns.com
Reply With Quote
  #9  
Old 09-26-2005, 03:24 PM
 
markjkaufman markjkaufman is offline
 

Newbie
  
Join Date: Aug 2005
Posts: 8
 

Default

I just applied this mod and tested it. It works GREAT on my installation too. Many thanks again DanUK!

Now just have to remember to fix the "===" issue once I hear it's the right thing to do...
__________________
Mark J Kaufman
X-Cart Gold 4.0.13
Linux, Apache, PHP 4.4.0, Perl 5.006001
LisaKaufmanDesigns.com
Reply With Quote
  #10  
Old 09-27-2005, 03:15 AM
  shan's Avatar 
shan shan is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Birmingham, UK
Posts: 6,163
 

Default

moved to custom mods
__________________
Looking for a reliable X-cart host ?
You wont go wrong with either of these.

EWD Hosting
Hands On Hosting
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



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 06:59 AM.

   

 
X-Cart forums © 2001-2020