Chuyển 0đ thành chữ “Liên hệ” trong woocommerce

0
(0)

Đoạn code dưới đây sẽ giúp các bạn chuyển 0đ thành chữ “Liên hệ”. Bạn chỉ cần chèn đoạn code sau vào file functions.php của theme bạn đang sử dụng là được

Code chuyển 0đ thành chữ “Liên hệ”

Dán code dưới vào file functions.php của theme

function devvn_wc_custom_get_price_html( $price, $product ) {
if ( $product->get_price() == 0 ) {
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 = ‘‘ . __( ‘Liên hệ’, ‘woocommerce’ ) . ‘‘;
}
}
return $price;
}
add_filter( ‘woocommerce_get_price_html’, ‘devvn_wc_custom_get_price_html’, 10, 2 );

Bài viết này hữu ích như thế nào?

Hãy bấm vào ngôi sao để đánh giá!

Đánh giá trung bình 0 / 5. Số phiếu bầu : 0

No votes so far! Be the first to rate this post.

Trả lời

Email của bạn sẽ không được hiển thị công khai.

btn-dangkyhocthu