$html .= '<form name="cart_recount" method="POST" action="index.php">'; $html .= '<input type="HIDDEN" name="p" value="cart">'; $html .= '<input type="HIDDEN" name="recount" value="true">'; $html .= '<tr>'; $html .= '<td style="width:25px; height:30px; background-color:#ececec; border-style:solid; border-color:#dddddd; border-width:1px; text-align:center; vertical-align:middle;" class="cart_main_top">Lp.</td>'; $html .= '<td style="width:145px; height:30px; background-color:#ececec; border-style:solid; border-color:#dddddd; border-width:1px; text-align:center; vertical-align:middle;" class="cart_main_top">Produkt</td>'; $html .= '<td style="width:40px; height:30px; background-color:#ececec; border-style:solid; border-color:#dddddd; border-width:1px; text-align:center; vertical-align:middle;" class="cart_main_top">Ilość</td>'; $html .= '<td style="width:80px; height:30px; background-color:#ececec; border-style:solid; border-color:#dddddd; border-width:1px; text-align:center; vertical-align:middle;" class="cart_main_top">Cena</td>'; $html .= '<td style="width:40px; height:30px; background-color:#ececec; border-style:solid; border-color:#dddddd; border-width:1px; text-align:center; vertical-align:middle;" class="ccart_main_top">Rabat</td>'; $html .= '<td style="width:80px; height:30px; background-color:#ececec; border-style:solid; border-color:#dddddd; border-width:1px; text-align:center; vertical-align:middle;" class="cart_main_top">Cena z Rabatem</td>'; $html .= '<td style="width:80px; height:30px; background-color:#ececec; border-style:solid; border-color:#dddddd; border-width:1px; text-align:center; vertical-align:middle;" class="cart_main_top">Wartość</td>'; $html .= '<td style="width:25px; height:30px; background-color:#ececec; border-style:solid; border-color:#dddddd; border-width:1px; text-align:center; vertical-align:middle;" class="cart_main_top"> </td>'; $html .= '</tr>'; $lp = 1; $sum = 0; // pozycje $query = mysql_query("SELECT *,cart.id AS item FROM cart LEFT JOIN product ON cart.pid = product.id WHERE session='".session_id()."' LIMIT 0,10;"); { $html .= '<tr>'; $html .= '<td style="width:25px; height:30px; background-color:#ffffff; border-style:solid; border-color:#ececec; border-width:1px; text-align:center; vertical-align:middle;" class="cart_main_item">'.$lp++.'</td>'; $html .= '<td style="width:145px; height:30px; background-color:#ffffff; border-style:solid; border-color:#ececec; border-width:1px; text-align:left; vertical-align:middle; font-weight:bold;" class="cart_main_item"> <a href="http://strona.pl/'.$cartitem['pid'].','.$cartitem['seo'].'">'.$cartitem['name'].'</a>'; if($cartitem['discount_code']=="PROMOCJA") $html .= '<font style="color:#dd0000; font-size:7.5pt; font-weight:normal;"><br> CENA PROMOCYJNA</font>'; elseif($cartitem['discount_code']) $html .= '<font style="color:#0000dd; font-size:7.5pt; font-weight:normal;"><br> KOD RABATOWY</font>'; $html .= '</td>'; $html .= '<td style="width:40px; height:30px; background-color:#ffffff; border-style:solid; border-color:#ececec; border-width:1px; text-align:center; vertical-align:middle;" class="cart_main_item"> <input type="TEXT" onFocus="this.select();" name="quantity_'.$cartitem['id'].'" value="'.$cartitem['quantity'].'" class="cart_main_item" style="border-style:none; background-color:#ffffff; width:40px; padding:0px 0px 0px 0px; text-align:center;"></td>'; //pole tekstowe gdzie klient może zmodyfikować ilość produktów $html .= '<td style="width:80px; height:30px; background-color:#ffffff; border-style:solid; border-color:#ececec; border-width:1px; text-align:center; vertical-align:right; font-size:7.5pt;" class="cart_main_item">'.number_format($cartitem['pricewithtax'],2,',',' ').'zł z VAT<br>('.number_format($cartitem['price'],2,',',' ').'zł netto)</td>'; $html .= '<td style="width:40px; height:30px; background-color:#ffffff; border-style:solid; border-color:#ececec; border-width:1px; text-align:center; vertical-align:middle;" class="cart_main_item">'.round(((1-($cartitem['pricewithtax_discount']/$cartitem['pricewithtax']))*100),0).'%</td>'; $html .= '<td style="width:80px; height:30px; background-color:#ffffff; border-style:solid; border-color:#ececec; border-width:1px; text-align:center; vertical-align:middle; font-size:7.5pt;" class="cart_main_item">'.number_format($cartitem['pricewithtax_discount'],2,',',' ').'zł z VAT<br>('.number_format($cartitem['price_discount'],2,',',' ').'zł netto)</td>'; $html .= '<td style="width:80px; height:30px; background-color:#ffffff; border-style:solid; border-color:#ececec; border-width:1px; text-align:center; vertical-align:middle; font-weight:bold;" class="cart_main_item">'.number_format(($cartitem['quantity']*$cartitem['pricewithtax_discount']),2,',',' ').'zł<br>z VAT</td>'; //tutaj po wysłaniu formularza powinna pojawiać się zmodyfikowana wartość cena*ilość produktów, pole jednak cały czas zwraca wartość dla ilości=1 $html .= '<td style="width:25px; height:30px; background-color:#ffffff; border-style:solid; border-color:#ececec; border-width:1px; text-align:center; vertical-align:middle;" class="cart_main_item"><A href="index.php?p=cart&delete='.$cartitem['item'].'"><img src="layout/'.$style.'/delete.png" alt="" title="" border="0" style="width:20px; height:20px;"></a></td>'; $html .= '</tr>'; $sum += ($cartitem['quantity']*$cartitem['pricewithtax_discount']); } // podusmowenie cen $html .= '</form>';
Następnie w dalszej części strony pojawia się taki fragment odpowiedzialny za przeliczanie i uaktywnienie powyższego kodu. Poprzez kliknięcie na grafikę
$html .= '<img onClick="document.cart_recount.submit();" src="layout/'.$style.'/cart_recount_off.png" onMouseOver="this.src='."'layout/".$style."/cart_recount_on.png'".';" onMouseOut="this.src='."'layout/".$style."/cart_recount_off.png'".';" alt="" title="" border="0" style="cursor:pointer;">'; $html .= '<img src="layout/'.$style.'/cart_recount_on.png" alt="" title="" border="0" style="display:none;">'; $html .= '</td>';