WooCommerce update version 3.0.x breaks site –

I updated to WooCommerce version 3.0.x from version 2.6.x and my site strangely stops loading correctly.

I get the message:

Object of class WC_Product_Variable could not be converted to string

the source of the error is a line in the woocommerce/includes/wc-product-functions.php file

$value = ucwords( str_replace( '-', ' ', $value ) );

I was able to get the site working fine again by commenting out the block of code that incorporates the line, starting at “if ( taxonomy_exists( $name ) ) {“, but I don’t really feel comfortable with such a patchwork solution.

Could someone possibly explain the reason for this error?

Here is my code:

foreach ( $variation_attributes as $name => $value ) {
        if ( ! $value ) {
            continue;
        }

        // If this is a term slug, get the term's nice name
        /*if ( taxonomy_exists( $name ) ) {
            $term = get_term_by( 'slug', $value, $name );
            if ( ! is_wp_error( $term ) && ! empty( $term->name ) ) {
                $value = $term->name;
            }
        } else {
            $value = ucwords( str_replace( '-', ' ', $value ) );
        }

        if ( $include_names ) {
            if ( $flat ) {
                $variation_list[] = wc_attribute_label( $name, $product ) . ': ' . rawurldecode( $value );
            } else {
                $variation_list[] = '<dt>' . wc_attribute_label( $name, $product ) . ':</dt><dd>' . rawurldecode( $value ) . '</dd>';
            }
        } else {
            if ( $flat ) {
                $variation_list[] = rawurldecode( $value );
            } else {
                $variation_list[] = '<li>' . rawurldecode( $value ) . '</li>';
            }
        }*/
    }

Thanks

Read more here: WooCommerce update version 3.0.x breaks site –

Leave a Reply

Your email address will not be published. Required fields are marked *