Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tdmrhn/c018305359e62bf1042780583f673eb2 to your computer and use it in GitHub Desktop.
Save tdmrhn/c018305359e62bf1042780583f673eb2 to your computer and use it in GitHub Desktop.
Blocksy 2 Content Blocks Hook + Product Attribute (and term)
<?php
// Change the hook as you want
// Remove "//"s if you want to check the color attribute specific term
add_action( 'woocommerce_product_meta_end', function () {
global $product;
$attributes = $product->get_attributes();
if ( isset( $attributes['pa_color'] ) ) {
// $color_terms = wc_get_product_terms( $product->get_id(), 'pa_color', array( 'fields' => 'names' ) );
// if ( in_array( 'Red', $color_terms ) ) { // Check if 'Red' is one of the terms
echo do_shortcode('[blocksy-content-block id="XXX"]');
// }
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment