Words about stuff, and things related to stuff

Add alternate pricing option to Cartweaver

A Cartweaver user asked how he can add alternate pricing to his Cartweaver ecommerce site. He was understandably concerned about the need to edit the database, and how much code editing might be involved. But if you take a systematic approach, it is pretty straightforward.

The first part of setting up any alternate pricing system is to get that info into your database and admin, so you can work with it. In this case, since the basic goal is to duplicate the existing 'price' system, that is exactly what we are going to do.


Marking current menu link with jQuery for CartWeaver categories

Working on a heavily-modified Cartweaver Coldfusion E-Commerce shopping cart site, I have created a database-driven navigation menu containing links to each category. When a user clicks a link, the products in that category are displayed, and the menu link for that category is highlighted via a special 'currentLink' css class.

Now of course I could use CF to add ' class="currentLink" ' to the current category's menu option, but I am not doing this particular menu that way. Besides, it is just as easy with jQuery!

view plain print about
1<cfif cgi.script_name contains 'results.cfm' AND isDefined('url.category') and url.category gt 0>
2<cfsavecontent variable="highlight">
3<script type="text/javascript">
5$('.sideNav li a').removeClass('currentLink');
6$('.sideNav li a[href=results.cfm?category=<cfoutput>#url.category#</cfoutput>]').addClass('currentLink');
7//end jQuery
11<cfhtmlhead text="#highlight#">

Simple enough - if we are on the 'results' page, and a category is defined in the url, remove the 'currentLink' class from all existing menu items, find the one where the 'href' attribute matches the current pagename and category, and add the class back to that link. Done.

The use of cfsavecontent and cfhtmlhead means I can put this right below the code that calls in my custom nav tag, for easy fine-tuning right where i need it (rather than in an external scripts file).

Quick , easy, and done in a flash with jQuery!

Modify CartWeaver functionality based on customer login

A CartWeaver user asked the question:

"I want to have viewers Register (or, log in if they've already registered) before they can see anything in the cart. How would I do this?"


Here's my quick answer:

In Cartweaver, the trigger for whether someone is logged in can be found in the "client.customerID" variable.

So, any logic that you want to base on 'if a customer is logged in', might look like this:

<cfif isDefined('client.customerID') AND client.customerID gt 0>
(or redirect to login page.. whatever)

When someone logs in, their 'ID' gets stored in the 'client' scope.
(Simply put, a variable that follows them around during their session on the site).
If they have a clientID defined and it is greater than '0', we can assume they have logged in already.

( I use isDefined() as a safeguard, but actually the default for this variable, if not logged in, is simply 0. )

You can safely wrap this line around anything you want to show ONLY if somebody is logged in

<cfif isDefined('client.customerID') AND client.customerID gt 0>

And if you only want stuff to show when the person is NOT logged in

<cfif (isDefined('client.customerID') AND client.customerID eq 0) OR not isDefined('client.customerID')>

Again, simpler version would be just:
<cfif client.customerID eq 0>

but I like to make sure the var exists when giving code examples,
so you can put that code anywhere in your site you like.


Firefox: select onChange() when using keyboard - a solution

Working on a CartWeaver site, modifying part of the routine whereby different prices are shown on the page when selecting various options from a dropdown list on the product details page, I noticed that in Firefox, the 'onchange' event of the select list only fires if using a mouse, or when tabbing out of the select box using the keyboard ( select list loses focus).

I guess it's always been this way, I just haven't noticed until now. Fortunately there is a very easy fix - append the 'losing of focus' to the 'onkeyup' event, so that either keyboard or mouse have the same effect, causing the browser to register the 'change'.

Original select list is like this:

<select name="sel" id="sel#i#" onchange=" ( function here )" >

Adding just a bit of code for the onkeyup, like so:

<select name="sel" id="sel#i#" onchange=" ( function here )" onkeyup="this.blur();this.focus();">

we now have a list that loses then regains focus everytime a key is pressed (while it has focus), i.e. using the keyboard to move up or down through the options now triggers a split-second loss and regaining of focus, which is enough to trigger the 'onchange()' in firefox. I love a good easy fix!

