[ic] Modify my modifier ?

Stefan Hornburg (Racke) racke at linuxia.de
Thu Mar 15 14:27:19 UTC 2012


On 03/15/2012 03:10 PM, DB wrote:
> Hi - I currnetly have the below code in place and it works well. If an
> item in the products table has value 1 in the heavy column, an extra
> charge is added the the cost of shipping.
>
> ===================================================
>
> ## add fee for items tagged heavy in products table
> AutoModifier heavy
>
> Variable HEAVY_FEE 7.95
>
> Sub custom_shipping<<EOS
> sub {
> my ($final, $mode, $opt, $o) = @_;
>
> $final += $Variable->{HEAVY_FEE}
> if grep {$_->{heavy}} @$Items;
>
> return $final;
> }
> EOS
>
> SpecialSub shipping_callout custom_shipping
>
> ===================================================
>
> I'd like to extend this a bit so that I can choose bewteen two or more
> different charges depending on the value of the 'heavy' field. For
> exmaple add HEAVY_FEE if heavy=1, or add HEAVY_FEE_2 if heavy=2. I don't
> remember where this code came from but I probably didn't write it. If I
> had, I'd likely know how to modify it ;) If anyone can provide a hint
> I'd be grateful.

Just loop through the items and determine the highest value of heavy.
Take this maximum to pick the variable you need.

Regards
	Racke


-- 
LinuXia Systems => http://www.linuxia.de/
Expert Interchange Consulting and System Administration
ICDEVGROUP => http://www.icdevgroup.org/
Interchange Development Team




More information about the interchange-users mailing list