Display Sale price before Regular price Woocommerce WordPress

Nếu bạn đang muốn đưa giá khuyến mãi lên trước giá bán thông thường trong wordpress và xuống dòng giá thông thường thì đây là đoạn code dành cho bạn.

Hãy copy đoạn code sau chèn vào file funtions.php trong wordpress để hưởng thành quả

Đoạn code sử dụng:

add_filter( 'woocommerce_format_sale_price', 'invert_formatted_sale_price', 10, 3 );
function invert_formatted_sale_price( $price, $regular_price, $sale_price ) {
    return '<ins>' . ( is_numeric( $sale_price ) ? wc_price( $sale_price ) : $sale_price ) . '</ins><br><del>' . ( is_numeric( $regular_price ) ? wc_price( $regular_price ) : $regular_price ) . '</del>';
}

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 *

0984966806