【发布时间】:2020-04-29 03:16:10
【问题描述】:
我正在尝试将以下代码中的表格单元格替换为 woocommerce 常规产品价格。
我的 functions.php 文件中有这段代码,用于将定价表添加到内容区域。
如何动态更改单元格 (class="pricing-table-full-price") 以显示常规产品价格?
add_filter ('the_content', 'insertPricingTable');
function insertPricingTable($content) {
if(is_single() && has_term( 'resin', 'product_cat' ) ) {
$content.= '<table class="pricing-table">';
$content.= '<tbody>';
$content.= '<tr>';
$content.= '<th>1 - 5</th>';
$content.= '<th>6 - 11</th>';
$content.= '<th>12+</th></tr>';
$content.= '<tr>';
$content.= '<td class="pricing-table-full-price">Full Price</td>';
$content.= '<td class="pricing-table-35">35% OFF</td>';
$content.= '<td class="pricing-table-45">45% OFF</td>';
$content.= '</tr></tbody></table>';
}
return $content;
}
【问题讨论】:
标签: php wordpress woocommerce price