Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

CFC question

Guest
May 08, 2008 May 08, 2008
How do I call a function from another function in the same CFC?

For example, let's say that I have a CFC called: cart.cfc

One of the functions in the cfc is: getCartSubTotal, which takes one argument - the cart ID

Now in the same cart.cfc, I want to have a function called getShipping.

I'm thinking I should be able to pass it the same cart ID and have it get the cart sub total from the function getCartSubTotal. But how do I call that other function from the new function?



TOPICS
Advanced techniques
254
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 08, 2008 May 08, 2008
cfinvoke argumentcollection=arguments

is a handy piece of code.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 08, 2008 May 08, 2008
LATEST
inside same cfc you can call a function like
<cfset myvar = functionname(argument1, argument2, ..., argumentN)>
check out the docs for various ways to pass arguments to a function -
the above example assumes you pass args to the function in same order
they appear in the cffunction tag.

in your case, you can have code like below in your getShipping function:

<cffunction name="getShipping" access="public">
<cfargument name="cartid" type="numeric" required="yes">
<cfset var cartSubTotal = getCartSubTotal(arguments.cartid)>
....
</cffunction>

hth


Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources