Woocommerce 变体产品价格显示默认值 [英] Woocommerce variation product price to show default

查看:63
本文介绍了Woocommerce 变体产品价格显示默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have my store set up with product variations and at the moment on the product thumbnail pages i.e. category and filtering pages it shows a (from £xx to £xx) and when down to the single product page and the variation shave been selected to variation price shows.

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

I have certain attributes set as defaults and this is the price I would prefer to show on the category pages... the standard size and cost. BUT i have no idea if its possible or what code to change it to.

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

Is this possible? Any ideas?

推荐答案

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

to juist display one standard price > go to the THEME folder and open functions.php and add this to the end of the file:

// 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 翻译成您的语言,让它说:从价格)

(Translate the HERE YOUR LANGUAGE in the code to your language to let it say something like: From price )

这篇关于Woocommerce 变体产品价格显示默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