Một số code tùy biến hiển thị Variations của WooCommerce

Thứ hai - 23/08/2021 02:18

Đặt giá mặc định cho sản phẩm có nhiều biến thể trong WooCommerce

add_filter( 'woocommerce_variable_sale_price_html', 'wc_wc20_variation_price_format', 10, 2 );
add_filter( 'woocommerce_variable_price_html', 'wc_wc20_variation_price_format', 10, 2 );
function wc_wc20_variation_price_format( $price, $product ) {
// Main Price
$prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) );
$price = $prices[0] !== $prices[1] ? sprintf( __( '%1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
// Sale Price
$prices = array( $product->get_variation_regular_price( 'min', true ), $product->get_variation_regular_price( 'max', true ) );
sort( $prices );
$saleprice = $prices[0] !== $prices[1] ? sprintf( __( '%1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
 
if ( $price !== $saleprice ) {
$price = '<del>' . $saleprice . '</del> <ins>' . $price . '</ins>';
}
return $price;
}

Xóa khoảng giá hiển thị khi đặt sản phẩm biến thể

function remove_variation_price( $price ) {
$price = '';
return $price;
}



 

Tác giả: luuhongphuc

Tổng số điểm của bài viết là: 10 trong 2 đánh giá

Xếp hạng: 5 - 2 phiếu bầu
Click để đánh giá bài viết
Dell Inspiron 5430 24.490.000

Dell Inspiron 5430

Dell Latitude 9510 18.200.000

Dell Latitude 9510

Dell Vostro 3500 24.600.000

Dell Vostro 3500

Dell Vostro 3400 18.900.000

Dell Vostro 3400

Bộ phận: Phòng Chăm sóc khách hàng
Điện thoại 0908 554 558
Email info@phatthanhdat.com
skype luuhongphuc
viber 0908554558
Zalo 0908554558
Yêu Xe - Trang Mạng Xã Hội
Phat Thanh Dat

DỊCH VỤ CÀI ĐẶT CẤU HÌNH QUẢN TRỊ MÁY CHỦ SERVER

Phatthanhdat.com -&nbsp;chuyên các dịch vụ giải pháp về công nghệ thông tin cho các doanh nghiệp, triển khai hệ thống mạng máy tính (LAN), máy chủ Server,&nbsp;domain, hosting,&nbsp;website, mail server, file server..... &nbsp; Dịch vụ cài đặt cấu hình quản trị máy chủ&nbsp;chuyên triển khai...

Thăm dò ý kiến

Bạn biết trang web PTD từ đâu

Liên Hệ

Phòng Chăm sóc khách hàng


Phòng Kỹ thuật


Thống Kê
  • Đang truy cập72
  • Máy chủ tìm kiếm29
  • Khách viếng thăm43
  • Hôm nay11,958
  • Tháng hiện tại896,149
  • Tổng lượt truy cập8,754,427
Sản Phẩm
Bạn đã không sử dụng Site, Bấm vào đây để duy trì trạng thái đăng nhập. Thời gian chờ: 60 giây
Gửi phản hồi