【问题标题】:Move Woo-commerce variation sale price below actual price将 Woo-commerce 变化销售价格移至低于实际价格
【发布时间】:2016-09-24 07:25:16
【问题描述】:

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

请看下图。

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

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

【问题讨论】:

    标签: php wordpress woocommerce hook


    【解决方案1】:

    这更多是 css 问题,您可以使用简单的样式标签对其进行样式化

    根据您的结构更改 div 类

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-05
      • 1970-01-01
      • 1970-01-01
      • 2018-12-06
      相关资源
      最近更新 更多