Im trying to make a wordpress shortcode that print "Free Shipping" if product price is greater than 8$, if not returns blank (prints nothing).
function shortcode_FreeShipping( $product ) {
if( $product->get_price() > 8 ) {
return __( 'Free Shipping', 'woocommerce' );
}
else {
return __( '', 'woocommerce' );
}
}
add_shortcode('freeshipping', 'shortcode_FreeShipping');
When shortcode [freeshipping]
in inserted on product page, the page doesn't load.
What could be wrong ?