<div id="cartblock" class="">
    <a href="index.php?controller=cart" id="cart-button">
        <span class="text"><?php echo $text_cart; ?></span>
        <span id="quality"><?php echo $cart_quantity; ?></span>
        <span class="arrow_down"><i class="icon-caret-down"></i></span>
    </a>
    <div class="block-content">
        <?php if($cart_quantity > 0){?>
            <div class="summary">
               <p class="subtotal"><span class="label">Cart Subtotal:</span> <span class="cart-header-price price"><?php echo $cart_subtal; ?></span></p>
            </div>
            <div class="actions">
                <button onclick="location='/index.php?controller=cart'" class="button btn-default btn-sm" title="Checkout" type="button"><span>Checkout</span></button>
                <button onclick="location='/index.php?controller=cart'" class="button btn-primary view-cart btn-sm" title="View Cart" type="button"><span>View Cart</span></button>
            </div>
            <div class="wrapp-top-cart-drop">
                <p class="block-subtitle">Recently added item(s)</p>
                <ol class="mini-products-list" id="cart-sidebar">
                    <?php foreach($cart_products as $product){?>
                         <li class="item clearfix odd">
                            <a class="product-image" href="/index.php?controller=product&product_id=<?php echo $product['product_id']?>">
                                <img width="50" height="50" src="<?php echo $product['thumb']?>">
                            </a>
                            <div class="product-details">
                                <a class="btn-remove" title="Remove This Item" href="javascript: void(0);" data-produt-key="<?php echo $product['product_key']; ?>"><span class="glyphicon glyphicon-trash"></span></a>
                                <a class="btn-edit" title="Edit item" href="/index.php?controller=product&product_id=<?php echo $product['product_id']?>"><span class="glyphicon glyphicon-pencil"></span></a>
                                <p class="product-name"><a href="/index.php?controller=product&product_id=<?php echo $product['product_id']?>"><?php echo $product['name']?></a></p>
                                <strong><?php echo $product['quantity']?></strong> x
                                <span class="price"><?php echo $product['price']?></span>
                            </div>
                        </li>
                    <?php }?>
                </ol>
            </div>
        <?php }else{ ?>
            <p class="empty">You have no items in your shopping cart.</p>
        <?php }?>
	</div>
</div>
<script type="text/javascript">
    //showing cart contents
	$("#cartblock").hover(function(){
	$("#cartblock").addClass("shown-sub")
	},function(){
	$("#cartblock").removeClass("shown-sub")
	});
    $('.mini-products-list .product-details .btn-remove').bind('click', function(){
        var product_key=$(this).attr('data-produt-key');
        var shipping_cost=$("#shipping_cost_id").val();
        var li = $(this).parents('li.item');
        li.remove();
        $.ajax({
            type:'GET',
            url: 'index.php?controller=cart&action=ajax_removeproduct&product_key='+product_key+'&shipping_cost='+shipping_cost,
            dataType: 'json',
            success: function(json) {
                // var json = eval("(" + jsonData + ")");
                $('.cart-header-price').text(json.sub_total);
                reloadCartHeader();
            }
        });
    });
</script>
