[item-sub] - how to use [item-quantity] inside it?
Luiz Carlos Maciel Junior <[email protected]> Thu, 17 Oct 2019 14:16:56 -0300
| Newsgroups | gmane.comp.web.interchange.users |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--===============2025161684804210117==
Content-Type: multipart/alternative;
boundary="------------D87F8ED4C2362A9F0471A2FF"
Content-Language: fr
This is a multi-part message in MIME format.
--------------D87F8ED4C2362A9F0471A2FF
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Hi,
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.
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].
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.
This is the calculation we do today in basket.html (very slow, but works):
==========================================================
[tmp desconto]0.8375[/tmp] <-- hypothetical value, just for example,
changes for each customer
...
[item-list]
...
Price per unit: [currency][item-calc][item-price noformat] *
$Tag->scratch('desconto')[/item-calc][/currency]
Subtotal : [currency][item-calc]([item-price noformat] *
$Tag->scratch('desconto')) * [item-quantity][/item-calc][/currency]
...
[/item-list]
==========================================================
We moved it to [item-sub] this way in basket.html (very fast, but works
partially):
==========================================================
[tmp desconto]0.8375[/tmp] <-- hypothetical value, just for example,
changes for each customer
[item-list]
...
[item-sub preco_unit_esp]
my $code = shift;
my $priceitem = $Tag->currency( { convert => 1 }, $Tag->price( {
code => $code, noformat => 1, interpolate => 1 } ) *
$Tag->scratch('desconto') );
return $priceitem
[/item-sub]
[item-sub subtotal_esp]
my $code = shift;
my $qt = $item->{quantity};
my $subtotalitem = $Tag->currency( { convert => 1 }, $Tag->price( {
code => $code, noformat => 1, interpolate => 1 } ) *
$Tag->scratch('desconto') * $qt );
return $subtotalitem
[/item-sub]
Price per unit: [item-exec preco_unit_esp][item-code][/item-exec]
Subtotal : [item-exec subtotal_esp][item-code][/item-exec]
...
[/item-list]
==========================================================
The problem is that $qt does not work as expected, it does not return
the quantity of the current item in the cart.
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:
1) my $code = shift;
2) my $code = $item->{code};
3) my $code = $Item->{code};
4) my $code = [item-code]; (with [item-sub subtotal_esp] and [item-sub
subtotal_esp interpolate=1])
5) my $code = $Tag->scratch('cod'); (inside the item-list and before the
item-sub we do a [tmp cod][item-code][/tmp])
6) my $code = "[item-code]";
7) my $code = $Item->[0]{code};
8) my $code = 2;
9) my $qt = shift;
10) my $qt = $item->{quantity};
11) my $qt = $Item->{quantity};
12) my $qt = [item-quantity]; (with [item-sub subtotal_esp] and
[item-sub subtotal_esp interpolate=1])
13) my $qt = $Tag->scratch('qtde'); (inside the item-list and before
the item-sub we do a [tmp qtde][item-quantity][/tmp])
14) my $qt = "[item-quantity]";
15) my $qt = $Item->[0]{quantity};
16) my $qt = 2;
And the results:
- 1 works perfectly for the code
- 2, 3, 4 and 5 "return $code" is either empty, ERROR or ARRAY??????
- 6 "return $code" is equal to the string "[item-code]"
- 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)
- 8 works but this is not a solution.
- 9, 10, 11, 12 and 13 "return $qt" is either empty, ERROR or ARRAY??????
- 14 "return $qt" is equal to the string "[item-quantity]"
- 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)
- 16 works but this is not a solution.
Can somebody give me a light on how to make $qt return the current
[item-quantity] on the situation above?
Thanks.
Best regards
Luiz Carlos Maciel Junior
MKNET SYSTEMS INFORMATICA LTDA.
--------------D87F8ED4C2362A9F0471A2FF
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 8bit
<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>
--------------D87F8ED4C2362A9F0471A2FF--
--===============2025161684804210117==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
interchange-users mailing list
[email protected]
https://www.interchangecommerce.org/mailman/listinfo/interchange-users
--===============2025161684804210117==--