要检查产品是否有标签,可以使用has_term()
或is_object_in_term()
.
has_term( \'tag_slug_or_ID\', \'product_tag\' )
或:
// checking if the product has any tag
is_object_in_term( $product_id, \'product_tag\' )
// checking if the product has a given tag
is_object_in_term( $product_id, \'product_tag\', \'tag_slug_or_ID\' )