맞춤형 조건부 출력을 위해 노력하고 있습니다. 판매 가격이있는 제품 루프가 발견되면 판매 가격 태그에 클래스를 추가합니다. 정상 가격 만 있으면이 클래스를 일반 가격표에 추가합니다.제품 주위의 조건부 맞춤 출력 판매 가격 및 일반 가격
나는이 다른 문서화으로부터 &에보고 한 후 작업을 얻이 수없는 것 : 나는 스팬 클래스 = "양"태그를 변경하려고 정상 가격 필터 &을 사용하고
add_filter('woocommerce_get_price_html', 'custom_price_html', 100, 2);
function custom_price_html($price, $product){
ob_start();
global $product;
if (isset($product->sale_price)) {
return str_replace('</del>', '<span class="amount">text</span></del>', $price);
return str_replace('</ins>', '<span class="highlight amount">highlight here</span></del>', $price);
}
else {
return str_replace('</ins>', '<span class="highlight amount">highlight here</span>text</del>', $price);
}
}
을 스팬 클래스 = "금액", 그러나 나는 여전히 동일한 출력을 얻을 수 있습니다.
아이디어가 있으십니까?
add_filter('woocommerce_price_html', 'price_custom_class', 10, 2);
function price_custom_class($price, $product){
return str_replace('<span class="amount"></span>', '<ins><span class="amount">'.woocommerce_price($product->regular_price ).'</span></ins>', $price);
}
예 내가 필터 훅이 올바른 방법이 될 것입니다 알아낼 5 분 전 후 정상 가격에 대한 woocommerce_sale_price_html
, 당신은
woocommerce_price_html
필터 훅이 그것을 통해 가십시오. 둘 다 sale_price & regular_price를 대체 할 것이라고 생각하면 get_price_html이 더 잘 작동할까요? – mark5예, get_price_html 함수를 사용하여 호출 할 때 바뀐 값이 표시됩니다. –