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
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

Sửa máy tính

-&nbsp;Dịch vụ quản trị máy chủ - Dịch vụ thiết kế website -&nbsp;Dịch vụ digital marketing - Dịch vụ IT Part time, Dịch vụ IT Full time -&nbsp;Cung cấp thiết bị CNTT (Máy tính, linh kiện, camera....) - Thi công hệ thống mạng máy tính&nbsp; Nhận 1️⃣: Sửa máy tính từ xa – Sửa...

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ập15
  • Máy chủ tìm kiếm1
  • Khách viếng thăm14
  • Hôm nay1,054
  • Tháng hiện tại6,480
  • Tổng lượt truy cập2,153,976
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