Blog lập trình

Chia sẻ mọi kiến thức về lập trình

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

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


Dán code dưới vào file functions.php của theme
1
2
3
4
5
6
7
8
9
10
11
12
13
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 = '<span class="amount">' . __( 'Liên hệ', 'woocommerce' ) . '</span>';
        }
    }
    return $price;
}
add_filter( 'woocommerce_get_price_html', 'devvn_wc_custom_get_price_html', 10, 2 );
Share on Google Plus

About Blog chia sẻ kiến thức lập trình

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.

0 nhận xét:

Đăng nhận xét