<?php

include("modules/db.php");
include("modules/products.php");
include("modules/cart.php");
@session_start();
$product_id = $_POST["id"];
$pro_code = $_POST["code"];
$pro_name = $_POST["name"];
$pro_desc = $_POST["desc"];
$pro_price = $_POST["price"];
$pro_img = $_POST["img"];
$pro_warranty = $_POST["warranty"];

if(isset($_SESSION['currency'])){
	$currency =$_SESSION['currency'];
}else{
	$currency = "MMK";
}

$product = new Product();


$product->id = $product_id;
$product->product_code = $pro_code;
$product->product_name = $pro_name;
$product->product_desc = $pro_desc;
$product->product_price =str_replace(",","",$pro_price );
$product->product_img = $pro_img;
$product->product_warranty = $pro_warranty;

$cart = new Cart();

$cart->add_cart($product);

$carts = json_decode($_SESSION['cart']);
?>
<div>
	<table>
		<?php

		foreach ($carts as $key => $value) {
			?>

			<tr>
				<td rowspan="2" align="left">
					<img width="70" src="<?=$value->product_img?>">
				</td>
				<td colspan="2" align="left">
					<p style="font-size: 12px;"><?=$value->product_name?></p>
				</td>
				
			</tr>
			<tr>
				
				<td align="left">
					
					<p style="font-size: 12px;">x <?=$value->product_qty?> - <?=number_format($value->product_price) ." ". $currency?> </p>
				</td>
				<td align="right"> 
					<p style="color: blue;font-size: 12px;"><?=number_format($value->product_qty*$value->product_price)." ". $currency?> </p>
				</td>
			</tr>

			<?php
		}

		?>
	</table>
</div>


