【发布时间】:2016-07-29 13:32:11
【问题描述】:
当我在 WooCommerce 插件文件夹中更改核心文件时,我试图将我的代码包含在 wc-formatting-functions.php 文件中,并且它正在工作。
现在我在我的主题文件夹中创建了 woocommerce 文件夹,并在其中复制了 wc-formatting-functions.php 文件,试图覆盖,但它不起作用。
我正在尝试将此代码插入 wc_price() 函数中:
if(is_product_category('mattress')){
echo "mattress category";
}
else if(is_product_category('pillows')){
echo "pillows category";
}
else if(is_product_category('protectors')){
echo "protectors category";
}
else if(is_product_category('toppers')){
echo "toppers category";
}
else if(is_product_category('foldable-mattress')){
echo "foldable-mattress category";
}
就在 wc-formatting-functions.php 中的这些行之后:
$formatted_price = ( $negative ? '-' : '' ) . sprintf( $price_format, '<span class="woocommerce-Price-currencySymbol">' . get_woocommerce_currency_symbol( $currency ) . '</span>', $price );
$return = '<span class="woocommerce-Price-amount amount">' . $formatted_price . '</span>';
我做错了什么?
【问题讨论】:
标签: php wordpress woocommerce categories product