Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
bigbrain28 #1
Help Simplify CFIF conditional
I have an eCommerce site which sells apparel, any given shirt my have 1 to 5
sizes. When the admin enters S,M,L,XL into the backend it creates one field
record (an array of 4 items). On the page I loop thru the array to display a
input box for each size so the user can designate how many of each size they
want (with a little js under it that tallies and evaluates the Quantity field).
The problem its thus; When u submit the page it sends the form to a page that
puts the values into Session vars (also arrays) so I am filling the
SESSION.Cart.sizes var with (for example) "form.size1, form.size2,form.size3"
and then I can parse the array back out in the "show cart page" so the user,
and the order taker can see what amt of each size the user wanted.
So if I account for 7 possible sizes (s-4xl) I need conditional logic to
account for missing items in an array that has maybe only 3 or 4 sizes. At
first I thought it was a simple as a series of IsDefined conditions but really
ANY slot could be empty and any combination of any number of slots could exist.
The logic and math are a bit complex, I assume.
Is there an easier way to check for existance and value of (potentially) 7
items in an array?
bigbrain28 Guest
-
Simplify code help wanted
I want to simplify the following code. First I am reading in 6 values that do not change. Then I have 8 shifting values which are to be read in... -
Simplify hatch effects
Illustrator 10 Windows 2.4 Ghz processor 1.5 GB RAM I used the hatch effects to create this "marble" texture, but it slows down my computer too... -
Simplify Tool
Hi, When drawing two «polygons» sharing a border and then trying to simplify this common border with Object/path/simplify in Illustrator 9 the... -
Can you alter or simplify a 3D mapped object?
I need to wrap a logo around a cylinder in a line art drawing so I did a simple 3D revolved cylinder and mapped on the logo (which is vector art... -
Proposal: Array#to_h, to simplify hash generation
Hi -talk, Ruby has wonderful support for chewing and spitting arrays. For instance, it's easy to produce an array from any Enumerable using... -
BSterner #2
Re: Help Simplify CFIF conditional
"Is there an easier way to check for existance and value of (potentially) 7
items in an array?"
- No. There is no 'isDefined' for array items. You can use workarounds like
just referencing all array elements as if they existed and surrounding it in a
try/catch block. You could also write your own UDF (may be one already on
cflib.org).
I would say you need to rethink your data structure. I would recommend using
something like an array of structs to hold your items. You could in turn, wrap
this in a CFC and have methods like 'totalCart', 'deleteItem', 'addItem',
etc... you use to manipulate the cart. You really should not have empty items
in the array if you're storing your shopping cart data correctly.
hth
BSterner Guest
-
BSterner #3
Re: Help Simplify CFIF conditional
You may want to also look at your database design. It sounds like you're database table is storing redundant data, and/or sizes that may or may not apply to every catalog item.
BSterner Guest
-
bigbrain28 #4
Re: Help Simplify CFIF conditional
Thanks for the comments, however, the cart is "CartWeaver" and not of my
design. We purchased it prior to my ability to create one, so these additional
functions, such as Quantity based pricing and parsing various sizes per SKU
were hacks I had to develop. The cart is an array of structs, but I am
evaluating one of the Arrays with an array whose length is contingent on
availible sizes for that sku. This is why I was looking for an easy was to say
"4sm 4med 6lg, and Xl is empty and xxl is not here either..." without writing a
conditional for every permutation...
bigbrain28 Guest
-
BSterner #5
Re: Help Simplify CFIF conditional
Check out this....
[url]http://cflib.org/udf.cfm?ID=632[/url]
BSterner Guest



Reply With Quote

