[ic] Help? - PERL and Discount Calculation

Thomas J.M. Burton tom at globalfocusdm.com
Wed Apr 21 18:49:23 UTC 2010


On 4/6/2010 4:30 PM, Thomas J.M. Burton wrote:
> Hello IC Users,
>
> I'm working on setting up quantity pricing on a client's catalog and 
> have run into a need for help on the last bit of code I'm writing.
>
> First, a little context:
> The products that will have quantity price breaks applied are 
> displayed in a list view and will have pricing displayed for three 
> tiers. In order to cut down on database queries and increase 
> efficiency of the page displays, I've written a check-pricing usertag 
> to check if an sku has data in the pricing table and using it like so:
>
> [search-list]
>     [if type="explicit" compare="[check-pricing code=[item-code]]"]
>         ... show special tiered pricing display ...
>     [else]
>         ... show normal pricing display ...
>     [/else]
>     [/if]
> [/search-list]
>
> On its initial run, the usertag queries the pricing table and stores 
> the results as a hash in a scratch variable. It then greps the hash 
> for the presence of the sku passed to the usertag and returns a 1 if 
> the sku is present in the pricing hash and a 0 if it's not. The 
> scratch variable is used for all subsequent sku checks in the result 
> page and for display of the quantity pricing information. (If this 
> approach presents more of a potential performance issue than the 
> multiple queries it avoids, please let me know.)
>
> I have some separate embedded perl in the results page that displays 
> the tiered pricing information for each item.
>
>
> Now for my question:
> The problem I'm having is in displaying discounted prices when 
> discounts are applied to the items in question. Since I'm not using a 
> [price] tag to display pricing for each tier, I need to add some code 
> to my embedded perl that uses the sku's corresponding discount from 
> $Session->{discount} to calculate the discounted price of each tier.
> I'm setting discounts for products on the site using the discount tag, 
> nothing out of the ordinary there. So $Session->{discount} typically 
> looks something like this (except with discounts for many more skus 
> than those snipped here):
>
> {
>   'MB6SL' =>  '$s * 0.9',
>   'TT537-BR-SP' =>  '$s * 0.8',
>   '500516CRYSAB' =>  '$s*0.9',
>   '473714CRYSCOP' =>  '$s*0.9',
>   'ABCC03' =>  '$s * 0.8'
> }
>
>
> What would be the best way to take the value of an sku's discount 
> setting and apply that calculation to a quantity price that I have 
> assigned to a variable in my embedded perl? In other words, if I have 
> a $price for each tier and want to calculate $s * 0.9 but use $price 
> instead of $s, how best would I do that?
>
> I hope this makes sense and that someone out there on the list has a 
> helpful answer.
>
> Thanks in advance!
> Tom

Not sure if anyone saw this, so I'm responding to "bump" the request. I 
could really use a helpful answer to this one as I need to finish this 
project and this is the last bit that I need to put in place.

Can anyone provide some helpful advice?

Thanks,
Tom

-- 
_______________________________
Global Focus Digital Media, LLC
www.globalfocusdm.com



!DSPAM:4bcf48a8271311265837516!





More information about the interchange-users mailing list