mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-05-01 11:52:25 +08:00
https://stackoverflow.com/questions/77436429/how-to-display-in-woocommerce-product-page-if-a-product-is-digital
9 lines
320 B
Text
9 lines
320 B
Text
function display_digital_product_notice() {
|
|
global $product;
|
|
|
|
if ( is_a( $product, 'WC_Product' ) && $product->is_downloadable() ) {
|
|
echo '<div class="digital-product-notice">This is a digital product.</div>';
|
|
}
|
|
}
|
|
|
|
add_action( 'woocommerce_before_single_product', 'display_digital_product_notice' );
|