2
我從版本2.6.x更新爲WooCommerce版本3.0.x,並且我的站點奇怪地停止正確加載。WooCommerce更新版本3.0.x破解站點 -
我得到的消息:
「類WC_Product_Variable的對象無法轉換爲字符串」
錯誤的來源是woocommerce/includes/wc-product-functions.php文件中的一行
$value = ucwords(str_replace('-', ' ', $value));
我能夠通過註釋出鱈魚塊來使網站再次正常工作e整合了這一行,從「if (taxonomy_exists($name)) {
」開始,但我對這種拼湊解決方案並不感到滿意。
有人可能可以解釋這個錯誤的原因嗎?
這是我的代碼:
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>';
}
}*/
}
由於
謝謝您的回答Loric!我一直在嘗試使用foreach循環,迄今爲止沒有成功。在這種情況下,我會如何編碼?此外,任何想法爲什麼這個錯誤將首先出現?我試過禁用所有其他woocommerce相關的插件,無濟於事。 – isk
酷,我會試着看你 – isk
https://github.com/woocommerce/woocommerce/blob/master/includes/wc-product-functions.php - 這是一個鏈接到同一個文件的github上傳。對我來說,錯誤從370行開始 – isk