亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在 Woocommerce 中的價格前添加自定義文本

如何在 Woocommerce 中的價格前添加自定義文本

PHP
飲歌長嘯 2021-09-18 21:44:10
如何在類別視圖和產品頁面中使用片段向我的 Woocoomerce 價格添加自定義文本?function sv_change_product_html( $price_html, $product ) {    $unit_price = get_post_meta( $product->id, 'unit_price', true );    if ( ! empty( $unit_price ) ) {        $price_html = '<span class="amount">' . wc_price( $unit_price ) . ' / Stück</span>';        }    return $price_html;}add_filter( 'woocommerce_get_price_html', 'sv_change_product_html', 10, 2 );
查看完整描述

2 回答

?
動漫人物

TA貢獻1815條經驗 獲得超10個贊

這工作正常。但我只想將這個剪斷用于某些產品。是否有用于某些產品 ID 的代碼?謝謝


查看完整回答
反對 回復 2021-09-18
?
隔江千里

TA貢獻1906條經驗 獲得超10個贊

add_filter("wc_price","addtext",10,4);

function addtext($return, $price, $args, $unformatted_price){

    if(is_product_category() || is_shop() || is_product()){

        $return =  'like Preis:'.$return;

    }

    return $return;


}


查看完整回答
反對 回復 2021-09-18
  • 2 回答
  • 0 關注
  • 223 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號