<?php
/**
 * Cart Page
 *
 * @author 		WooThemes
 * @package 	WooCommerce/Templates
 * @version     2.1.0
 */

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

global $woocommerce;

wc_print_notices();

do_action( 'woocommerce_before_cart' );
?>

<div class="row">
	<div class="span12">
	<form action="<?php echo esc_url( WC()->cart->get_cart_url() ); ?>" method="post">

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

		<div class="wrapper">
			<h2 class="pull-left"><?php _e('SHOPPING CART', WFT_DOMAIN); ?></h2>
			<div class="pull-right right-button">
				<a href="<?php echo WC()->cart->get_checkout_url(); ?>" class="button button-2x"><?php _e( 'Proceed to Checkout', 'woocommerce' ); ?></a>
			</div>
		</div>

		<div class="box-wrapper">
			<div class="inside">
				<table class="table shopping-cart-table">
					<tbody>

						<tr>
							<th>&nbsp;</th>
							<th><?php _e( 'Product', 'woocommerce' ); ?></th>
							<th class="aligncenter"><?php _e( 'Price', 'woocommerce' ); ?></th>
							<th class="aligncenter"><?php _e( 'Quantity', 'woocommerce' ); ?></th>
							<th class="aligncenter"><?php _e( 'Total', 'woocommerce' ); ?></th>
							<th class="aligncenter">&nbsp;</th>
						</tr>

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

						<?php
						if ( sizeof( WC()->cart->get_cart() ) > 0 ) {
							foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) {
								$_product = $values['data'];
								if ( $_product->exists() && $values['quantity'] > 0 ) {
									?>
									<tr class = "<?php echo esc_attr( apply_filters('woocommerce_cart_table_item_class', 'cart_table_item', $values, $cart_item_key ) ); ?>">

										<!-- The thumbnail -->
										<td>
											<?php
												$thumbnail = apply_filters( 'woocommerce_in_cart_product_thumbnail', $_product->get_image(), $values, $cart_item_key );

												if ( ! $_product->is_visible() || ( ! empty( $_product->variation_id ) && ! $_product->parent_is_visible() ) )
													echo $thumbnail;
												else
													printf('<a href="%s">%s</a>', esc_url( get_permalink( apply_filters('woocommerce_in_cart_product_id', $values['product_id'] ) ) ), $thumbnail );
											?>
										</td>

										<!-- Product Name -->
										<td>
											<span class="cart-col-name"><?php _e( 'Product name', 'woocommerce' ); ?>: </span>
											<?php
												if ( ! $_product->is_visible() || ( ! empty( $_product->variation_id ) && ! $_product->parent_is_visible() ) ) {
													echo apply_filters( 'woocommerce_in_cart_product_title', $_product->get_title(), $values, $cart_item_key );
												} else {
													printf('<strong><a href="%s">%s</a></strong>', esc_url( get_permalink( apply_filters('woocommerce_in_cart_product_id', $values['product_id'] ) ) ), apply_filters('woocommerce_in_cart_product_title', $_product->get_title(), $values, $cart_item_key ) );
												}

												// Meta data
												echo WC()->cart->get_item_data( $values );

												// Backorder notification
												if ( $_product->backorders_require_notification() && $_product->is_on_backorder( $values['quantity'] ) ) {
													echo '<p class="backorder_notification">' . __( 'Available on backorder', 'woocommerce' ) . '</p>';
												}
											?>
										</td>

										<!-- Product price -->
										<td class="aligncenter">
											<span class="cart-col-name"><?php _e( 'Price', 'woocommerce' ); ?>: </span>
											<?php
												$product_price = get_option('woocommerce_tax_display_cart') == 'excl' ? $_product->get_price_excluding_tax() : $_product->get_price_including_tax();

												echo apply_filters('woocommerce_cart_item_price_html', woocommerce_price( $product_price ), $values, $cart_item_key );
											?>
										</td>

										<!-- Quantity inputs -->
										<td class="aligncenter">
											<span class="cart-col-name"><?php _e( 'Quantity', 'woocommerce' ); ?>: </span>
											<?php
												if ( $_product->is_sold_individually() ) {
													$product_quantity = sprintf( '1 <input type="hidden" name="cart[%s][qty]" value="1" />', $cart_item_key );
												} else {
													$product_quantity = sprintf( '<input id="textfield" class="qty" type="text" name="cart[%s][qty]" value="%s" title="' . _x( 'Qty', 'Product quantity input tooltip', 'woocommerce' ) . '" />', $cart_item_key, esc_attr( $values['quantity'] ) );
												}

												echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity, $cart_item_key );
											?>
										</td>

										<!-- Product subtotal -->
										<td class="aligncenter">
											<span class="cart-col-name"><?php _e( 'Subtotal', 'woocommerce' ); ?>: </span>
											<?php
												echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $values['quantity'] ), $values, $cart_item_key );
											?>
										</td>

										<!-- Remove from cart link -->
										<td class="aligncenter">
											<?php
											echo apply_filters( 'woocommerce_cart_item_remove_link', sprintf('<a href="%s" class="icon-trash-2 custom_color" title="%s"></a>', esc_url( WC()->cart->get_remove_url( $cart_item_key ) ), __( 'Remove this item', 'woocommerce' ) ), $cart_item_key );
											?>
										</td>
									</tr>
									<?php
								}
							}
						}

						do_action( 'woocommerce_cart_contents' );
						?>

						<?php do_action( 'woocommerce_after_cart_contents' ); ?>
					</tbody>
				</table>

				<div class="wrapper">
					<div class="pull-left">
						<a class="button button-2x" href="<?php echo get_permalink( woocommerce_get_page_id( 'shop' ) ); ?>"><?php _e( 'Continue Shopping', 'woocommerce' ); ?></a>
					</div>
					<div class="pull-right hidden-phone">
						<button class="button-2x" value="update_qty" name="update_cart" type="submit"><?php _e( 'Update Cart', 'woocommerce' ); ?></button>
					</div>
				</div>

			</div>
		</div>

	<?php do_action( 'woocommerce_after_cart_table' ); ?>
	<?php wp_nonce_field( 'woocommerce-cart' ); ?>
	</form>

	<div class="cart-collaterals">

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

	</div>

	<?php do_action( 'woocommerce_after_cart' ); ?>
	</div>
