我需要覆盖在jigoshop中返回折扣百分比的公共函数
/**
* Returns the products sale value, either with or without a percentage
*
* @return string HTML price of product (with sales)
*/
public function get_calculated_sale_price_html()
{
if ($this->is_on_sale()) {
if (strstr($this->sale_price, '%')) {
return '<del>'.jigoshop_price($this->regular_price).'</del>
<ins>'.jigoshop_price($this->get_price()).'</ins><br/>
<span class="discount">'.sprintf(__('%s off!', 'jigoshop'), $this->sale_price).'</span>';
} else {
return '<del>'.jigoshop_price($this->regular_price).'</del>
<ins>'.jigoshop_price($this->sale_price).'</ins>';
}
}
return '';
}
我试过了
if (!function_exists('calculated_price')) {
function calculated_price(){
if ($this->is_on_sale()) {
if (strstr($this->sale_price, '%')) {
return '<del>'.jigoshop_price($this->regular_price).'</del>
<ins>'.jigoshop_price($this->get_price()).'</ins><br/>
<span class="discount">'.$this->sale_price.'</span>';
} else {
return '<del>'.jigoshop_price($this->regular_price).'</del>
<ins>'.jigoshop_price($this->sale_price).'</ins>';
}
}
return '';
}
}
add_action('get_calculated_sale_price_html', 'calculated_price');
我试过了,add_filter()
但没有运气。
是否可以修改现有的公共功能?