gpt4 book ai didi

wordpress - Woocommerce 变体产品价格显示默认

转载 作者:行者123 更新时间:2023-12-02 21:28:02 25 4
gpt4 key购买 nike

我的商店设置了产品变体,目前在产品缩略图页面(即类别和过滤页面)上显示(从 £xx 到 £xx),当向下到单个产品页面时,变体已经选择变化价格显示。

我将某些属性设置为默认值,这是我希望在类别页面上显示的价格……标准尺寸和成本。但我不知道它是否可能或将其更改为什么代码。

enter image description here enter image description here

这可能吗?有什么想法吗?

最佳答案

只显示一个标准价格> 转到 THEME 文件夹并打开 functions.php 并将其添加到文件末尾:

// Use WC 2.0 variable price format, now include sale price strikeout
add_filter( 'woocommerce_variable_sale_price_html', 'wc_wc20_variation_price_format', 10, 2 );
add_filter( 'woocommerce_variable_price_html', 'wc_wc20_variation_price_format', 10, 2 );
function wc_wc20_variation_price_format( $price, $product ) {
// Main Price
$prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) );
$price = $prices[0] !== $prices[1] ? sprintf( __( 'HERE YOUR LANGUAGE: %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( __( 'HERE YOUR LANGUAGE: %1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );

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

(将代码中的 HERE YOUR LANGUAGE 翻译成您的语言,让它说类似:From price )

关于wordpress - Woocommerce 变体产品价格显示默认,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23065821/

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