Last active
January 23, 2018 19:17
-
-
Save grola/b006c9d2b631279759f481b941d76ecb to your computer and use it in GitHub Desktop.
Display additional content after "Add to cart" button on product page for declared categories
This file contains 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 characters
add_action( 'woocommerce_after_add_to_cart_button', 'studiowp_woocommerce_after_add_to_cart_button' ); | |
function studiowp_woocommerce_after_add_to_cart_button() { | |
global $product; | |
$my_categories = array( 15, 16 ); | |
$is_my_category = false; | |
$product_categories = $product->get_category_ids(); | |
foreach ( $my_categories as $my_category ) { | |
if ( in_array( $my_category, $product_categories ) ) { | |
$is_my_category = true; | |
} | |
} | |
if ( $is_my_category ) { | |
?> | |
<div>My content</div> | |
<?php | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment