Created
March 28, 2016 09:07
-
-
Save themepaint/80fdf7fed0618eb2be01 to your computer and use it in GitHub Desktop.
Revisions
-
themepaint created this gist
Mar 28, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,53 @@ function themepaint_custome_add_to_cart(){ if ( ! is_product() ) return; $product = get_product(); if ( has_term('posters','product_cat',$product ) || themepaint_is_child_of_turm( 'posters','product_cat',$product )) { /** * Product Add to cart. * * @see woocommerce_template_single_add_to_cart() * @see woocommerce_simple_add_to_cart() * @see woocommerce_grouped_add_to_cart() * @see woocommerce_variable_add_to_cart() * @see woocommerce_external_add_to_cart() * @see woocommerce_single_variation() * @see woocommerce_single_variation_add_to_cart_button() */ remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 ); remove_action( 'woocommerce_simple_add_to_cart', 'woocommerce_simple_add_to_cart', 30 ); remove_action( 'woocommerce_grouped_add_to_cart', 'woocommerce_grouped_add_to_cart', 30 ); remove_action( 'woocommerce_variable_add_to_cart', 'woocommerce_variable_add_to_cart', 30 ); remove_action( 'woocommerce_external_add_to_cart', 'woocommerce_external_add_to_cart', 30 ); add_action( 'woocommerce_single_product_summary', 'cart_custome_text', 30 ); add_action( 'woocommerce_simple_add_to_cart', 'cart_custome_text', 30 ); add_action( 'woocommerce_grouped_add_to_cart', 'cart_custome_text', 30 ); add_action( 'woocommerce_variable_add_to_cart', 'cart_custome_text', 30 ); add_action( 'woocommerce_external_add_to_cart', 'cart_custome_text', 30 ); } } add_action('wp','themepaint_custome_add_to_cart'); function themepaint_is_child_of_turm( $term, $taxonomy, $post_object ){ $term = get_term_by( 'slug', $term, $taxonomy ); $post_terms = get_the_terms( (int) $post_object->ID, (string) $taxonomy ); $post_term_parent_ids = wp_list_pluck( $post_terms, 'parent' ); if ( in_array( $term->term_id, $post_term_parent_ids )) { return true; } return false; } function cart_custome_text(){ echo '<p>Please Contact Raju</p>'; }