久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

將 WooCommerce 可變產(chǎn)品價(jià)格范圍替換為“最高&qu

Replace WooCommerce variable products price range with #39;Up to#39; and the max price(將 WooCommerce 可變產(chǎn)品價(jià)格范圍替換為“最高和最高價(jià)格)
本文介紹了將 WooCommerce 可變產(chǎn)品價(jià)格范圍替換為“最高"和最高價(jià)格的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

我發(fā)現(xiàn)以下代碼(來(lái)自

感謝任何幫助.

解決方案

以下代碼將給出max"變量格式的價(jià)格后綴為Up to:"并處理銷(xiāo)售價(jià)格范圍:

add_filter( 'woocommerce_variable_sale_price_html', 'custom_variable_price_range', 10, 2 );add_filter( 'woocommerce_variable_price_html', 'custom_variable_price_range', 10, 2 );函數(shù) custom_variable_price_range( $price_html, $product ) {$prefix = __('Up to', 'woocommerce');$max_regular_price = $product->get_variation_regular_price('max', true);$max_sale_price = $product->get_variation_sale_price( 'max', true );$max_active_price = $product->get_variation_price( 'max', true );$min_active_price = $product->get_variation_price( 'min', true );$price_html = ( $max_sale_price == $max_regular_price ) ?wc_price( $max_active_price ) :'<del>'.wc_price( $max_regular_price ) .'</del><ins>'.wc_price( $max_sale_price ) .'</ins>';返回 $min_active_price == $max_active_price ?$price_html : sprintf('%s %s', $prefix, $price_html);}

代碼位于活動(dòng)子主題(或活動(dòng)主題)的 function.php 文件中.經(jīng)測(cè)試有效.

<小時(shí)>

如果您不想處理銷(xiāo)售價(jià)格范圍,您將使用:

add_filter( 'woocommerce_variable_sale_price_html', 'custom_variable_price_range', 10, 2 );add_filter( 'woocommerce_variable_price_html', 'custom_variable_price_range', 10, 2 );函數(shù) custom_variable_price_range( $price_html, $product ) {$prefix = __('Up to', 'woocommerce');$max_active_price = $product->get_variation_price( 'max', true );$min_active_price = $product->get_variation_price( 'min', true );$price_html = wc_price( $max_active_price );返回 $min_active_price == $max_active_price ?$price_html : sprintf('%s %s', $prefix, $price_html );}

代碼位于活動(dòng)子主題(或活動(dòng)主題)的 function.php 文件中.經(jīng)測(cè)試有效.

I found the following code (from here) which enables me to show on a variable price product on WooCommerce: 'From: £10' (on a £10 - £50 product). I would like to effectively reverse this and show 'Up to: £50'.

I have tried to tweak the code below, but just can't figure it out:

function custom_variable_price_range( $price_html, $product ) {
    $prefix = sprintf('%s: ', __('From', 'woocommerce') );

    $min_regular_price = $product->get_variation_regular_price( 'min', true );
    $min_sale_price    = $product->get_variation_sale_price( 'min', true );
    $max_price         = $product->get_variation_price( 'max', true );
    $min_price         = $product->get_variation_price( 'min', true );

    $price_html = ( $min_sale_price == $min_regular_price ) ? wc_price( $min_regular_price ) :
    '<del>' . wc_price( $min_regular_price ) . '</del>' . '<ins>' . wc_price( $min_sale_price ) . '</ins>';

    return ( $min_price == $max_price ) ? $price_html : sprintf( '%s%s', $prefix, $price_html );
}
add_filter( 'woocommerce_variable_sale_price_html', 'custom_variable_price_range', 10, 2 );
add_filter( 'woocommerce_variable_price_html', 'custom_variable_price_range', 10, 2 );

This is how I would like it to look:

Any help is appreciated.

解決方案

The following code will give the "max" variable formatted price suffixed with "Up to:" and handling on sale price range:

add_filter( 'woocommerce_variable_sale_price_html', 'custom_variable_price_range', 10, 2 );
add_filter( 'woocommerce_variable_price_html', 'custom_variable_price_range', 10, 2 );
function custom_variable_price_range( $price_html, $product ) {

    $prefix = __('Up to', 'woocommerce');

    $max_regular_price = $product->get_variation_regular_price( 'max', true );
    $max_sale_price    = $product->get_variation_sale_price( 'max', true );
    $max_active_price  = $product->get_variation_price( 'max', true );
    $min_active_price  = $product->get_variation_price( 'min', true );

    $price_html = ( $max_sale_price == $max_regular_price ) ? wc_price( $max_active_price ) :
    '<del>' . wc_price( $max_regular_price ) . '</del> <ins>' . wc_price( $max_sale_price ) . '</ins>';

    return $min_active_price == $max_active_price ? $price_html : sprintf('%s %s', $prefix, $price_html);
}

Code goes in function.php file of your active child theme (or active theme). Tested and works.


If you don't want to handle on sale price range, you will use instead:

add_filter( 'woocommerce_variable_sale_price_html', 'custom_variable_price_range', 10, 2 );
add_filter( 'woocommerce_variable_price_html', 'custom_variable_price_range', 10, 2 );
function custom_variable_price_range( $price_html, $product ) {

    $prefix = __('Up to', 'woocommerce');

    $max_active_price  = $product->get_variation_price( 'max', true );
    $min_active_price  = $product->get_variation_price( 'min', true );

    $price_html = wc_price( $max_active_price );

    return $min_active_price == $max_active_price ? $price_html : sprintf('%s %s', $prefix, $price_html );
}

Code goes in function.php file of your active child theme (or active theme). Tested and works.

這篇關(guān)于將 WooCommerce 可變產(chǎn)品價(jià)格范圍替換為“最高"和最高價(jià)格的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Session is lost after an OAuth redirect(OAuth 重定向后會(huì)話(huà)丟失)
Pagination Sort in Cakephp 3.x(Cakephp 3.x 中的分頁(yè)排序)
CakePHP Shared core for multiple apps(CakePHP 多個(gè)應(yīng)用程序的共享核心)
Login [ Auth-gt;identify() ] always false on CakePHP 3(在 CakePHP 3 上登錄 [ Auth-identify() ] 始終為 false)
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 87 bytes)(致命錯(cuò)誤:允許的內(nèi)存大小為 134217728 字節(jié)已用盡(嘗試分配 87 字節(jié)))
主站蜘蛛池模板: 国内久久 | 精品久久久久久久久久久 | 欧美一区二不卡视频 | 国产日韩欧美在线 | 中文字幕一区在线 | 久久亚洲免费 | 久草视频网站 | 我要看一级片 | 免费的黄色片子 | 亚洲精品久久视频 | 国产一区二区三区久久久久久久久 | 中文字幕国产视频 | 99久久久久国产精品免费 | 欧美日韩精品一区二区三区四区 | 欧美日韩免费 | 亚洲一区国产精品 | 日本韩国电影免费观看 | 99精品热视频 | 欧美日韩视频在线第一区 | 日韩欧美在线视频播放 | 欧美日韩久 | 亚洲国产精品成人 | 国产成人免费视频网站高清观看视频 | 国产夜恋视频在线观看 | 国产高清精品一区二区三区 | av官网在线| 欧美日韩综合 | 伊人狠狠| 91伊人 | 国产精品夜夜春夜夜爽久久电影 | 中文字幕免费视频 | 久久av一区二区三区 | 午夜专区| 成人免费在线观看 | 黄色网毛片 | 免费在线黄色av | 亚洲福利免费 | 国产精品国产成人国产三级 | 国产午夜视频 | 日日综合 | 成人福利视频网站 |