<?php

function eventerra_woocommerce_support() {
	add_theme_support( 'woocommerce' );
}
add_action( 'after_setup_theme', 'eventerra_woocommerce_support' );

//add_filter( 'woocommerce_show_page_title', '__return_false' );

remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);

remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );

function eventerra_woocommerce_add_clear() {
	echo '<div class="clear"></div>';
}
add_action( 'woocommerce_before_shop_loop', 'eventerra_woocommerce_add_clear', 40 );

function eventerra_woocommerce_pagination_args($args) {

	return $args;
}
add_filter('woocommerce_pagination_args', 'eventerra_woocommerce_pagination_args');

function eventerra_woocommerce_before_shop_loop_item_title_before() {
	echo '<div class="woocommerce-loop-product__thumb">';
}
function eventerra_woocommerce_before_shop_loop_item_title_after() {
	echo '</div>';
}
add_action('woocommerce_before_shop_loop_item_title', 'eventerra_woocommerce_before_shop_loop_item_title_before', 1);
add_action('woocommerce_before_shop_loop_item_title', 'eventerra_woocommerce_before_shop_loop_item_title_after', 100);

function eventerra_woocommerce_loop_add_to_cart_link($link) {
	$link='<div class="woocommerce-add-to-cart-wrapper">' . $link . '</div>';
	return $link;
}
add_filter('woocommerce_loop_add_to_cart_link', 'eventerra_woocommerce_loop_add_to_cart_link');

remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_title', 5);


function eventerra_woocommerce_add_to_cart_inline($output, $tag, $attr){
	if('add_to_cart' != $tag){
		return $output;
	}
	$output = str_replace('<p','<div',$output);
	$output = str_replace('</p','</div',$output);
	return $output;
}
add_filter( 'do_shortcode_tag', 'eventerra_woocommerce_add_to_cart_inline', 10, 3);


function eventerra_woocommerce_atts_product_add_to_cart($out, $pairs, $atts){
	if(!isset($atts['style'])) {
		$out['style'] = '';
	}
	return $out;
}
add_filter( 'shortcode_atts_product_add_to_cart', 'eventerra_woocommerce_atts_product_add_to_cart', 10, 3 );
