Instantly share code, notes, and snippets.

@grola /functions.php
Last active Jan 23, 2018

Embed
What would you like to do?
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