<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<p><font face="Arial">Hi,<br>
<br>
We need to improve the load speed of the basket and checkout
pages from our stores because the carts of our customers have an
average of 60 different products and, also, we have a specific
situation of 4 diferent price levels per product according to a
matrix customer x product. The price and the discount area from
interchange works for 2 of the prices, but for the other 2 we
calculate it in on-the-fly.<br>
<br>
We are moving the calcs from [item-calc] to [item-sub] tag as it
gives us an average of 60% reduction in load/processing the
basket and checkout, according to [benchmark].<br>
<br>
Inside the [item-sub] we need to use the code and quantity of
the item (from the cart) and a value from a scratch variable.<br>
<br>
This is the calculation we do today in basket.html (very slow,
but works):<br>
</font></p>
<p><font face="Arial">==========================================================<br>
[tmp desconto]0.8375[/tmp] <-- hypothetical value, just
for example, changes for each customer<br>
...<br>
[item-list]<br>
...<br>
Price per unit: [currency][item-calc][item-price noformat] *
$Tag->scratch('desconto')[/item-calc][/currency]<br>
Subtotal : [currency][item-calc]([item-price noformat] *
$Tag->scratch('desconto')) *
[item-quantity][/item-calc][/currency]<br>
...<br>
[/item-list]<br>
</font></p>
<p><font face="Arial">==========================================================</font></p>
<p><font face="Arial">We moved it to [item-sub] this way in
basket.html (very fast, but works partially):<br>
</font></p>
<p><font face="Arial">==========================================================<br>
[tmp desconto]0.8375[/tmp] </font><font face="Arial"><font
face="Arial"><-- hypothetical value, just for example,
changes for each customer</font></font></p>
<p><font face="Arial">[item-list]<br>
...<br>
[item-sub preco_unit_esp]<br>
my $code = shift;<br>
my $priceitem = $Tag->currency( { convert => 1 },
$Tag->price( { code => $code, noformat => 1,
interpolate => 1 } ) * $Tag->scratch('desconto') );<br>
return $priceitem<br>
[/item-sub]<br>
<br>
[item-sub subtotal_esp]<br>
my $code = shift;<br>
my $qt = $item->{quantity};<br>
my $subtotalitem = $Tag->currency( { convert => 1 },
$Tag->price( { code => $code, noformat => 1,
interpolate => 1 } ) * $Tag->scratch('desconto') * $qt );<br>
return $subtotalitem<br>
[/item-sub]<br>
<br>
Price per unit: [item-exec
preco_unit_esp][item-code][/item-exec]<br>
Subtotal : [item-exec subtotal_esp][item-code][/item-exec]<br>
...<br>
[/item-list]<br>
</font></p>
<p><font face="Arial">==========================================================</font></p>
<p><font face="Arial">The problem is that $qt does not work as
expected, it does not return the quantity of the current item in
the cart.<br>
<br>
After digging Cart.pm, item_list.coretag and the list we saw a
lot of options for getting the item code and quantity from the
cart. Then, in the [item-sub] above we have tried this options:<br>
<br>
1) my $code = shift;<br>
2) my $code = $item->{code};<br>
3) my $code = $Item->{code};<br>
4) my $code = [item-code]; (with [item-sub subtotal_esp] and
[item-sub subtotal_esp interpolate=1])<br>
5) my $code = $Tag->scratch('cod'); (inside the item-list and
before the item-sub we do a [tmp cod][item-code][/tmp])<br>
6) my $code = "[item-code]";<br>
7) my $code = $Item->[0]{code};<br>
8) my $code = 2;<br>
<br>
9) my $qt = shift;<br>
10) my $qt = $item->{quantity};<br>
11) my $qt = $Item->{quantity};<br>
12) my $qt = [item-quantity]; (with [item-sub subtotal_esp] and
[item-sub subtotal_esp interpolate=1])<br>
13) my $qt = $Tag->scratch('qtde'); (inside the item-list
and before the item-sub we do a [tmp qtde][item-quantity][/tmp])<br>
14) my $qt = "[item-quantity]";<br>
15) my $qt = $Item->[0]{quantity};<br>
16) my $qt = 2;<br>
<br>
And the results:<br>
<br>
- 1 works perfectly for the code<br>
- 2, 3, 4 and 5 "return $code" is either empty, ERROR or
ARRAY??????<br>
- 6 "return $code" is equal to the string "[item-code]"<br>
- 7 works but as we typed the index "0" this gives us always the
code for the first item in the cart and not the code for the
current item listed (from 0 to n)<br>
- 8 works but this is not a solution.<br>
<br>
- 9, 10, 11, 12 and 13 "return $qt" is either empty, ERROR or
ARRAY??????<br>
- 14 "return $qt" is equal to the string "[item-quantity]"<br>
- 15 works but as we typed the index "0" this gives us always
the quantity for the first item in the cart and not the quantity
for the current item listed (from 0 to n)<br>
- 16 works but this is not a solution.<br>
<br>
Can somebody give me a light on how to make $qt return the
current [item-quantity] on the situation above?</font></p>
<p><font face="Arial">Thanks.</font></p>
<p><font face="Arial">Best regards<br>
Luiz Carlos Maciel Junior<br>
MKNET SYSTEMS INFORMATICA LTDA.</font><br>
</p>
</body>
</html>