我正在尝试输入一个插件,我正在编写产品的变体 ID。这是我写的:
class mass {
public function __construct()
{
add_action('woocommerce_product_after_variable_attributes',array($this,'thfo_mass'));
}
public function thfo_mass()
{
$id = WC_Product_Variation::get_variation_id();
//$lenght = get_post_meta($id,'_length');
//$dimensions = wc_get_dimension(24750, 'cm');
var_dump($id);
}
我只得到一个错误:
已弃用:不应静态调用非静态方法 WC_Product_Variation::get_variation_id(),假设 $this 来自第 19 行的 path/to/plugins/thfo-raw-material-for-woocommerce/class/mass.php 中的不兼容上下文
注意:未定义的属性:第 257 行 int(0) 上 path/to/wp-content/plugins/woocommerce/includes/class-wc-product-variation.php 中的 mass::$variation_id