I'm building a WordPress site with WooCommerce and I want to check if there are products on sale with the shortcode, if there is a return to the title + products, if there is no product on the promotion, the some block. I had some ideas and one of them was this:
<?php
//Produtos em promoção
//Armazena o shortcode ( mas acredito estar errado )
$produto_promocao = do_shortcode('[sale_products limit="4" columns="4" orderby="popularity" class="quick-sale" on_sale="true" ]');
//Verifica se existe os produtos, se existir, exibe o titulo e os produtos por
//meio do shortcode, caso ao contrario, retorna vazio
if($produto_promocao != false){
_e( 'Promotional Products', 'wordpress' ); //Exibe titulo
echo $produto_promocao; //Exibe produtos
} else {
return ''; //Retorna vazio
}
?>
But it did not work and I figured N reasons for it. I imagine that I need some identifier for promotional products, or to do some other logic .. I accept constructive criticism, I'm training! I apologize beforehand if I did not train here right, I am a beginner. Hugs