Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
Bill #1
Mathimatical functions
I'm a little stumped on how to accomplish this.
Here is what I have
**************
<cfif rsGetCart.cart_sku_qty lte 2>
<cfset Client.CartSubTotal = Client.CartSubTotal +
(rsGetCart.SKU_Price*rsGetCart.cart_sku_qty)>
<cfelse>
<cfset Client.CartSubTotal = Client.CartSubTotal +
(rsGetCart.SKU_Price*(rsGetCart.cart_sku_qty - int(rsGetCart.cart_sku_qty /
3)))>
</cfif>
**************
<td align="right">
<cfif rsGetCart.cart_sku_qty lte 2>
#LSCurrencyFormat(rsGetCart.SKU_Price*rsGetCart.ca rt_sku_qty,'local')#
<cfelse>
LSCurrencyFormat(rsGetCart.SKU_Price*rsGetCart.car t_sku_qty,'local')#<br />
</cfif>
***************8
And I need it to do this
For instance:
If I order 2 I get 1 more free = 3 total
If I order 3 I still get 1 free = 3 total
order 4 I get 2 free = 4 total
order 6 I get 3 free = 6 total
order 7 I still get 3 free = 7 total
and so on...
So it only updates the free quantity when its an even number.
The code I have works for adding 1 if the quantity is greater then 2 but to
get it to add 2 if the quantity is 4 and 3 if the quantity is 6 is what has
me stumped.
Any knowledgeable folks out there that can offer the code to point me in the
right direction??
Bill
Bill Guest
-
Too many functions!!!
While developing a large FMS application, main.asc has become more than a bit lengthy. The bulk of the file is taken up by the custom client... -
web functions?
Hi, I'd like to post some news content on my web page from another website. Are there built in php functions that will allow me to do this? ... -
Using ZIP functions..
Okay, here's the scenario.. I have uploaded file_blah.zip .. It has a file compressed in it called asdf.mgx .. The thing I need to do is rename the... -
#10743 [Com]: class functions & PHP core functions inconsistently clash ;)
ID: 10743 Comment by: destes at ix dot netcom dot com Reported By: jjones at net-conex dot com Status: Open... -
Functions
Do you know if Sql Server User defined Functions are an ANSI Standard ? -
Bill #2
Re: Mathimatical functions
Sorry wrong snippet. Tis post is revised
I'm a little stumped on how to accomplish this.
Here is what I have
**************
<cfif rsGetCart.cart_sku_qty lte 2>
<cfset Client.CartSubTotal = Client.CartSubTotal +
(rsGetCart.SKU_Price*rsGetCart.cart_sku_qty)>
<cfelse>
<cfset Client.CartSubTotal = Client.CartSubTotal +
(rsGetCart.SKU_Price*(rsGetCart.cart_sku_qty - int(rsGetCart.cart_sku_qty /
3)))>
</cfif>
**************
td align="right">
<cfif rsGetCart.cart_sku_qty lte 2>
#LSCurrencyFormat(rsGetCart.SKU_Price*rsGetCart.ca rt_sku_qty,'local')#
<cfelse>
#LSCurrencyFormat(rsGetCart.SKU_Price*(rsGetCart.c art_sku_qty -
int(rsGetCart.cart_sku_qty / 3)),'local')#
</cfif>
***************8
And I need it to do this
For instance:
If I order 2 I get 1 more free = 3 total
If I order 3 I still get 1 free = 3 total
order 4 I get 2 free = 4 total
order 6 I get 3 free = 6 total
order 7 I still get 3 free = 7 total
and so on...
So it only updates the free quantity when its an even number.
The code I have works for adding 1 if the quantity is greater then 2 but to
get it to add 2 if the quantity is 4 and 3 if the quantity is 6 is what has
me stumped.
Any knowledgeable folks out there that can offer the code to point me in
the
right direction??
Bill
Bill Guest
-
mxstu #3
Re: Mathimatical functions
Something like this maybe..
<cfoutput>
<cfloop from="1" to="20" index="qty">
<cfif qty gte 2>
<cfset qtyFree = Int(qty / 2)>
Qty #qty# + Free #qtyFree#<br>
</cfif>
</cfloop>
</cfoutput>
mxstu Guest
-
Bill #4
Re: Mathimatical functions
Thank you.
I'm gonna try it right now
Bill
"mxstu" <webforumsuser@macromedia.com> wrote in message
news:d8pa4m$err$1@forums.macromedia.com...> Something like this maybe..
>
>
>
> <cfoutput>
> <cfloop from="1" to="20" index="qty">
> <cfif qty gte 2>
> <cfset qtyFree = Int(qty / 2)>
> Qty #qty# + Free #qtyFree#<br>
> </cfif>
> </cfloop>
> </cfoutput>
>
Bill Guest
-
parvee #5
Re: Mathimatical functions
Try following, after you separate original and free you can easily calculate
the price. Hope this helps
<cfif Mod(rsGetCart.cart_sku_qty/2) EQ 0>
<cfset chargable_order=rsGetCart.cart_sku_qty>
<cfset free_order=rsGetCart.cart_sku_qty/2>
<cfelse>
<cfset
chargable_order=rsGetCart.cart_sku_qty-int(rsGetCart.cart_sku_qty/2)>
<cfset free_order=int(rsGetCart.cart_sku_qty/2)>
</cfif>
**************
parvee Guest
-
Bill #6
Re: Mathimatical functions
That is awesome. Thank you parvee
Bill
"parvee" <webforumsuser@macromedia.com> wrote in message
news:d8q6re$oe9$1@forums.macromedia.com...> Try following, after you separate original and free you can easily
> calculate
> the price. Hope this helps
>
> <cfif Mod(rsGetCart.cart_sku_qty/2) EQ 0>
> <cfset chargable_order=rsGetCart.cart_sku_qty>
> <cfset free_order=rsGetCart.cart_sku_qty/2>
> <cfelse>
> <cfset
> chargable_order=rsGetCart.cart_sku_qty-int(rsGetCart.cart_sku_qty/2)>
> <cfset free_order=int(rsGetCart.cart_sku_qty/2)>
> </cfif>
>
> **************
>
>
>
Bill Guest
-
Bill #7
Re: Mathimatical functions
Hi Parvee
What is MOD referring to??
Bill
"parvee" <webforumsuser@macromedia.com> wrote in message
news:d8q6re$oe9$1@forums.macromedia.com...> Try following, after you separate original and free you can easily
> calculate
> the price. Hope this helps
>
> <cfif Mod(rsGetCart.cart_sku_qty/2) EQ 0>
> <cfset chargable_order=rsGetCart.cart_sku_qty>
> <cfset free_order=rsGetCart.cart_sku_qty/2>
> <cfelse>
> <cfset
> chargable_order=rsGetCart.cart_sku_qty-int(rsGetCart.cart_sku_qty/2)>
> <cfset free_order=int(rsGetCart.cart_sku_qty/2)>
> </cfif>
>
> **************
>
>
>
Bill Guest
-
parvee #8
Re: Mathimatical functions
Sorry, I am wrong, you need use mod like below
(rsGetCart.cart_sku_qty MOD 2) EQ 0
MOD is a coldfusion operator.
parvee Guest



Reply With Quote

