簡體   English   中英

WooCommerce 5.4.1 - 刪除零小數並在價格后添加字符(整數)

[英]WooCommerce 5.4.1 - Remove Zero Decimals and add character after the price (integer)

先生們請

在實踐中,下面的代碼刪除小數位 ( .00 ) 只顯示在屏幕上,並且只顯示值 ( 2 )。

(價格而不是$2.00 ,它顯示這個$2

拜托,我應該在哪一行添加一個逗號,以便像這樣顯示值 ( $2, ) ?? 先感謝您!

function remove_zero_decimals( $formatted_price, $price, $decimal_places, $decimal_separator, $thousand_separator ) {

if ( $price - intval( $price ) == 0 ) {
        // Format units, including thousands separator if necessary.
    return $unit = number_format( intval( $price ), 0, $decimal_separator, $thousand_separator );
    }
    else {
        return $formatted_price;
    }
}

先生們請

在實踐中,下面的代碼刪除小數位 ( .00 ) 只顯示在屏幕上,並且只顯示值 ( 2 )。

(價格而不是$2.00 ,它顯示這個$2

拜托,我應該在哪一行添加一個逗號,以便像這樣顯示值 ( $2, ) ?? 先感謝您!

function remove_zero_decimals( $formatted_price, $price, $decimal_places, $decimal_separator, $thousand_separator ) {

if ( $price - intval( $price ) == 0 ) {
        // Format units, including thousands separator if necessary.
    return $unit = number_format( intval( $price ), 0, $decimal_separator, $thousand_separator );
    }
    else {
        return $formatted_price;
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM