Chuyển sản phẩm không có giá thành Liên hệ woocommerce

Chuyển sản phẩm không có giá thành Liên hệ woocommerce

28/02/2023 - 170

Đoạn code Woocommerce chuyển giá 0đ hoặc để trống thành Liên hệ, số điện thoại tùy ý bạn, bạn muốn thay thành gì cũng được, code sẽ được thêm vào function.php

Nếu bạn không xài child theme thì paste code vào  function.php của theme đó luôn.

Nếu bạn xài flatsome-child thì vào đó và thêm code vào function.php :

function themeflatsome_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, __( 'Liên hệ', 'woocommerce' ) );
        } else {
            $price = '<span class="lienhe">' . __( 'Liên hệ', 'woocommerce' ) . '</span>';
        }
    }
    return $price;
}
add_filter( 'woocommerce_get_price_html', 'themeflatsome_wc_custom_get_price_html', 10, 2 );

 

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *

Bài viết liên quan
Contact Me on Zalo