gpt4 book ai didi

php - 将 Woo-commerce 变体销售价格低于实际价格

转载 作者:搜寻专家 更新时间:2023-10-31 20:35:13 26 4
gpt4 key购买 nike

我想将销售价格移动到实际价格之下以进行变化,我设法为产品摘要部分执行此操作但无法找到任何变化过滤器。

请看下图。

enter image description here

我已经尝试过此代码但没有成功,我的代码适用于 Summery 部分

add_filter( 'woocommerce_variable_sale_price_html', 'product_variation_price_format', 10, 2 );
add_filter( 'woocommerce_variable_price_html', 'product_variation_price_format', 10, 2 );

function product_variation_price_format( $price, $product ) {
if(is_singular('product')){
// Main Price
$prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) );
$price = $prices[0] !== $prices[1] ? sprintf( __( 'From: %1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );

// Sale Price
$prices = array( $product->get_variation_regular_price( 'min', true ),$product->get_variation_regular_price( 'max', true ) );
sort( $prices );
$saleprice = $prices[0] !== $prices[1] ? sprintf( __( 'From: %1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );

if ( $price !== $saleprice ) {
$price = '<ins>' . $price . '</ins> <del>' . $saleprice . '</del>';
}
}
return $price;
}

请指导我如何解决这个问题。

最佳答案

这更多是 css 问题,你可以使用简单的样式标签来设计它

根据您的结构更改 div 类

.priceMainWrapperDiv {
display: table;
}
.salePriceDiv {
display: table-footer-group;
}
.actualPriceDiv {
display: table-header-group;
}

关于php - 将 Woo-commerce 变体销售价格低于实际价格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37458335/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com