</div>
<div class="row">

	<?php if ( get_option('woocommerce_enable_shipping_calc')!='no' && $woocommerce->cart->needs_shipping() ) { ?>
	<div class="span4">
		<div class="box-wrapper">
			<div class="inside">
				<?php woocommerce_shipping_calculator(); ?>
			</div>
		</div>
	</div>
	<?php } //endif; ?>

	<?php if ( WC()->cart->coupons_enabled() ) { ?>
		<div class="span4">
			<div class="box-wrapper">
				<div class="inside">
					<h2><?php _e('DISCOUNT CODES', WFT_DOMAIN); ?></h2>
					<p><?php _e('Enter your coupon code if you have one', WFT_DOMAIN); ?></p>

					<form action="<?php echo esc_url( WC()->cart->get_cart_url() ); ?>" method="post">
						<input type="text" name="coupon_code" class="fullwidth input-text" id="coupon_code" value="" />
						<div class="wrapper">
							<div class="pull-left"><button type="submit" class="button button-2x" name="apply_coupon"><?php _e( 'Apply Coupon', 'woocommerce' ); ?></button></div>
						</div>

						<?php do_action('woocommerce_cart_coupon'); ?>
					</form>

				</div>
			</div>
		</div>

	<?php } //endif; ?>

	<div class="span4">
		<div class="box-wrapper">
			<div class="inside">

				<?php woocommerce_cart_totals(); ?>

				<div class="aligncenter">
					<p><a href="<?php echo WC()->cart->get_checkout_url(); ?>" class="button button-2x"><?php _e( 'Proceed to Checkout', 'woocommerce' ); ?></a></p>
				</div>
			</div>
		</div>
	</div>


</div>