问题描述
我在functions.PHP中有以下用于子主题的代码。这个想法是,如果用户在线预订工作,他们将获得该工作的折扣以鼓励更多的在线预订,并在商店中显示如下:
随身听价格:£349.99 网上价格:£339.00
但是,即使我在产品中将销售价格留空,$ product-> is_on_sale()似乎总是返回true。如果我只有一个正常价格(没有销售价格),那么它什么也不显示(即未显示任何价格,其左侧为空白),我想显示正常价格。
// ***********************************************************
// START ADD TEXT BEFORE SALE PRICE
// && (!has_term( 'product','product_cat'))
// ***********************************************************
function bd_rrp_sale_price_html( $price,$product ) {
// SHOWS PRICE FOR PRODUCTS NOT REPAirs
if (has_term( 'Products','product_cat'))
{
if ( $product->is_on_sale() )
{
$has_sale_text = array(
'<del>' => '<del>normal Price: ','<ins>' => '<br>Sale Price: <ins>' );
$return_string = str_replace(array_keys( $has_sale_text ),array_values( $has_sale_text ),$price);
}
else
{
$return_string = $price;// . get_woocommerce_currency_symbol().$product->get_regular_price();
}
}
else
{
if ( $product->is_on_sale() )
{
$has_sale_text = array(
'<del>' => '<del>Walk-In Price: ','<ins>' => '<br>Online Price: <ins>'
);
$return_string = str_replace(array_keys( $has_sale_text ),$price);
}
else
{
$retun_string = "2";// $price;
}
}//ENDIF
return $return_string;
}
add_filter( 'woocommerce_get_price_html','bd_rrp_sale_price_html',100,2 );
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)