Hello!
Ok so here's the problem. I have a perl script that takes order info from a site, processes the quantity of the product(s) ordered as well as price totals and such. What I'm trying to do is to make it so that the first item they buy is regular price but every item after that is $4 off each. From the structure of the code, I believe the answer is to separate out all the ordered items into their own columns in a table-like format. Unfortunately I have a very hard time going about this, the vital part of the script is as follows:
foreach $row (@rows)
{
if (($rowcount == 0) && ($quantity{$rowcount} > 1))
{
print "<tr><td width=$productw>$product{$rowcount}</td>\n";
print "<td width=$pricew>$currency $price{$rowcount}</td>\n";
print "<td width=$quanw><input type=\"text\" name=\"quan-$rowcount\" SIZE=\"5\" MAXLENGTH=\"5\" value=\"1\"></td>\n";
$thispricedec=$price{$rowcount};
$thisprice = sprintf ("%.2f\n", $thispricedec);
print "<td width=$totalw>$currency $thisprice</td>\n";
print "<td width=$deletew><input type=\"checkbox\" name=\"del-$rowcount\"></td>\n";
print "</tr>\n";
$totalprice=$totalprice+$price{$rowcount};
#$quantity($rowcount) = $quantity($rowcount)-1;
print "<tr><td width=$productw>$product{$rowcount}</td>\n";
print "<td width=$pricew>$currency ($price{$rowcount}-4)</td>\n";
print "<td width=$quanw><input type=\"text\" name=\"quan-$rowcount\" SIZE=\"5\" MAXLENGTH=\"5\" value=\"($quantity{$rowcount}-1)\"></td>\n";
$thispricedec=(($price{$rowcount}-4)*($quantity{$rowcount}-1));
$thisprice = sprintf ("%.2f\n", $thispricedec);
print "<td width=$totalw>$currency $thisprice</td>\n";
print "<td width=$deletew><input type=\"checkbox\" name=\"del-$rowcount\"></td>\n";
print "</tr>\n";
$totalprice=$totalprice+(($price{$rowcount}-4)*($quantity{$rowcount}-1));
$rowcount=$rowcount+1;
}
else
{
print "<tr><td width=$productw>$product{$rowcount}</td>\n";
print "<td width=$pricew>$currency ($price{$rowcount}-4)</td>\n";
print "<td width=$quanw><input type=\"text\" name=\"quan-$rowcount\" SIZE=\"5\" MAXLENGTH=\"5\" value=\"($quantity{$rowcount}-1)\"></td>\n";
$thispricedec=(($price{$rowcount}-4)*($quantity{$rowcount}-1));
$thisprice = sprintf ("%.2f\n", $thispricedec);
print "<td width=$totalw>$currency $thisprice</td>\n";
print "<td width=$deletew><input type=\"checkbox\" name=\"del-$rowcount\"></td>\n";
print "</tr>\n";
$totalprice=$totalprice+(($price{$rowcount}-4)*($quantity{$rowcount}-1));
$rowcount=$rowcount+1;
}
}
I gave it my best shot but it doesn't work. Can someone help me?
Thanks,
Jisoo22
Ok so here's the problem. I have a perl script that takes order info from a site, processes the quantity of the product(s) ordered as well as price totals and such. What I'm trying to do is to make it so that the first item they buy is regular price but every item after that is $4 off each. From the structure of the code, I believe the answer is to separate out all the ordered items into their own columns in a table-like format. Unfortunately I have a very hard time going about this, the vital part of the script is as follows:
foreach $row (@rows)
{
if (($rowcount == 0) && ($quantity{$rowcount} > 1))
{
print "<tr><td width=$productw>$product{$rowcount}</td>\n";
print "<td width=$pricew>$currency $price{$rowcount}</td>\n";
print "<td width=$quanw><input type=\"text\" name=\"quan-$rowcount\" SIZE=\"5\" MAXLENGTH=\"5\" value=\"1\"></td>\n";
$thispricedec=$price{$rowcount};
$thisprice = sprintf ("%.2f\n", $thispricedec);
print "<td width=$totalw>$currency $thisprice</td>\n";
print "<td width=$deletew><input type=\"checkbox\" name=\"del-$rowcount\"></td>\n";
print "</tr>\n";
$totalprice=$totalprice+$price{$rowcount};
#$quantity($rowcount) = $quantity($rowcount)-1;
print "<tr><td width=$productw>$product{$rowcount}</td>\n";
print "<td width=$pricew>$currency ($price{$rowcount}-4)</td>\n";
print "<td width=$quanw><input type=\"text\" name=\"quan-$rowcount\" SIZE=\"5\" MAXLENGTH=\"5\" value=\"($quantity{$rowcount}-1)\"></td>\n";
$thispricedec=(($price{$rowcount}-4)*($quantity{$rowcount}-1));
$thisprice = sprintf ("%.2f\n", $thispricedec);
print "<td width=$totalw>$currency $thisprice</td>\n";
print "<td width=$deletew><input type=\"checkbox\" name=\"del-$rowcount\"></td>\n";
print "</tr>\n";
$totalprice=$totalprice+(($price{$rowcount}-4)*($quantity{$rowcount}-1));
$rowcount=$rowcount+1;
}
else
{
print "<tr><td width=$productw>$product{$rowcount}</td>\n";
print "<td width=$pricew>$currency ($price{$rowcount}-4)</td>\n";
print "<td width=$quanw><input type=\"text\" name=\"quan-$rowcount\" SIZE=\"5\" MAXLENGTH=\"5\" value=\"($quantity{$rowcount}-1)\"></td>\n";
$thispricedec=(($price{$rowcount}-4)*($quantity{$rowcount}-1));
$thisprice = sprintf ("%.2f\n", $thispricedec);
print "<td width=$totalw>$currency $thisprice</td>\n";
print "<td width=$deletew><input type=\"checkbox\" name=\"del-$rowcount\"></td>\n";
print "</tr>\n";
$totalprice=$totalprice+(($price{$rowcount}-4)*($quantity{$rowcount}-1));
$rowcount=$rowcount+1;
}
}
I gave it my best shot but it doesn't work. Can someone help me?
Thanks,
Jisoo22