jimboobrien
3/21/2016 - 1:50 AM

woocommerce-functions.php

	 /*****************************************************************************/
	/**************VISIONQUEST WOOCOMMERCE CUSTOM FUNCTIONS***********************/
	/******************************************************************************/
	
	remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
	remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);
		
	add_action('woocommerce_before_main_content', 'my_theme_wrapper_start', 10);
	add_action('woocommerce_after_main_content', 'my_theme_wrapper_end', 10);

	function my_theme_wrapper_start() {
	  echo '<div class="container"><div class="sixteen columns pageWrapper">'; ?>
		    <div class="sixteen columns pageContent offset-by-one alpha">             
			<!--<div class="nine columns pageContent offset-by-one alpha">-->
				<div id="woo-content-custom">
					
	<? }

	function my_theme_wrapper_end() {
		echo '</div></div>';
		?>
		<ul class="sidebar five columns omega clearfix">                                                      
			<?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar("Pages")) ; ?>                            
		</ul>
		<? echo '</div></div>';
	}	
		
	add_theme_support( 'woocommerce' );
	
	/*
	* wc_remove_related_products
	*
	* Clear the query arguments for related products so none show.
	* Add this code to your theme functions.php file.
	*/
	function wc_remove_related_products( $args ) {
	  return array();
	}

	add_filter('woocommerce_related_products_args','wc_remove_related_products', 10);
	
		/*==========================================================

		This is for the little cart in the primary navigation

	===========================================================*/


	/* add_filter('wp_nav_menu_items','add_last_nav_item', 10, 2 );
	function add_last_nav_item($items, $args) {
		global $woocommerce;
		if ( $args->theme_location == 'primary' ) {
			return $items .= '<li class="menu-item-cart-item"><div class="log-in-out-link">'. <?php  echo $loginout = wp_loginout($_SERVER['REQUEST_URI'], false ); ?> .'</div></li>';
		}
		return $items;
	}  */





	// this should only ever fire on non-cached pages (so it SHOULD fire
	// whenever we add to cart / update cart / etc
	function update_cart_total_cookie()
	{
		global $woocommerce;
		$cart_total = $woocommerce->cart->cart_contents_count;
		setcookie('woocommerce_cart_total', $cart_total, 0, '/');
	}
	add_action('init', 'update_cart_total_cookie');






	  add_filter('add_to_cart_fragments', 'woocommerce_header_add_to_cart_fragment');
		function woocommerce_header_add_to_cart_fragment( $fragments ) {
			global $woocommerce;
			ob_start();
			?>
			<a class="cart-contents" href="<?php echo $woocommerce->cart->get_cart_url(); ?>" ><?php echo sprintf(_n('%d', '%d', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count);?></a>
			<?php
			$fragments['a.cart-contents'] = ob_get_clean();
			return $fragments;
		}







	
	add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );

	function custom_override_checkout_fields( $fields ) {
		unset($fields['billing']['billing_first_name']);
		unset($fields['billing']['billing_last_name']);
		unset($fields['billing']['billing_company']);
		unset($fields['billing']['billing_address_1']);
		unset($fields['billing']['billing_address_2']);
		unset($fields['billing']['billing_city']);
		unset($fields['billing']['billing_postcode']);
		unset($fields['billing']['billing_country']);
		unset($fields['billing']['billing_state']);
		unset($fields['billing']['billing_phone']);
		//unset($fields['order']['order_comments']);
		unset($fields['billing']['billing_address_2']);
		unset($fields['billing']['billing_postcode']);
		unset($fields['billing']['billing_company']);
		unset($fields['billing']['billing_last_name']);
		unset($fields['billing']['billing_email']);
		unset($fields['billing']['billing_city']);
		return $fields;
	}
	

	
	add_filter( ‘woocommerce_checkout_fields’ , ‘custom_override_checkout_fields’ );
	// Our hooked in function – $fields is passed via the filter!
	function custom_override_checkout_fields( $fields ) {
	unset($fields[‘order’][‘order_comments’]);
	unset($fields[‘billing’][‘billing_company’]);
	unset($fields[‘billing’][‘billing_address_1′]);
	unset($fields[‘billing’][‘billing_address_2′]);
	unset($fields[‘billing’][‘billing_city’]);
	unset($fields[‘billing’][‘billing_postcode’]);
	unset($fields[‘billing’][‘billing_country’]);
	unset($fields[‘billing’][‘billing_state’]);
	unset($fields[‘billing’][‘billing_phone’]);
	return $fields;
	}
	

	/* Remove Billing & Shipping Address In Woocommerce Checkout */
	add_action('woocommerce_checkout_init','disable_billing_shipping');

	function disable_billing_shipping($checkout){

	 $checkout->checkout_fields['billing']=array();
	 $checkout->checkout_fields['shipping']=array();
	 return $checkout;
	} 








	/* WOOCOMMERCE NOTES CHANGE */
	add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
	// Our hooked in function - $fields is passed via the filter!
	function custom_override_checkout_fields( $fields ) {
		 $fields['order']['order_comments']['placeholder'] = 'Notes about your order go here. All grains are shipped milled unless otherwise specified for whole here, also grains are packaged together unless otherwise requested. ';
		 return $fields;
	}