[ic] how to calculate item-subtotal by the item price *and* packing unit

Joachim Leidinger interchange-users@icdevgroup.org
Fri Aug 16 05:06:04 2002


Kevin Walsh wrote:
>>I've the item price and the quantity. If 1 quantity of an item is in the 
>>basket, the item-subtotal has to dispay the price like
>>
>>1 quantity * item-prive * packing unit (from the field unit)
>>
>>For example a cake of soap cost 0.50 $. In the basket, it has to displays as
>>
>>sku  description    Qt.(Unit)  price   unit   item total
>>1234 soap           1          0.50 $  72     36.00 $
>>
>>Can I use CommonAdjust to calculate the item total with
>>
>>price * quantity + field unit
>>
>>? My customer export his products table from his software and is not 
>>able to set the price with 36.00$ instead of 0.50 $.
>>
> 
> Why not give multi-packs their own SKU, perhaps with their own pack
> price.
> 
> If I buy six tins of cat food as a multi-pack, the package's bar code
> (sku) is different from the individual tins inside.  This is how
> the supermarket knows that I bought a multi-pack instead of picking
> up six tins.
> 
>     sku      description     price    qty   item total
>     1234-72  soap (72 pack)  $36.00   1     $36.00 

That is ok! But my customer want to create new datas in his own 
software. He is a producer for the market and not a products seller.


> Just a thought, before you start creating a custom UserTag for use in
> your CommonAdjust, which is the answer to your question, by the way.

Hmmm...I believe, it is easer to create an usertag, which call the carts 
and change the values of [item-subtotal].

For example

########
# change the item-subtoal
#
#
UserTag myitemsubtotal Interpolate 1
UserTag myitemsubtotal Routine <<EOF
sub {
package Vend::Interpolate;
my $cart;
my $cart = $Vend::Items;
my $code;
my $price;
my $unit;
my $db = 'products';
my $field = 'unit';
my $qt;
my $itemsubtotal;
foreach my $item (@$cart){
    $code = $item->{code};
    $unit = Vend::Interpolate::tag_data($db, $field, $code);
    $qt =  $item->{quantity} * $unit;
    $price = $item->{price};
    $itemsubtotal = $price * $qt;
    $item->{subtotal} = $itemsubtotal;
    }
return '';
}

and call it as [myitemsubtotal] at the top of the basket, checkout, 
receipt, etc. pages.
I'm unsure, if $item->{subtotal} is the right variable to set.

What do you think?

Thank you a lot!

Joachim




-- 
Hans-Joachim Leidinger | Dipl.-Phys.Ing. Entwicklung eCommerce
[leidinger@bpanet.de]
Black Point Arts Internet Solutions GmbH
http://www.bpanet.de