Is there any way to check the product has variation something like
Please help me.
<?php
If (product has variation) {
echo"This Product have Variations ";
} else {
echo "This Product does not have Variations ";
}
?>
Is there any way to check the product has variation something like
Please help me.
<?php
If (product has variation) {
echo"This Product have Variations ";
} else {
echo "This Product does not have Variations ";
}
?>
Comments are closed.
This should work:
Example:
If you will replace the file woocommerce –> single-product –> meta.php with this code, you will see it works.
To get all variation ids of a variable product
The above code will provide visible variation ids only. For example, If the price is not set for a variation, that variation will be hidden.
Alternatively use the below code to get all variations without considering visibility.