WP-eCommerce Gold Cart Plug-In Hack
A friend of mine asked if I could help him out with a project he was working on. He had a client who was trying to sell some products online and the previous developers gave him exactly what he asked for. And unfortunately all they asked for was a way that their visitors could fill out a form to purchase a product. They didn't ask for the ability to view orders, update products, customer data retention, etc.
The problem was that the client really wanted a shopping cart. Something that he could use to manage his business, but because my friend and his client are a little new to the online world, they didn't specify what they wanted to the developer. And unfortunately this developer didn't take any initiative to offer additional options and suggestions.
So I took a look at the website and I realized what the developer had done, which to say the least, wasn't a lot. They basically had a form, and a PHP page that processed the form data. They didn't even take the time to e-mail the customer a receipt. Sheesh. Oh well, I told my friend that I'd look around and see if there was an off-the-shelf PHP solution that could help them out. I'll be the first to tell you that I do not specialize in coding in PHP. My background is ColdFusion, but I've done a few little PHP sites in the past and to be quite honest, I'm not scared to dive into PHP and figure something out. I have a theory, and that is if you know programming logic, you can pretty much program in any language as long as you have good reference material. Hello Google!
ColdFusion Components and Var Scoping Trick
Var scoping is essential when dealing with ColdFusion Components. You can get weird results or even some hard-to-track errors if you don't do this. I'm not privy as to why this happens, I just know that it does. It's one of those mysteries that I just never bothered to research. All I know, is that sometimes it's a pain in the butt, especially when your writing a fairly complex function and you forgot to var scope an "i" in a cfloop or some other quick and dirty variable you made.
Well a few months back, I started doing something with my function variables, that I thought I would share. Not only does it solve my var problem, but it winds up making the top of my function shorter (I'm a stickler for cleanish looking code). Essentially I create a generic local struct in the begining and I'm sure to var scope it, like so:
<cfset var local = StructNew() />
Reason #592 why I hate Internet Explorer
My last step on any website design is to go through it and make sure that it works and look correct in the various flavors of Internet Explorer. I can't really say that the time spent doing this is blissful. I compare it to going to the dentist, because I never know what I'm going to find and when I do it's rarely good.
So today as I was debugging, what I thought was a very simple, JavaScript page. I came across one of those nifty "This method or function is undefined" errors from the Internet Explorer debugger. And as we all know, the IE debugger is as worthless as playing "I Spy" with a blind person.
JSLint Keeps Warning Me About Calling a Function Within A Loop
I use JSlint to check my JavaScript on a regular bases, most of the time it just for light scripts that I just need to check to make sure that I don't have a typo. But occasionally I check more robust scripts and I find myself presented with an error message that says "Problem at line XXX character XX: Be careful when making functions within a loop. Consider putting the function in a closure".
I know I've come across this in the past and I know that I fixed it, but the problem is I can never remember what the heck I did to fix it. Then I remembered that I have a blog! I can just put it there and never have to search far for the answer ever again!
Here's the problem:
function myHappyFunction() {
var a = document.getElementsByTagName('a');
for(var i = 0; i <= a.length - 1; i++) {
a[i].onclick = function(e) {
alert('Ouch!');
};
}
}
ColdFusion Site Timeouts? Check To See If Your Database Server.
Awhile back I had switched one of my clients websites from CrystalTech to HostMySite. The site on CrystalTech was inaccessible at least 2 times a day, due to either a ColdFusion/JRun restart or some other problem. Talking it over with the client, we decided it would be a good time to update their code and move it on over to HostMySite.
Almost immediately, we noticed some speed gains, but again we started to see that the site would go down once a or twice a day. I was starting to wonder if it was my code, but I had been running it internally on my server with no problems at all. My server is about 7 years old with only 1 gig of ram. Surely, if it could run on this junker, it should run fine on our ISP's shared server.