Chuyển 0đ thành chữ “Liên hệ” trong Woocommerce WordPress
Chỉ cần coppy đoạn code dưới đây chèn vào file functions.php của theme active hoặc child theme, sẽ chuyển 0đ thành chữ “Liên hệ” trong Woocommerce WordPress
function vareno_wc_custom_get_price_html( $price, $product ) {
if ( ! $product->get_price() ) {
if ( $product->is_on_sale() && $product->get_regular_price() ) {
$regular_price = wc_get_price_to_display( $product, array( 'qty' => 1, 'price' => $product->get_regular_price() ) );
$price = wc_format_price_range( $regular_price, __( 'Free!', 'woocommerce' ) );
} else {
$price = '<span class="amount">' . __( 'Liên hệ', 'woocommerce' ) . '</span>';
}
}
return $price;
}
add_filter( 'woocommerce_get_price_html', 'vareno_wc_custom_get_price_html', 10, 2 );
Code Chuyển giá thành “Liên hệ” khi hết hàng trong Woocommerce
Chỉ cần coppy đoạn code dưới đây chèn vào file functions.php của theme active hoặc child theme, sẽ giúp chuyển giá thành “Liên hệ” khi hết hàng trong Woocommerce
function vareno_oft_custom_get_price_html( $price, $product ) {
if ( !is_admin() && !$product->is_in_stock()) {
$price = '<span class="amount">' . __( 'Liên hệ', 'woocommerce' ) . '</span>';
}
return $price;
}
add_filter( 'woocommerce_get_price_html', 'vareno_oft_custom_get_price_html', 99, 2 );
Xem thêm:
- Thiết Kế Website Ngành Nail Spa – Bí Quyết Tăng Doanh Thu Và Thu Hút Khách Hàng
- [Share Code] Tự động tạo tài khoản cho khách hàng và gửi thông báo sau khi hoàn tất đơn hàng trong WooCommerce WordPress
- [SEO] Khắc phục lỗi Google không index tốt với các sản phẩm không có giá trong Woocomerce
- [Share Code] Chia sẻ code ẩn hiện text với hiệu ứng hover mượt mà trong website WordPress
- Top 10+ Công Cụ Hỗ Trợ Viết Content Chuẩn SEO Bằng AI Cho Website
![[Share Code] Chuyển 0đ thành chữ “Liên hệ” trong Woocommerce Wordpress 1 woocomerce plugin - ThemeVareno.com](https://themevareno.com/wp-content/uploads/2025/12/woocomerce-plugin.png)
![[SEO] Khắc phục lỗi Google không index tốt với các sản phẩm không có giá trong Woocomerce 2 seo price woocomerce 1 - ThemeVareno.com](https://themevareno.com/wp-content/uploads/2025/12/seo-price-woocomerce-1.jpg)
![[Share Code] Chia sẻ code ẩn hiện text với hiệu ứng hover mượt mà trong website Wordpress 3 an hien text 2 - ThemeVareno.com](https://themevareno.com/wp-content/uploads/2025/12/an-hien-text-2.jpg)
![[Share Code] Chia sẻ code xóa các hình không sử dụng trong website WordPress 4 Remove Default WordPress Image Sizes - ThemeVareno.com](https://themevareno.com/wp-content/uploads/2025/12/Remove-Default-WordPress-Image-Sizes.png)
![[Share Code] Chỉnh sửa fields trong trang checkout của Woocommerce 5 checkout cua woocommerce 2 - ThemeVareno.com](https://themevareno.com/wp-content/uploads/2025/12/checkout-cua-woocommerce-2.jpg)
