Check for current product category in single product page (Woocommerce)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
URL: https://wproot.dev/blog/get-woocommerce-current-product-category-single-product-page/ | |
*/ | |
if ( has_term( 'tshirts', 'product_cat' ) ) //product category is tshirts | |
{ | |
$flatrate = '10.00'; | |
} | |
elseif ( has_term( 'hoodies', 'product_cat' ) ) //product category is hoodies | |
{ | |
$flatrate = '15.00'; | |
} | |
else | |
{ | |
$flatrate = '0.00'; | |
} | |
echo 'USD'.$flatrate.' Flat Rate Shipping'; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment