Posted by BenNadelPost on Thu 10 Jul 16:35
report abuse | download | new post
- <cffunction name="getFormattedPrice" output="false" access="public" hint="I format a price">
- <cfset var price = 0 />
- <cfif len( trim( getPrice() ) ) >
- <cfset price = getPrice() />
- </cfif>
- <cfreturn LSCurrencyFormat( price ) />
- </cffunction>
- <cffunction name="getFormattedSavingsPercent" output="false" access="public" hint="I format the difference between the price and the disc price (aka the discounted amount )">
- <cfset var savingsPercent = 0 />
- <cfif calculateSavings() GT 0 >
- <cfset savingsPercent = getPrice()/calculateSavings() />
- </cfif>
- <cfreturn "%#decimalFormat(savingsPercent)#"/>
- </cffunction>
- <cffunction name="getFormattedDiscPrice" output="false" access="public" hint="I format a Discprice">
- <cfset var Discprice = 0 />
- <cfif len( trim( getDiscPrice() ) ) >
- <cfset Discprice = getDiscPrice() />
- </cfif>
- <cfreturn LSCurrencyFormat( Discprice ) />
- </cffunction>
- <cffunction name="calculateSavings" output="false" access="public" hint="I get the savings amount from the price and disc price">
- <cfset var savings = 0 />
- <cfif val( getPrice() ) GT 0>
- <cfset savings = getPrice() - val( getDiscPrice() ) >
- </cfif>
- <cfreturn savings />
- </cffunction>
- <cffunction name="isDiscounted" access="public" output="false">
- <cfreturn getPrice() IS NOT getDiscPrice() >
- </cffunction>
- <cffunction name="getFormattedSavings" output="false" access="public" hint="I format the difference between the price and the disc price (aka the discounted amount )">
- <cfreturn LSCurrencyFormat( calculateSavings() ) />
- </cffunction>
- <cffunction name="getPrice" access="public" output="false">
- <cfreturn variables.instance.price>
- </cffunction>
- <cffunction name="setPrice" access="public" output="false">
- <cfargument name="price" required="true">
- <cfset variables.instance.price = arguments.price>
- </cffunction>
- <cffunction name="getDiscPrice" access="public" output="false">
- <cfreturn variables.instance.discPrice>
- </cffunction>
- <cffunction name="setDiscPrice" access="public" output="false">
- <cfargument name="discPrice" required="true">
- <cfset variables.instance.discPrice = arguments.discPrice>
- </cffunction>
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.