Categories

有特色的模板

WooCommerce. 如何消除可变产品的可用价格范围

Elina Webb June 2, 2016
Rating: 4.6/5. From 5 votes.
Please wait...

本视频教程将向您展示如何删除可变产品中可用的价格范围 WooCommerce templates.

WooCommerce-How_to_remove_variable_products_available_price_range-1
  1. 连接到你的 FTP/File Manager,沿着这条路走: wp-content /主题/ themeXXXXX /包括 and look for custom-function.php file to edit.

    WooCommerce-How_to_remove_variable_products_available_price_range-2

    你也可以找到这个 custom-function.php file under the Appearance > Editor 在WordPress管理面板.

    WooCommerce-How_to_remove_variable_products_available_price_range-3
  2. 为了移除价格中较大的值,我们应该将以下代码添加到 custom-function.php -在结束标记之前 ?> 在文件的底部:

    /*
    可变产品价格范围: 
    */
    
    Add_filter ('woocommerce_variable_sale_price_html', 'my_variation_price_format', 10,2);
    
    Add_filter ('woocommerce_variable_price_html', 'my_variation_price_format', 10,2);
    
    函数my_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 (__ (' % 1 $ s ', ' woocommerce '), wc_price(美元价格[0])):wc_price(美元价格[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 (__ (' % 1 $ s ', ' woocommerce '), wc_price(美元价格[0])):wc_price(美元价格[0]);
    
    if ( $price !== $ salesprice) {
    $price = '' . $saleprice . ' ' . $price . '';
    }
    return $price;
    }

    结果如下:

    WooCommerce-How_to_remove_variable_products_available_price_range-4
  3. 要完全删除价格范围,我们将向 custom-function.php -在结束标记之前 ?> 放到文件的底部.

    /*
    完全禁用可变产品价格范围:
    */
    
    Add_filter ('woocommerce_variable_sale_price_html', 'my_remove_variation_price', 10,2);
    Add_filter ('woocommerce_variable_price_html', 'my_remove_variation_price', 10,2);
    
    函数my_remove_variation_price($price) {
    $price = '';
    return $price;
    }

    下面你可以看到添加代码的结果:

    WooCommerce-How_to_remove_variable_products_available_price_range-5

请随时查看下面的详细视频教程.

WooCommerce. 如何消除可变产品的可用价格范围
易于使用的Wordpress主题
这个条目被张贴了出来 WooCommerce教程 and tagged price range, 变量的产品, WooCommerce. Bookmark the permalink.

提交罚单

如果您仍然无法找到关于您的问题的足够的教程,请使用以下链接向我们的技术支持团队提交请求. 我们将在接下来的24小时内为您提供我们的帮助和协助: 提交罚单