實用的 WordPress ICP 備案許可管理器

如何在 WooCommerce 中更改產品銷售 “ 促銷” Sale 顯示徽章文字?

WooCommerce 為銷售商品新增銷售徽章,意味著產品銷售價格低於實際價格。預設 WooCommerce,銷售徽章文字是 「促銷!」

預設銷售文字如下所示:

woocommerce銷售文字

現在開啟位於 wp-content/themes/your-theme-name/ 中的主題的 function.php 檔案推薦放置到子主題中,並在其末尾新增此程式碼:

add_filter('woocommerce_sale_flash', 'vs_change_sale_content', 10, 3); function vs_change_sale_content($content, $post, $product){    $content = '<span class="onsale">'.__( 'On Sale', 'woocommerce' ).'</span>';    return $content; }

在 function.php 主題檔案中新增上面的過濾器後:

woocommerce銷售徽章文字

注意:您可以將 「On Sale」 文字替換為您的文字,銷售徽章設計將繼承您的主題風格。

文章沒看懂?程式碼不會用?需要幫助您可以

小新 的頭像