상품 페이지의 실제 가격 뒤에 'kg 당'을 추가하여 '쇠고기'와 '닭'카테고리에 대한 WooCommerce의 가격 표시를 변경하고 싶습니다.
다음 코드가 있지만 작동하지 않습니다.
add_filter( 'woocommerce_get_price_html', 'wb_change_product_html' );
// Change and return $price_html variable using the $price and weight amount
function wb_change_product_html( $price, $product ) {
$product_categories = array('beef', 'chicken');
if( has_term( $product_categories, 'product_cat', $product->get_id() ) )
$price_html = '<span class="amount">' . $price . ' per kg </span>'; // change weight measurement here
return $price_html;
}
이 문제를 해결하도록 도와 주시겠습니까?
귀하의 지원에 감사드립니다.
이 스 니펫을 시도하십시오.
add_filter( 'woocommerce_get_price_suffix', 'bbloomer_add_price_suffix', 99, 4 );
function bbloomer_add_price_suffix( $html, $product, $price, $qty ){
$product_categories = array('beef', 'chicken');
if( has_term( $product_categories, 'product_cat', $product->get_id() ) ){
$html = ' per kg';
return $html;
}
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다