Thanks to Sanket Vasa for the tip


Some alternatives to Adobe NNTP Newsgroups

As many dedicated web developers mourn the passing of the NNTP interface for Adobe's support forums ( formerly nntp://forums.adobe.com ), I'd like to extend a hearty welcome, inviting all web developers, friends and interested cohorts to join myself and a number of other seasoned web professionals in some popular NNTP-friendly alternative hangouts.


In addition to general web developer newsgroups, there are some specialized groups for ColdFusion, javascript (ok, mostly jQuery), all three flavors of CartWeaver (E-commerce) and more.

Every one of the newsgroups listed on the page above is happy to welcome new and interesting contributors, the more the merrier. You may even discover some old friends among the archived threads. 

NOTE: If you are not currently using NNTP to interact with other web-folks online, you've been missing out! I recommend Mozilla Thunderbird, and an account at each one of the places listed. See you there!


In regards to the big switch, the Adobe Dreamweaver support forum says this:

ANNOUNCEMENT: Forums will be unavailable for planned system maintenance
starting at 3pm PST on April 3, 2009. New forums will be online on
Monday April 6, 2009.

( currently April 3, 1:35 Pacific time ... T-minus 90 minutes )

mySQL search query : remove case sensitivity

I've had this situation before - a mySQL query using 'like' to search a string value for a given phrase sometimes becomes case sensitive when the query contains other 'Where' phrases. ( As far as I know, 'like' is supposed to be case INsensitive, and this is a known bug in some installations of mysql - I've tried updating mysql drivers and still it remains). But, regardless of the cause, there's an easy fix...


Cartweaver Option Selection Fix ( select list javascript )

A small but persistent issue with the default Cartweaver product selection script shows up when a product has more than one set of options. For example, you have skus with a range of colors and a range of sizes.

I finally took a few minutes to create a fix, which was actually quite simple to implement. And in the interest of keeping it non-denominational, I didn't even use jQuery... just plain 'ol javascript that can easily be added to any existing CW site.


Show/Hide the Cartweaver "forgot password" form with jQuery

Here's a perfect example of the way jQuery makes things so easy, even a caveman programmer can do it.

In Cartweaver, the default Customer Login form is actually two separate forms - one to log in, and one to recall a forgotten password by entering an email address.

I have tried various rearrangements of the default markup on this page for each site I've done, always trying to give the more important 'log in' form a more visible presence than the 'forgot pw' form, without cluttering up the page.

Tonight, i found a solution i like best of all ... hide the forgot pw form altogether, using a simple link to show it if needed.


CF Google Search - custom ColdFusion content Google search

Just stumbled upon this little gem, courtesy of Charlie Arehart :

CF Search for Coldfusion Developers

... searches 1338 sites, including: http://*.cfwebtools.com/*, http://mkruger.cfwebtools.com/*, http://www.cartweaver.com/*, http://www.interaktonline.com/*, http://www.kcfusion.org/* ...

Blog Updates : new blog.cfc version : back on (off?) track

I've been busier than ever with the expansion of my web design company and CF programming services, as well as a massive total upgrade (and renaming) of our ColdFusion web hosting company -  all very good things, no complaints about having enough to do, but things like this humble blog have fallen by the wayside.

I've had lots of neat ideas or things to share (don't we all!) but somewhere along the line, I decided to upgrade to the newest blogcfc version, and instead of posting, have been spending my precious little 'blog time' working on the site itself. (Actually really easy to upgrade - thanks again to Ray Camden for making it so smooth!)

In addition to the new look and simpler layout, I put a heap o' tweak on the back end, including tinyMCE, a nice image resizer/uploader, and a bunch of other little things designed to get me back to posting and sharing tiny tidbits as quickly and easily as possible. ( so far so good... the new tinyMCE is really slick, and I've set it up to switch between plain text and a text editor with a single click, depending on the need... more on that later - I'll share it here once i get a few more miles on it!)

