Mathimatical functions

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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? ...
    3. 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...
    4. #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...
    5. Functions
      Do you know if Sql Server User defined Functions are an ANSI Standard ?
  3. #2

    Default 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

  4. #3

    Default 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

  5. #4

    Default 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

  6. #5

    Default 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

  7. #6

    Default 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

  8. #7

    Default 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

  9. #8

    Default 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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139