woocommerce - WooCommerce 在 bool 上调用成员函数 get_type()
问题描述
在我的网站上更新插件后,我遇到了一个致命错误Call to a member function get_type() on bool
/* WooCommerece settings */
if ( defined( 'WOOCOMMERCE_VERSION' ) && isset( $query_post_type ) && $query_post_type == 'product' ) {
if ( function_exists( 'wc_get_product' ) ) {
// WC 3.0+
$woo_product = wc_get_product( $post->ID );
$woo_is_variation = $woo_product->get_type() == 'variable' ? true : false;
} else {
// Old WC
$woo_product = get_product( $post->ID );
$woo_is_variation = isset( $woo_product->product_type ) && ( $woo_product->product_type == 'variation' || $woo_product->product_type == 'variable' ) ? true : false;
if ( $woo_is_variation ) {$post = $woo_product->post;}
}
}
我尝试将代码修改为
if( $product->is_type('variable') ) :
$woo_is_variation = true;
else :
$woo_is_variation = false;
endif;
我已经联系了插件作者,但到目前为止我没有任何回应。
我的产品页面已关闭,希望能提供一些帮助。
解决方案
推荐阅读
- python - 如何合并2个数组python(类似于SQL Join)
- geopandas - 尝试将多边形中的两个多边形元素分配给 geopandas 几何列会导致 ValueError
- react-native - 最近 react-native 版本中的“无法解析模块”debuggerWorker 错误
- javascript - Firebase 身份验证服务器端
- java - Imageview 上的 Android 大图像在 OOM 错误时使应用程序崩溃
- c++ - Windows 命名管道丢弃消息
- r - 函数和 rollapply 找到所有值等于某物的任何窗口?
- bash - sed 在 bash 脚本中停止工作,但在 shell 中工作
- javascript - createElement 及其属性有错误
- python - 编辑 python 列表