📜  如果产品打开显示此按钮 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:35.447000             🧑  作者: Mango

代码示例2
add_action( 'woocommerce_single_product_summary', 'custom_button_by_categories', 32 ,0 );
function custom_button_by_categories(){
    
    global $product;

    // Define your categories in this array (can be Ids, slugs or names)
    $product_cats = array('clothing', 'music', 'furnitures');

    if( has_term( $product_cats, 'product_cat', $product->get_id() ) ){
         $demo_url = get_post_meta( $product->get_id(), 'demo_url', true );
         echo '';
    }
}