I want to add in the product page and archive, the text "free shipping" for products that have at least a certain price (say $ 49) free delivery, to later stylize it from css. I did this, but it doesn't work. Whoever gives me a helping hand, please, and if he has time, he can explain to me what I'm doing wrong, short.
add_action( 'woocommerce_before_shop_loop_item_title', 'single_product_label', 10, 1 );
function single_product_label() {
if ( is_product() || is_shop() || is_product_category() || is_product_tag() ):
global $post, $product;
if ( $price >= 49 ) {
if ( empty( $product->get_shipping_class() ) ) {
echo '<span class="freshipp">FREE SHIPPING</span>';
endif;
}
}
Best regards.
' . $message . '
'; } – atto Feb 01 '22 at 13:54