Thêm chữ liên hệ với sản phẩm không nhập giá trong Woocommerce
[php]
function filter_price_product(){
global $product;
if($product->get_price()){
wc_get_template( ‘single-product/price.php’ );
}
else{
echo ‘Liên hệ‘;
}
remove_action(‘woocommerce_single_product_summary’,’woocommerce_template_single_price’,10);
remove_action(‘woocommerce_after_shop_loop_item_title’,’woocommerce_template_loop_price’,10);
add_action(‘woocommerce_after_shop_loop_item_title’,’filter_price_product’,11 );
add_action(‘woocommerce_single_product_summary’,’filter_price_product’,11);
[/php]
Hoặc
[php]
function filter_woocommerce_empty_price_html( $var, $instance ) {
return “Liên hệ”;
};
add_filter( ‘woocommerce_empty_price_html’, ‘filter_woocommerce_empty_price_html’, 10, 2 );
[/php]