我正在尝试插入一个插件,我正在编写产品的变体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);
}
Run Code Online (Sandbox Code Playgroud)
我只收到一个错误:
不推荐使用:非静态方法WC_Product_Variation :: get_variation_id()不应该静态调用,假设$ this来自路径中的不兼容上下文/ to/plugins/thfo-raw-material-for-woocommerce/class/mass.php第19行
注意:未定义属性:mass :: $ variation_id in path/to/wp-content/plugins/woocommerce/includes/class-wc-product-variation.php on line 257 int(0)