You can use the has_term function to check for the desired term.
function add_cart_button_replace() {
global $product;
$link = $product->get_permalink();
$button_text = __('+show OFFER', 'woocommerce');
// check if the current product has a "product-category" of "free-products"
if(has_term('free-products', 'product_cat', $product->get_id()))
$button_text = __('+choose me', 'woocommerce');
echo do_shortcode('<a href="'.$link.'" class="button addtocartbutton">' . $button_text . '</a>');
}
You can also learn more about has_term function.
Update: change product-category taxonomy to product_cat as per your comment.
Related Posts:
- How to get WooCommerce Product Category Link by ID?
- Approach for saving a product attribute values with a custom UI in a woocommerce+dokan set up [closed]
- Set download limit and expiry for WooCommerce downloadable products in specific categories
- Remove pagination from WooCommerce product categories on admin edit navigation menus
- Taxonomy , subtaxonomy,child taxonomy of a product woocommerce
- Woocommerce custom taxonomies page
- Outputting an array of term meta values in a custom WooCommerce tab?
- Programatically added attribute, set to ‘show on product page’ automatically. Woocommerce [closed]
- Get child product categories from parent product category in WooCommerce
- Top level parent taxonomy ID
- Woocommerce product search result layout page
- Filter WooCommerce admin products list by a custom taxonomy
- Catchable fatal error on custom category post
- Get custom category image from menu
- Hide product categories and taxonomy terms in menu if empty
- Display related products based on 2 specific product attributes values in WooCommerce
- How to target parent product category and its children using WooCommerce?
- woocommerce custom product category template
- Getting WooCommerce product related child categories
- Hiding taxonomies with no children WP_Query & tax_query
- How to display ACF taxonomy checkbox links on WooCommerce product category archive
- Hide custom Woocommerce taxonomies when empty
- Add attribute taxonomy through code don’t appear in admin product page
- Showing custom taxonomy in woocommerce signle product page
- Adding term to a custom taxonomy based on term from product category
- Warning: Undefined variable $post in C:\xampp\htdocs\… after PHP upgrade
- Admin only taxonomies?
- Fill New Taxonomies
- Infinite Scroll appending Next Product Category Term pages
- How to exclude woocommerece product category in search results?
- Cloning product not copying custom taxonomies
- Check if any available product has specific attribute
- how to show product custom taxonomies in woocommerce rest api
- WordPress search form and search result through ACF field in custom taxonomy
- Get user created Woocommerce attributes ( taxonomies ) [closed]
- Custom order of taxonomy using wp_get_object_terms and woocommerce_term_meta
- How do you search for a post by custom taxonomy?
- Display woocommerce product_cat child terms with thumbnails
- Woocommerce – how to get and display selected variations on single product page
- How do I check if a post has a term with a particular ancestor/parent?
- Creating a custom archive page for WooCommerce products based on tags
- Hide empty categories on widget
- Change filter id into slug
- Set Variant options/attributes values on WooCommerce
- Remove taxonomy base or term from url
- Creating custom Woocommerce attribute taxonomies from a plugin
- How to enable hierarchical permalinks for hierarchical taxonomies
- Create taxonomy with meta term using the WP Rest Api
- Use custom posts as taxonomy term meta replacement?
- Remove description in custom taxonomy edit screen
- Make Custom Taxonomy Category Use Parent Template
- How to call custom taxonomy categories with shortcodes
- How to get terms of a custom post type in a loop inside footer.php
- How do I make a custom taxomony appear like tags?
- Refine user taxonomy query based on role
- List the number of posts for each custom taxonomy and specific custom field value
- Recreating the hierarchy of taxonomies for a dropdown form menu?
- showing custom taxonomies w/custom post type
- Display sub categories and their data of a taxonomy
- Exclude Taxonomy Terms from Template Via Back End?
- How to overwrite registered taxonomy url from vendor plugin in child theme
- Dynamic loading of Archive content based on custom taxonomy term name
- Wrapping result of the_terms in a span with a class of the term name
- Pull in taxonomy links using get_the_terms?
- I am trying to display information from a custom table from my wordpress users pages
- Retrieve Custom Taxonomies according to posts selected
- Can I use OR relation for one item when calling tax_query from WP_Query and use AND for the rest?
- Custom taxonomy not appearing in menu administration panel
- how can i display taxonomy instead of category on my web page?
- Taxonomy Meta Box in User Profile?
- How can I make front page to display custom taxonomy page?
- How to show post list based on taxonomy term?
- WordPress autocomplete search with taxonomies
- Display empty custom taxonomies differently than with one with posts
- remove term from custom taxonomy list
- Display taxonomy with a maximum number of letters
- Display Child Categories of Current Post ID
- Taxonomies specific to Page attribute template
- Echo ACF taxonomy field within a foreach for another taxonomy
- Keeping session instance of random display results over pagination breaks
- How can I rewrite the URL of my custom taxonomy to include the year?
- Query Product categories what have a custom field
- Listing Cities A custom taxonmy by selection order
- Count tags for current post and save into custom meta field (and update it on post edit)
- Limit Tag Links in Post Content
- Passing taxonomy id of taxonomy clicked on one page to another page
- Custom Taxonomy Not Being Recognized by is_tax()
- How to truncate the description in the admin panel for a custom taxonomy
- Why is it defaulting to “uncategorized” even after I select a custom taxonomy
- Get one custom taxonomy category
- Creating a page for custom taxonomy archive
- WordPress Taxonomy Menu
- Insert code on specific taxonomy archives
- get_term_children specific no id
- custom texonomy category child category list with parent head
- is_tax not working for custom taxonomy
- Custom taxonomy with custom meta value is not sorting correctly (query returns the same value for orderby regardless of sort column click)
- wp_add_object_terms cant recognize a post ID
- Foreach for get_the_terms for hierarchical taxonomy don’t repeat Top Level Terms if contains multiple Second Level Terms
- Issue with WordPress Automatically Assigning Terms to Multiple Posts