Building two businesses, raising a family, and being a code-obssessed project-mongering CF/jQuery nut-fan doesn't leave a lot of time for sharing and discussion, but I am gettting a grip on all that is required of me at this stage of life and career, and coming to see not only an outlet in the social web community, but also beginning to noticeably realize the return from all the time I've spent over the years on various web developer newsgroups and forums, as well as this and other web developer blogs. Instead of taking me 'off track', the interchange of ideas, tools and time-saving suggestions has led to a noticeable increase in my efficiency and a new spring in the step of my general workflow, not to mention quite a few very nice paid projects (thanks especially to the CartWeaver crew for all the props this past year).

If anything, being part of a larger community of web developers and other like-minded folks, even if virtual, has been a very real part of keeping me 'on track' all this time.

At the risk of sounding overly sentimental, I just want to give a smathering of thanks and praise to the CF community at large. I've seen a lot of great ColdFusion ideas and renewed enthusiasm on a lot of levels as more and more people get the bug of <cf_connectedness>. Great ColdFusion resources like ColdFusionCommunity.org, riaforge.org and of course CFbloggers.org seem to be steadily picking up speed, and the general willingness to share and discuss all our little brain-children concepts and widgets is what keeps this business fun. As long as I am still learning, I am still doing what I love for a living.

Cartweaver Search mod: subcats as keywords / auto-submit select box

I just spent a few minutes tweaking the way the default Cartweaver categories search form works - it is fairly basic form javascript, but I think it might be useful to others...

This site is in progress - client has added (and named, sometimes a bit off-spelling) his products, and the CW functions are all up and working.

Rather than the standard secondary category functions, with this site we wanted a 'keyword' search function, much like the tags commonly assigned to blog posts. Most of his photos have multiple secondary categories assigned, so a picture of a river by a mountain for example, would show up under both rivers and mountains. you get the idea.

Cartweaver's search function allows for all sorts of configurations in the call for the search (see the default index.cfm page when you install CW... here is a sample - this is all the default search types plus a few custom ones I keep around... in this case we're working from the one labeled "All form defaults used"). I have the call to the search tag in place in my 'results' page, and have opted to turn off the text box search and the main category search, simply leaving the 'secondary' category search and a submit button with a value of "Go".

anyway... rather than requiring the viewer to select the option and click the submit button to run the search, I thought it would be slick if the select box auto-submitted the form when changed. So... in the cw tag that handles the search function, I simply added this to the <select> dropdown code


so the whole line for the select now looks like this:
 <select name="secondary" id="<cfoutput>#attributes.formid#</cfoutput>-secondary" onchange="document.<cfoutput>#attributes.formid#</cfoutput>.submit()">

(Note, I could have hand-coded the attributes.formID part since I am only using this once in the page, but this method is copying the ID given to the form by cartweaver through the FormID variable)

However... this alone does not work... because...
the default name for the submit button is - can you guess? - "submit", and , left to itself, my javascript code above makes the browser think its trying to do something with that button, rather than submit the form. So the easy fix - rename the submit button to "btnSubmit".

<input name="btnSubmit" type="submit" class="formButton" value="<cfoutput>#attributes.buttonlabel#</cfoutput>"> 

I could also have just removed (commented out) the submit button, since the dropdown now submits the form when changed, but if javascript is disabled, you need the button, so renaming it is the easy fix.

That's a long post for a short mod... hope it helps somebody some time.


Recent Comments

Importing Events Calendar Data into Mura CMS
Jon said: Hi Michael, Thanks for this post - similarly looking to import data from excel spreadsheet into mur... [More]

New TinyMCE lets you paste as plain text automatically
PRR said: I am using tinyMCE 4.2.3 and configured as suggested in this post but when i try pasting in editor i... [More]

Searching and collecting Mura CMS content by Extended Attribute Value with feed.addParam()
Armando Faes said: After a few hours of head banging - finally thanks to this - Once more THANK YOU! [More]

CF Gallery Creator & jQuery Slider Gallery !New and Improved!
Jan Willis said: Okay, I realized that you are calling my root as the Site - not the wwwroot. So, I moved the JS, CS... [More]

CF Gallery Creator & jQuery Slider Gallery !New and Improved!
Michael Evangelista said: @Jan, it has been a long time (6+ years) so my memory of the details is vague, but I think the image... [More]