How do I output the sign if the price is equal to 0 Woocommerce?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
7 views
Hi all. There is such a need in the Woocommerce shop, when the price is zero, that is, free goods, output its label. Doing such action
filter_woocommerce_empty_price_html function($price, $_product) { if ($_product->get_price() == 0) return __('Price check'); return $price; } add_filter( 'woocommerce_empty_price_html', 'filter_woocommerce_empty_price_html', 10, 2 );

but it works when prices do not, and such a product in the basket is not put. Already a head broke in 2 days. Who can tell me what I'm doing wrong.
by | 7 views

1 Answer

0 like 0 dislike
Helped to solve so
add_filter( 'woocommerce_get_price_html', 'product_price_free_zero_empty', 100, 2 ); product_price_free_zero_empty function( $price, $product ){ if ( " === $product->get_price() || 0 == $product->get_price() ) { $price = 'Price check'; } return $price; }
by
110,608 questions
257,186 answers
0 comments
35,430 users