html做报价显示,WooCommerce 自定义商品价格显示HTML结构

这篇博客展示了如何修改WooCommerce的`woocommerce_get_price_html`函数,以调整新旧价格的显示位置,创建自定义的报价HTML结构。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

// DeveWork.com

//这是一个可以修改woocommerce_get_price_html 函数默认输出的html代码的例子,

//作用是调换新旧价格的位置

//感谢http://wordpress.stackexchange.com/questions/83367/how-to-edit-the-get-price-html-on-woocommerce

add_filter( 'woocommerce_get_price_html', 'dw_change_default_price_html', 100, 2 );

function dw_change_default_price_html( $price,$product ){

if ( $product->price > 0 ) {

if ( $product->price && isset( $product->regular_price ) ) {

$from = $product->regular_price;

$to = $product->price;

return ''.( ( is_numeric( $to ) ) ? woocommerce_price( $to ) : $to ) .'

'. ( ( is_numeric( $from ) ) ? woocommerce_price( $from ) : $from ) .' ';

} else {

$to = $product->pric

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值