<?php // no direct access
defined('_JEXEC') or die('Restricted access');
$productModel = VmModel::getModel('product');
$totalProduct = ( isset($data->totalProduct ) && $data->totalProduct != 0 ) ? $data->totalProduct : 0;
// Ajax is displayed in vm_cart_products
// ALL THE DISPLAY IS Done by Ajax using "hiddencontainer" ?>
<div class="vmCartModule <?php echo $params->get('moduleclass_sfx'); ?>" id="vmCartModule">
	<div class="minicart_hover" id="header-mini-cart">
		<span class="cart-items-number">
			<i class="fa fa-fw fa-shopping-cart"></i>
			<span class="wrapper-items-number">
				<span class="items-number total_products"><?php echo $totalProduct; ?></span>
			</span>
		</span>
		<div class="clear"></div>
	</div>

	<div id="hiddencontainer" style=" display: none; ">
		<ul class="cart_list">
			<li class="cart_list product_list_widget vmcontainer">
				<span class="image_ajax_cart">
				</span>
				<span class="product_name"></span>
				<span class="quantity"></span>&nbsp;x&nbsp;

				<?php if ($show_price and $currencyDisplay->_priceConfig['salesPrice'][0]) { ?>
					<div class="subtotal_with_tax" style="float: right;"></div>
				<?php } ?>
				<div class="clear"></div>
			</li>
		</ul>
	</div>

	<div class="shopping_cart_content vm_cart_products">

		<?php $list_products = $cart->products; ?>

		<?php if(count($list_products)) {?>

		<ul class="cart_list product_list_widget vmcontainer">

			<?php
			$list_products = $cart->products;

			if ($show_product_list) {
				$price_with_only_tax = 0;
				foreach ($data->products as $key_prduct=>$product){
					$subtotal_with_tax = str_replace( $currencyDisplay->getSymbol(), '', $product['subtotal_with_tax'] );
					$price_with_only_tax += $subtotal_with_tax;
					$pr_images = $productModel->getProduct($list_products[$key_prduct]->virtuemart_product_id,TRUE,TRUE,TRUE,1);
					$productModel->addImages($pr_images);
					?>
					<li class="mini_cart_item product_row">
						<span class="image_ajax_cart">
						<?php if ($pr_images->images[0]->file_url != '' ) { ?>
						<img src="<?php	echo $pr_images->images[0]->file_url;?>" alt="">
						<?php } ?>
						</span>
						<span class="product_name"><?php echo  $product['product_name'] ?></span>
						<span class="quantity"><?php echo  $product['quantity'] ?></span>&nbsp;x&nbsp;
						<?php if ($show_price and $currencyDisplay->_priceConfig['salesPrice'][0]) { ?>
							<?php echo $product['subtotal_with_tax'] ?>
						<?php } ?>
						<div class="clear"></div>
					</li>
				<?php }
				if ( $price_with_only_tax > 0 ) {
					$price_with_only_tax = $currencyDisplay->priceDisplay( $price_with_only_tax );
					$data->billTotal = vmText::sprintf('COM_VIRTUEMART_CART_TOTALP', $price_with_only_tax);
				}
				} ?>
		</ul><!-- end product list -->

<?php //echo'<pre>';print_r($data);die;?>
		<p class="total">
			<?php if ($data->totalProduct and $show_price and $currencyDisplay->_priceConfig['salesPrice'][0]) { ?>
				<?php echo $data->billTotal; ?>
			<?php } ?>
		</p>


		<p class="buttons show_cart">
			<?php if ($data->totalProduct) echo $data->cart_show; ?>
			<a href="<?php echo JRoute::_("index.php?option=com_virtuemart&view=checkout"); ?>" class="button checkout wc-forward"><?php echo JText::_('OB_VIRTUEMART_SHOP_CHECKOUT'); ?></a>
		</p>

		<?php } else { ?>

		<div class="null_cart"><?php echo JText::_( 'OB_NO_PRODUCTS_IN_CART' ); ?></div>

		<?php } ?>


	</div>

	<div style="clear:both;"></div>
		<div class="payments-signin-button" ></div>
	<noscript>
	<?php echo vmText::_('MOD_VIRTUEMART_CART_AJAX_CART_PLZ_JAVASCRIPT'); ?>
	</noscript>
</div>

