[ic] Many to many price schema

Renato Enea interchange-users@lists.akopia.com
Fri May 11 09:53:00 2001


Hi again...i modified your routine according to my database structure:

UserTag calc_price Order code quantity
UserTag calc_price Routine <<EOF
sub {
    my ($code, $quantity);

if ($Vend::Interpolate::item) {
$code = $Vend::Interpolate::item->{code};
$quantity = $Vend::Interpolate::item->{quantity};
} else {
($code, $quantity) = @_;
    }

# sanity check
if ($code !~ /^\d+$/ || $quantity !~ /^\d+$/) {
Log ("Wrong input for calc_price: CODE $code QUANTITY $quantity");
        return;
    }
 my $db = Vend::Data::database_exists_ref('products');
 my $keys = $db->query ("select price from prezzi where sku='$code' and nome
= '$Vend::Session->{username}' and min<='$quantity' and max>='$quantity'");
my $price;

if (@$keys) {
# fallback price
$price = $keys->[0]->[0];
# check for appropriate price
#for (my $i = 0; $i < @$keys; $i++) {
#if ($quantity > $keys->[$i]->[1]) {
#$price = $keys->[$i]->[0];
#}
#}
}
else {
 my $keys = $db->query ("select price from prezzi where sku='$code' and nome
is null and min<='$quantity' and max>='$quantity'");
 $price = $keys->[0]->[0];
}


}
EOF

CommonAdjust [calc_price]

and using the tag:

[calc_price code="405153283" quantity="1"]

works well...

the problem is now that the tag [item-price] does not show the correct prize
and ordering the product the basket does not show the correct price.
How can i do to show always the prize calculated by the routine ??

Regards
Renato Enea

----- Original Message -----
From: "Stefan Hornburg (Racke)" <racke@linuxia.de>
To: <interchange-users@developer.akopia.com>
Sent: Friday, May 11, 2001 10:04 AM
Subject: Re: [ic] Many to many price schema


> "Renato Enea" <renea@enter.it> writes:
>
> > Hello, thank you for reply.
> > The suggestion is good but i think that this routine is useful using the
> > [order] tag.
>
> No, the output of [item-price] and friends is calculated by this
> routine, so it may indeed useful for you.
>
> Bye
>         Racke
>
> --
> Master of Swiss Web 2001: http://www.zweifel.ch/
>
> For projects and other business stuff please refer to COBOLT NetServices
> (URL: http://www.cobolt.net; Email: info@cobolt.net; Phone:
0041-1-3884400)
> _______________________________________________
> Interchange-users mailing list
> Interchange-users@lists.akopia.com
> http://lists.akopia.com/mailman/listinfo/interchange-users
>