Created
June 2, 2024 15:10
-
-
Save tdmrhn/c018305359e62bf1042780583f673eb2 to your computer and use it in GitHub Desktop.
Blocksy 2 Content Blocks Hook + Product Attribute (and term)
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
<?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