<?php
$pid = $_GET['pid'];

$sql = mysqli_query($con, "SELECT * FROM product WHERE product_id = 81 ");
$row = mysqli_fetch_array($sql);
$old_price = $row['old_price'];
$price = $row['price'];
$section = $row['section'];
$product_info = $row['product_info'];
$images = explode(',', $row['image_url']);

?>
<div class="product-single-container product-single-default product-quick-view container">
    <div class="row">
        <div class="col-lg-6 col-md-6 product-single-gallery">
            <div class="product-slider-container product-item">
                <div class="product-single-carousel owl-carousel owl-theme">
                    <?php foreach($images as $image): ?>
						<div class="product-item">
							<img class="product-single-image" src="uploads/<?php echo $section . '/' .  $image ?>" data-zoom-image="uploads/<?php echo $section . '/' . $image ?>"/>
						</div>
					<?php endforeach;  ?>
                </div>
                <!-- End .product-single-carousel -->
            </div>
            <div class="prod-thumbnail row owl-dots" id='carousel-custom-dots'>
                <?php foreach($images as $image): ?>
					<div class="col-3 owl-dot">
						<img src="uploads/<?php echo $section . '/' . $image ?>"/>
					</div>
				<?php endforeach;  ?>
            </div>
        </div><!-- End .col-lg-7 -->

        <div class="col-lg-6 col-md-6">
            <div class="product-single-details">
                <h1 class="product-title"><?php echo $row['product_name'] ?></h1>

                <div class="price-box">
                    <span class="old-price"><?php echo '₦' . number_format($old_price) ?></span>
                    <span class="product-price"><?php echo '₦' . number_format($price) ?></span>
                </div><!-- End .price-box -->

                <div class="product-desc">
					<p><?php echo substr($row['product_info'], 0, 200) ?></p>
				</div><!-- End .product-desc -->

                <div class="product-action">
                    <div class="product-single-qty">
                        <input class="horizontal-quantity form-control" type="text">
                    </div><!-- End .product-single-qty -->

                    <a onclick="addToCart(<?php echo $row['section'] ?>,<?php echo $row['product_id'] ?>,<?php echo $row['price']?>,'<?php echo $row['product_name'] ?>','<?php echo $images[0] ?>')" class="paction add-cart" title="Add to Cart">
						<span>Add to Cart</span>
					</a>
                </div><!-- End .product-action -->

                <div class="product-single-share">
                    <label>Share:</label>
                    <!-- www.addthis.com share plugin-->
                    <div class="addthis_inline_share_toolbox"></div>
                </div><!-- End .product single-share -->
            </div><!-- End .product-single-details -->
        </div><!-- End .col-lg-5 -->
    </div><!-- End .row -->
</div><!-- End .product-single-container -->
<script>
function addToCart(pid, price, product_name, product_image){
	
	var query = 'replace';
	var quantity = $('#qty').val();
	var action = 'replace';
	
	$.ajax({
		type: "POST",
		url: "process.php",
		data: {
			query_cart : 1,
			query : query,
			section : section,
			product_id : pid,
			product_name : product_name,
			product_image : product_image,
			price: price,
			quantity : quantity,
			action : action
		},
		success: function(data){
			    location.reload(true);
		}
	});
}
</script>