It’s not working because:
get_the_terms( $post->ID, 'product_cat' )
yields an array of objects, to test against those objects you have to run a loop and pull a $term_id property out of each object.
WordPress to the rescue! WordPress has a helper method for that…
has_term(330,'product_cat', $post);
Use the has_term method to satisfy your conditional.
Related Posts:
- How to add custom metakey to shop_order page’s searching function?
- Changing the HTML of notices in WooCommerce [closed]
- How to display custom field in woocommerce orders in admin panel?
- How to get woocommerce inventory status [closed]
- Woocommerce add to simple product attribute programmatically [closed]
- Apply jquery script to only woocommerce product pages and categories
- How can I add an extra WooCommerce hook
- How to get the original price of the product in woocommerce?
- How to Acheive the custom woocommerce category template
- Remove product description from product archive page
- Hide some items from Screen options in dashboard for products
- display 100 products per page on product category page [closed]
- Adding WooCommerce to a Custom Theme – not working [closed]
- Issue adding text after short description on product pages Woocommerce [closed]
- Exclude Empty Child Categories in Menu
- Can you use admin pages functionality on the frontend of your site
- change billing and shipping address 1 and 2 field placeholders [closed]
- Creating loop within functions.php
- Override woocommerce wc-class function
- Display WooCommerce subscriptions for user [closed]
- Increment price for Woocommerce Minicart [closed]
- Change woocommerce products weight varation based its product category or tags? [closed]
- woocommerce target button with class after ajax update
- WordPress function for 1 to for many
- Pass parameters to function through an action
- Woocommerce checkout field maxlength, make input number field only (postcode)
- change in form-checkout.php by using code in functions.php
- Set quantity of woocommerce product on page visit [closed]
- Product Tags in Add New product as checkbox list [closed]
- Calling a function from anywhere, used in different places
- Selective Product Category for Carousel
- I want to get product attirbute in the section below
- WooCommerce – Want to show multiple currency for a single product [closed]
- How can I remove the main description text box in a Woocommerce product editor page? I only use the “Product short description” text box [closed]
- Load Woocommerce and WordPress Functions Outside
- How to add a slide toggle to the Woocommerce-Layout__Activity-Panel area in the orders admin page
- Add to cart php not working [closed]
- How to auto refresh when user change postcode
- When sale price is 0.00 show only regular price
- Remove the product category module block from the Woocommerce product page
- how can I edit flexslider in woocommerce. [Urgent]
- woocommerce change currency per category [closed]
- help I changed one currency in woocommerce and everything is ruined [closed]
- Functions when woocommerce isn’t installed
- How to override woocommerce.css?
- How can I use Woocommerce $product->get_attribute in functions.php? (if at all)
- (Woocommerce) Order by price when entering specific category
- Create custom function for hero image
- replace text in Sort Box
- add_filter to specific WooCommerce Category
- Woocommerce checkout field
- Woocommerce image sizes missing from Appearance › Customize but not declared by theme
- add referrer to woo
- Way to redirect all Product Sub Category to its Main category Page?
- Add Login/Logout Menu Item to Primary Nav “My Account” Submenu [Woocommerce] [closed]
- Create a Woocommerce product widget with category filter
- Delay a function, any function!
- How add body_class from wp_termmeta
- Adding product to WooCommerce cart [closed]
- WooCommerce -> wc_enqueue_js not working [closed]
- Use existing image sizes for WooCommerce
- Woocommerce Variable Product Dropdown for Custom Shop Template
- How to hide content on mobile in the functions.php file – woocommerce
- How to hide WooCommerce product title and short description to non logged in users?
- localize_script but data changes dependent on product ID
- Show ‘Add to Cart’ on Out of Stock products
- Hide ‘add to cart’ when certain value in dropdown is selected
- removing description tabs – single product page – breaks footer
- Link product attribute value to a URL – woocommerce
- Remove text after a dot and a colon in Woocommerce product title
- When are the user meta fields created in the database? Admin vs Woo API REST
- Woocommerce product price change
- Help with with my function for wordpress
- Remove clickable Link of WordPress Site Logo from Woocommerce Single Product page
- is_product_category(‘Services’) not working
- Problems adding a new field to product in cart
- Parent category as WOOCommerce Categories widget title
- Woocommerce Display Discount On cart
- Problem with my footer after changing WooCommerce Products Sorting [closed]
- Variable function names
- Override plugin function to show invoices even if not logged in
- Woocommerce – Switching Price for Category
- how can I change the read more link destinations and direct all to the same page?
- Woocommerce custom calculation function
- button to toggle css styling / div visibility?
- add product thumbnail to checkout page only and include variation name
- Execute jQuery with custom event listener after successfully add an item to the cart
- Move product attributes after summary on single product page
- Which method is more correct for removing WooCommerce Extensions menu item?
- Show number of sold products but be first for less than 2
- function syntax is off,
- Insert menu into theme location depending on user logged in/out status
- Display post_meta-by_key on product catalogue
- Woocommerce – Checkout error message
- reusing code in function and running it with loop
- Which template file to edit to edit homepage in Mystile [closed]
- “woocommerce_output_related_products” not working
- woocommerce_sort_product_tabs() expects an array
- sort by date in users
- Copy and Modified WooCommerce function is_coupon_valid [closed]