[英]php add product post date woocommerce price
我要實現以下代碼段,但要按示例閱讀所有產品價格的后綴。
示例: 截至“產品創建日期”為79.99美元
代碼段:
<?php
add_filter( 'woocommerce_get_price_html', 'bg_price_prefix_suffix', 100, 2 );
function bg_price_prefix_suffix( $price, $product ){
$price = 'prefix here ' . $price . ' suffix here';
return apply_filters( 'woocommerce_get_price', $price );
}
我找到了一個代碼段,該代碼段將在產品摘要后回顯產品發布日期,但不確定如何使用它作為價格的后綴。 見下文:
<?php
add_action('woocommerce_single_product_summary','bg_echo_product_date',25);
function bg_echo_product_date() {
if (is_product() ) {
echo the_date('', '<span class="date_published">Published on: ', '</span>', false);
}
}
我還想通過CSS單獨設置價格后綴的樣式。
像這樣嗎
.date_published { font-style: italic; }
<?php $price=7 9.99; $prefex="$"; $suffex="November 11th, 2016"; // if you want a function you could do this. function productInfo($a, $b, $c) { $date=a ddDate($c); return $a.$b.$date; } function addDate($date) { return " <span class='date_published'> As of ".$date. "</span>"; } echo productInfo($prefex, $price, $suffex); ?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.