Wordpress 从Woocommerce价格中删除Span标记

Wordpress 从Woocommerce价格中删除Span标记,wordpress,woocommerce,wordpress-theming,Wordpress,Woocommerce,Wordpress Theming,我想从价格中删除span标签 <span class="woocommerce-Price-amount amount"> <span class="woocommerce-Price-currencySymbol">$</span>15</span> $15 在活动主题的functions.php中添加以下代码片段- function modify_wc_price( $return, $price, $args ) { // rem

我想从价格中删除span标签

<span class="woocommerce-Price-amount amount">
<span class="woocommerce-Price-currencySymbol">$</span>15</span>

$15

在活动主题的functions.php中添加以下代码片段-

function modify_wc_price( $return, $price, $args ) {
    // remove span tags
    $negative          = $price < 0;
    $formatted_price = ( $negative ? '-' : '' ) . sprintf( $args['price_format'], get_woocommerce_currency_symbol( $args['currency'] ), $price );
    return $formatted_price;
}
add_filter( 'wc_price', 'modify_wc_price', 99, 3 );
函数modify_wc_price($return,$price,$args){
//删除跨距标记
$negative=$price<0;
$formatted_price=($negative?'-':'').sprintf($args['price_format'],get_-woodcommerce\u currency\u symbol($args['currency']),$price);
返回$U价格;
}
添加过滤器('wc_price','modify_wc_price',99,3);

请使用下面的代码并将span标记与您的标记一起更改,您要使用:

remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
add_action('woocommerce_single_product_summary','woocommerce_template_single_price',10);
function woocommerce_template_single_price() {
    $price = get_post_meta( get_the_ID(), '_regular_price', true);
    $price_sale = get_post_meta( get_the_ID(), '_sale_price', true);
?>
    <del>
        <span class="woocommerce-Price-amount amount">
            <span class="woocommerce-Price-currencySymbol">$</span><?php echo $price; ?>.00
        </span>
    </del>
    <ins>
        <span class="woocommerce-Price-amount amount">
            <span class="woocommerce-Price-currencySymbol">$</span><?php echo $price_sale; ?>.00
        </span>
    </ins>
<?php }
remove_action('woocommerce_single_product_summary'、'woocommerce_template_single_price',10);
添加行动(“woocommerce\u single\u product\u summary”和“woocommerce\u template\u single\u price”,10);
功能商业\模板\单一\价格(){
$price=get_post_meta(get_ID(),'u regular_price',true);
$price\u sale=get\u post\u meta(get\u ID(),'u sale\u price',true);
?>
$.00
$.00

你尝试过什么?你的解决方案有哪些问题?