WP-Woocommerce内部服务器错误500代码片段

时间:2014-10-30 11:45:59

标签: php wordpress

当我将此代码添加到functions.php时 我收到内部服务器错误.... 怎么了?

该片段的用途:此代码用于替换具有变化(价格1,价格2)的产品中的价格,它将从“1 $”输出,显示价格较低......

在debbuging从日志中得到了这个:

 PHP Warning: Cannot modify header information - headers already sent by (output started at /home/organicb/public_html/wp-content/themes/flatsome-child/functions.php:20) in /home/organicb/public_html/wp-includes/pluggable.php
https://gist.github.com/kloon/8981075

中找到了

代码段

 // 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( __( 'Desde: %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( __( 'Desde: %1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );

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

1 个答案:

答案 0 :(得分:0)

您应该使用wp_debug启用。在您的wp-config.php文件中,搜索:

define('WP_DEBUG', false);

并改为:

define('WP_DEBUG', true);