Need help, I want to echo “sale” on the woocommerce product page on top of product title if the product is on the “store-pickup” product category.
Tried using the below code, but WordPress throws an error
add_action( 'woocommerce_single_product_summary', 'show_store_pickup', 1 );
function show_store_pickup() {
global $product;
if (is_product_category( 'store-pickup' )) {
echo "Sale!";
}
2
Answers
Can you please check with “woocommerce_before_single_product_summary” hook. that might be help you. also check the result of is_product_category() is coming properly or not.
Try the follows code –