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

Move Woo-commerce variation sale price below actual price

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

请看下图

我试过这段代码但没有用,我的代码适用于 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;
}