Skip to content

Instantly share code, notes, and snippets.

@grola
Last active January 23, 2018 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grola/b006c9d2b631279759f481b941d76ecb to your computer and use it in GitHub Desktop.
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
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