You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.
I have created a new custom field ( see topic 9419) that requires the customer to enter the last four digits of their telephone number by adding this code per the above post to ste_checkout.pl at about line 1792 where a check is made to see if all the required fields have been completed.
After foreach $line (@requiredfields){
I have added this line:
if ($line eq "tracking_customfour") {$line =~ s/[^0-9]//gs;}
This strips out everything except numbers. If there is only white space left then the programme errors out.
Even when I put numbers in the field CCP5.1 complains that I have not completed all the required fields. If I made custom four 'not required' then the problem goes away.
I cannot see what is wrong with the syntax of the expression above.
Any help gratefully received.
Offline
I'm not entirely sure how Nick was implementing this... it might have been a version difference or something, but that just doesn't look right to me. The regex is right, but I don't see how that implementation would work - it's stripping the non-numeric characters from the variable name, not the value. I would try it a bit differently. Remove the change you just did and look a little further down the code (maybe 10 lines or so) to find this:
} elsif ($line =~ /custom/ || $line =~ /other/) { $fd_value = $q->param($line); } else {
I would try changing that to:
} elsif ($line =~ /custom/ || $line =~ /other/) { $fd_value = $q->param($line); if ($line eq "tracking_customfour") {$fd_value =~ s/[^0-9]//gs;} } else {
I haven't tested this at all, but the theory looks right. Good luck!
Offline
Works a treat!
Many thanks for your quick reply.
Regards,
K Ryan
KPR i-Services Ltd.
Offline
You're very welcome. As a side note, you can simplify that regex a bit, if you care to. This will work just the same:
s/\D//g
Offline
Hi,
What was the original post? Please.
Offline
Offline
Thank You
Offline