[ic] how to access the price for options in cart

Mike Heins mike at perusion.com
Fri Apr 15 11:10:47 EDT 2005


Quoting Daniel Davenport (ddavenport at newagedigital.com):
> 
> 
> >>> tim.g at edsd.com 04/13/05 12:43 PM >>>
> > Dan,
> > Thanks for the response. Do you know how the checkout
> > process adds to item-subtotal if a particular option is
> > selected?
> > For instance, if you select yes "installed" which adds $.20 
> > to the extended price. Where is this code located. Maybe I 
> > could inject code snippet to tally installed items there?
> > 
> > Tim Good
> 
> As far as i'm aware, the cart and checkout pages recheck the price of
> the item each time the cart is viewed. To them, it's not "add $20 to
> the price"....it's more like "The current options for this item are
> <x>, <y>, and <z>. Give me the current price."
>
> I did think of a way you could calculate the installation fees....
> 
> for each $item in the cart,
> *  get the current price ([item-subtotal] could do that). I'll call it
>    "first price".
> *  save the current value of $item->{installed}
> *  set $item->{installed} to 0, '', or undef
> *  Grabbing the price at this point will give you the price without
>    installation fees. I'll call this "second price".
> *  Set $item->{installed} back to its former value
> *  second price - first price ====> installation fee for the
>    current item
>

Actually, you can do things like:

[item-list]
[item-code], Installed price: [price code="[item-code]" installed=1]<br>
[item-code], Not installed: [price code="[item-code]"]<br>
[/item-list]

Or: 

[perl tables="products pricing options variants"]

    my $installation = 0;
    for my $it (@$Items) {
        my $opt = { code => $it->{code}, noformat => 1 };
        my $not = $Tag->price($opt);
        $opt->{installed} = 1;
        my $inst = $Tag->price($opt);
        if($inst != $not) {
            $installation += $inst - $not;
        }
    }
    return 'No cost for installation.' unless $installation > 0;
    return "Installation will be " . $Tag->currency( { body => $installation });
[/perl]

-- 
Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.765.647.1295  tollfree 800-949-1889 <mike at perusion.com>

Nature, to be commanded, must be obeyed. -- Francis Bacon


More information about the interchange-users mailing list