<?php
/**
 * Mini-cart
 *
 * Contains the markup for the mini-cart, used by the cart widget
 *
 * @author 		WooThemes
 * @package 	WooCommerce/Templates
 * @version     2.1.0
 */

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

global $woocommerce;

$woo_cart = array_slice(WC()->cart->get_cart(), -3);
$woo_cart = array_reverse($woo_cart);

?>

<?php do_action( 'woocommerce_before_mini_cart' ); ?>

<div class="inner-wrapper">

	<?php if ( sizeof( $woo_cart ) > 0 ) { ?>

		<?php _e('Recently added item(s)', 'buyshop'); ?>

		<?php foreach ( $woo_cart as $cart_item_key => $cart_item ) :

			$_product = $cart_item['data'];

			// Only display if allowed
			if ( ! apply_filters('woocommerce_widget_cart_item_visible', true, $cart_item, $cart_item_key ) || ! $_product->exists() || $cart_item['quantity'] == 0 )
				continue;

			// Get price
			$product_price = get_option( 'woocommerce_tax_display_cart' ) == 'excl' ? $_product->get_price_excluding_tax() : $_product->get_price_including_tax();

			$product_price = apply_filters( 'woocommerce_cart_item_price_html', woocommerce_price( $product_price ), $cart_item, $cart_item_key );

			$product_link = get_permalink( $cart_item['product_id'] );

			?>

			<div class="item">
				<a class="product-image" href="<?php echo $product_link; ?>">

					<?php echo $_product->get_image(); ?>

				</a>

				<div class="product-detailes">
					<?php echo apply_filters('woocommerce_widget_cart_product_title', $_product->get_title(), $_product, $product_link ); ?>
					<?php echo apply_filters( 'woocommerce_widget_cart_item_quantity', '<div class="product-price">' . sprintf( '%s &times; %s', $cart_item['quantity'], $product_price ) . '</div>', $cart_item, $cart_item_key ); ?>
				</div>

				<?php echo WC()->cart->get_item_data( $cart_item ); ?>


				<div class="alignright">
					<a href="<?php echo $product_link; ?>"><i class="icon-edit-1"></i></a>
					<a class="cart_delete_ajax" href="<?php echo esc_url( WC()->cart->get_remove_url( $cart_item_key ) ); ?>"><i class="icon-trash-3"></i></a>
				</div>
			</div>

		<?php endforeach; ?>

		<div class="wrapper">
			<a class="button" href="<?php echo WC()->cart->get_cart_url(); ?>">View shopping cart</a>
			<a class="button" href="<?php echo WC()->cart->get_checkout_url(); ?>">Proceed to Checkout</a>
		</div>

	<?php } else { ?>
		<?php _e('You have no items in your shopping cart.', WFT_DOMAIN); ?>
	<?php } //endif; ?>



</div>

<?php do_action( 'woocommerce_after_mini_cart' ); ?>
